From 3740dd699341d65461fd2b247fcc65910f265aa8 Mon Sep 17 00:00:00 2001
From: Robert Latta <robert.latta@geant.org>
Date: Wed, 17 Mar 2021 13:43:31 +0000
Subject: [PATCH] corrected portrelate query

---
 inventory_provider/db/ims.py       | 7 +++++--
 inventory_provider/db/ims_data.py  | 6 +-----
 inventory_provider/tasks/worker.py | 2 +-
 test/test_ims_data.py              | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/inventory_provider/db/ims.py b/inventory_provider/db/ims.py
index c15fdbc0..d23557dc 100644
--- a/inventory_provider/db/ims.py
+++ b/inventory_provider/db/ims.py
@@ -232,8 +232,11 @@ class IMS(object):
 
                 if NO_FILTERED_RESULTS_MESSAGE in response_.text.lower():
                     return False
-
-                r = response_.json()
+                try:
+                    r = response_.json()
+                except Exception as e:
+                    logger.debug(f"unexpected response: {response_.text}")
+                    raise e
                 if r and 'HasErrors' in r and r['HasErrors']:
                     for e in r['Errors']:
                         if 'Guid expired' in e['ErrorMessage']:
diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py
index d6c82aa8..d86b158c 100644
--- a/inventory_provider/db/ims_data.py
+++ b/inventory_provider/db/ims_data.py
@@ -35,8 +35,6 @@ def get_service_types(ds: IMS):
         yield d['selection']
 
 
-
-# http://test-inventory-provider-ims.geant.org:8080/classifier/infinera-lambda-info/VEN-OLA1/1-A-3-L1/wibble
 def get_fibre_info(ds: IMS):
     # get all the wdm ots circuits where each node is in a different location
 
@@ -177,10 +175,8 @@ def get_port_id_services(ds: IMS):
             ports = [circuit['portaid'], circuit['portbid']]
         yield from _populate_end_info(cd, ports)
 
-
-
     ignore_status_str = ''.join([
-        f'inventoryStatusId != {s} | ' for s in STATUSES_TO_IGNORE
+        f'circuit.inventoryStatusId != {s} | ' for s in STATUSES_TO_IGNORE
     ])
     for portrelate in chain(
             ds.get_filtered_entities(
diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py
index de531464..eb2a6c2e 100644
--- a/inventory_provider/tasks/worker.py
+++ b/inventory_provider/tasks/worker.py
@@ -496,7 +496,7 @@ def update_fibre_spans(self, use_current=False):
 
 
 @app.task(
-    base=InventoryTask, bind=True, name='update_interfaces_to_services_ims')
+    base=InventoryTask, bind=True, name='update_interfaces_to_services')
 @log_task_entry_and_exit
 def update_interfaces_to_services(self, use_current=False):
     port_id_services = defaultdict(list)
diff --git a/test/test_ims_data.py b/test/test_ims_data.py
index 4df183a8..8bdf6dbb 100644
--- a/test/test_ims_data.py
+++ b/test/test_ims_data.py
@@ -5,7 +5,7 @@ from inventory_provider.db.ims import InventoryStatus
 from inventory_provider.db.ims_data import lookup_lg_routers, \
     otrs_get_customer_company_rows, \
     otrs_get_customer_users_rows, get_node_locations, IMS_OPSDB_STATUS_MAP, \
-    get_fibre_info, get_port_id_services, get_port_details, \
+    get_port_id_services, get_port_details, \
     get_circuit_hierarchy
 
 
-- 
GitLab