diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index d78e7628fc33051170d60c7b17cf70d5528d9ae0..77614dc33700cdf8e26c61544c4c972d6214934c 100644 --- a/inventory_provider/db/ims_data.py +++ b/inventory_provider/db/ims_data.py @@ -124,6 +124,14 @@ def get_port_id_services(ds: IMS): # internal port a / internal port b # port a / port b + # if there are more than two ports we'll yield a circuit of the ends of the + # sequence and the reverse; and then single ended circuits for all ports + # between + # e.g. four ports are reported [a,b,c,d] the 4 circs would have endpoints + # a and d + # d and a + # b only + # c only def _populate_end_info(_circuit, _port_ids): port_ids = [p for p in _port_ids if p] if not port_ids: @@ -133,15 +141,15 @@ def get_port_id_services(ds: IMS): _circuit['port_a_id'] = port_a_id if port_a_id != port_b_id: _circuit['port_b_id'] = port_b_id - yield _circuit + yield copy(_circuit) _circuit['port_a_id'], _circuit['port_b_id'] = \ _circuit['port_b_id'], _circuit['port_a_id'] - yield _circuit + yield copy(_circuit) if len(port_ids) > 2: _circuit.pop('port_b_id', None) for p in port_ids[1:-1]: _circuit['port_a_id'] = p - yield _circuit + yield copy(_circuit) for circuit in circuits: cd = {