From 67ceb485bf10a9facca8eec689b49046d0028402 Mon Sep 17 00:00:00 2001
From: Robert Latta <robert.latta@geant.org>
Date: Fri, 16 Apr 2021 12:02:42 +0000
Subject: [PATCH] added contacts from direct interface

---
 inventory_provider/db/ims_data.py  | 4 +++-
 inventory_provider/tasks/worker.py | 8 +++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py
index 455905eb..838aed07 100644
--- a/inventory_provider/db/ims_data.py
+++ b/inventory_provider/db/ims_data.py
@@ -123,7 +123,8 @@ def get_port_id_services(ds: IMS):
                     InventoryStatus(circuit['inventorystatusid']), 'unknown'),
             'circuit_type': circuit['circuit_type'],
             'service_type': products[circuit['productid']],
-            'project': customers[circuit['customerid']]
+            'project': customers[circuit['customerid']],
+            'customerid': circuit['customerid']
         }
         ports = []
         if circuit['internalports']:
@@ -168,6 +169,7 @@ def get_port_id_services(ds: IMS):
                 'circuit_type': _get_circuit_type(circuit),
                 'service_type': products[circuit['productid']],
                 'project': customers[circuit['customerid']],
+                'customerid': circuit['customerid'],
                 'port_a_id': portrelate.get(
                     'portid',
                     portrelate.get('internalportid', ''))
diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py
index e0d00fff..00d2e817 100644
--- a/inventory_provider/tasks/worker.py
+++ b/inventory_provider/tasks/worker.py
@@ -634,6 +634,13 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False):
             circuits = port_id_services.get(details['port_id'], [])
 
             for circ in circuits:
+                contacts = set()
+                contacts.update(
+                    customer_contacts.get(
+                        circ['customerid'],
+                        []
+                    )
+                )
                 circ['fibre-routes'] = \
                     [{
                         'id': hierarchy[x]['id'],
@@ -643,7 +650,6 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False):
                 circ['top-level-services'] = \
                     get_top_level_services(circ['id'])
 
-                contacts = set()
                 for tlc in circ['top-level-services']:
                     contacts.update(tlc.pop('contacts'))
                 circ['contacts'] = sorted(list(contacts))
-- 
GitLab