diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index c07f0d18cb425f779ffb1af18cd5932b2ba871e3..f6d856c845b328aa7a0cf65a7afa7af10adad29d 100644 --- a/inventory_provider/db/ims_data.py +++ b/inventory_provider/db/ims_data.py @@ -37,6 +37,18 @@ def get_non_monitored_circuit_ids(ds: IMS): yield d['extrafieldvalueobjectinfo']['objectid'] +def get_monitored_circuit_ids(ds: IMS): + # note the id for the relevant field is hard-coded. I didn't want to use + # the name of the field as this can be changed by users + for d in ds.get_filtered_entities( + 'ExtraFieldValue', + 'extrafield.id == 2898 | value == 1', + EXTRA_FIELD_VALUE_PROPERTIES['ExtraFieldValueObjectInfo'], + step_count=10000 + ): + yield d['extrafieldvalueobjectinfo']['objectid'] + + def get_service_types(ds: IMS): for d in ds.get_filtered_entities( 'ComboBoxData', diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index d5a558e1c1628328611c6853528bab9805625231..9d72b5b89a79e1ec2e54e0fb247294a09a5c7ad5 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -143,7 +143,7 @@ def get_interface_services_and_loc(ims_source_equipment, ims_interface, redis): for s in json.loads(raw_services.decode('utf-8')): related_services.update( {r['id']: r for r in s['related-services']}) - if s['monitored']: + if s['monitored'] and s['circuit_type'] == 'service': contacts.update(set(s.pop('contacts', set()))) _format_service(s) result['services'].append(s) diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index 170c0a283b08433a2ec6e7a264b5f729e74cd006..82644b92c8cdcd2ab1c9ebf7fe9c3b2eaa461a9e 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -573,6 +573,8 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False): {k: v for k, v in ims_data.get_customer_service_emails(ds1)} circuit_ids_not_to_monitor = \ list(ims_data.get_non_monitored_circuit_ids(ds1)) + circuit_ids_to_monitor = \ + list(ims_data.get_monitored_circuit_ids(ds1)) hierarchy = None port_id_details = defaultdict(list) @@ -616,10 +618,7 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False): nonlocal hierarchy hierarchy = {} for d in ims_data.get_circuit_hierarchy(ds1): - if d['id'] in circuit_ids_not_to_monitor: - d['monitored'] = False - else: - d['monitored'] = True + d['monitored'] = d['id'] in circuit_ids_to_monitor d['contacts'] = customer_contacts.get(d['customerid'], []) hierarchy[d['id']] = d logger.debug("hierarchy complete")