From d42ad226504b50fab675b670c0ca246da8e09277 Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Tue, 13 Sep 2022 11:40:00 +0100 Subject: [PATCH] changed structure of retrieved data RE. DBOARD3-659 --- inventory_provider/db/ims_data.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index 0851fa3e..d4ef64ec 100644 --- a/inventory_provider/db/ims_data.py +++ b/inventory_provider/db/ims_data.py @@ -67,14 +67,20 @@ NODE_LOCATION_SCHEMA = { } -def get_flex_ils_entities(ds: IMS): - for f in ds.get_all_entities('FLEXILS_SCHF_SUBINTERFACES'): - yield { - 'circuit_id': f['circuitid'], - 'node_name': f['nodename'], - 'port_name': f['port'], - 'full_port_name': f['port_ref'] - } +def get_flexils_by_circuitid(ds: IMS): + by_circuit = defaultdict(list) + found_keys = set() + for entity in ds.get_all_entities('FLEXILS_SCHF_SUBINTERFACES'): + k = f'{entity["nodename"]}:{entity["port_ref"]}' + if k in found_keys: + continue + found_keys.add(k) + by_circuit[entity['circuitid']].append({ + 'node_name': entity['nodename'], + 'full_port_name': entity['port_ref'], + 'key': k + }) + return dict(by_circuit) def get_non_monitored_circuit_ids(ds: IMS): -- GitLab