VOL-950: Lookup onu device based on PON-intf_id and onu id
The adapter_agent.get_child_device() method is used by OLT adapters
to lookup the ONU device. The lookup allows search on ONU ID
(and/or ONU serial number).
When looking up by ONU ID, this method should also take the
PON interface id into consideration since ONU IDs are not
unique across PONs.
The parent_port_no member of the Device class is used to identify
the PON interface that the ONU is connected to.
Change-Id: I19478e73157c74e095fb84b327b317539fc10276
diff --git a/voltha/core/adapter_agent.py b/voltha/core/adapter_agent.py
index 4e4a9e5..037fadb 100644
--- a/voltha/core/adapter_agent.py
+++ b/voltha/core/adapter_agent.py
@@ -287,8 +287,10 @@
:return: Child Device Object or None
"""
# Get all arguments to be used for comparison
- # Note that for now we are only matching on the ONU ID & SERIAL NUMBER
+ # Note that for now we are only matching on the
+ # PON Interface Id (parent_port_no), ONU ID & SERIAL NUMBER
# Other matching fields can be added as required in the future
+ parent_port_no = kwargs.pop('parent_port_no', None)
onu_id = kwargs.pop('onu_id', None)
serial_number = kwargs.pop('serial_number', None)
if onu_id is None and serial_number is None: return None
@@ -309,7 +311,13 @@
found_onu_id = False
if onu_id is not None:
if device.proxy_address.onu_id == onu_id:
- found_onu_id = True
+ # Does the ONU ID belong to the right PON port?
+ # (ONU IDs are not unique across PON ports)
+ if parent_port_no is not None:
+ if device.parent_port_no == parent_port_no:
+ found_onu_id = True
+ else:
+ found_onu_id = True
# Does this child device match the passed in SERIAL NUMBER?
found_serial_number = False