Handle multiple onu discover events gracefully
Change-Id: I63831df976654bcb612a06f491932baf7bf1ab5c
diff --git a/voltha/adapters/openolt/openolt_data_model.py b/voltha/adapters/openolt/openolt_data_model.py
index de43677..03db02a 100644
--- a/voltha/adapters/openolt/openolt_data_model.py
+++ b/voltha/adapters/openolt/openolt_data_model.py
@@ -178,10 +178,9 @@
if onu_device:
self.log.debug("data_model onu update", intf_id=intf_id,
onu_id=onu_id, serial_number=serial_number)
- onu_device.oper_status = OperStatus.DISCOVERED
- onu_device.connect_status = ConnectStatus.REACHABLE
- self.adapter_agent.update_device(onu_device)
- return
+ if onu_device.oper_status == OperStatus.ACTIVATING \
+ or onu_device.oper_status == OperStatus.DISCOVERED:
+ raise ValueError
self.log.debug("data_model onu create", intf_id=intf_id,
onu_id=onu_id, serial_number=serial_number)
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index 928d1aa..343f128 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -213,9 +213,13 @@
if onu_id is None:
raise Exception("onu-id-unavailable")
- self.data_model.onu_create(intf_id, onu_id, serial_number_str)
-
- self.activate_onu(intf_id, onu_id, serial_number, serial_number_str)
+ try:
+ self.data_model.onu_create(intf_id, onu_id, serial_number_str)
+ except ValueError:
+ pass
+ else:
+ self.activate_onu(intf_id, onu_id, serial_number,
+ serial_number_str)
def onu_indication(self, onu_indication):
self.log.debug("onu indication", intf_id=onu_indication.intf_id,