From aeb9db1708f7239e277e14febf836129caf8c60c Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Tue, 9 Feb 2021 15:41:00 +0000 Subject: [PATCH] yielded copies of dicts to prevent polution --- inventory_provider/db/ims_data.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index d78e7628..77614dc3 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 = { -- GitLab