From 611df7ce4ccf5151bf77937fcdf9eb1b29379edc Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Fri, 28 May 2021 15:27:14 +0000 Subject: [PATCH] changed status of non-monitored services --- inventory_provider/routes/classifier.py | 4 +-- inventory_provider/tasks/worker.py | 34 ++++++++----------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 9d72b5b8..f470dd33 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -143,15 +143,13 @@ 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'] and s['circuit_type'] == 'service': + if s['circuit_type'] == 'service': contacts.update(set(s.pop('contacts', set()))) _format_service(s) result['services'].append(s) result['related-services'] = list(related_services.values()) result['contacts'] = sorted(list(contacts)) - # non-monitored related services are not added by the worker so don't - # need filtering out here if not result['services']: result.pop('services', None) if result['related-services']: diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index 82644b92..a36a5faf 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -571,8 +571,6 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False): tls_names = list(ims_data.get_service_types(ds1)) customer_contacts = \ {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)) @@ -618,7 +616,6 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False): nonlocal hierarchy hierarchy = {} for d in ims_data.get_circuit_hierarchy(ds1): - d['monitored'] = d['id'] in circuit_ids_to_monitor d['contacts'] = customer_contacts.get(d['customerid'], []) hierarchy[d['id']] = d logger.debug("hierarchy complete") @@ -667,25 +664,20 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False): c = hierarchy.get(circuit_id, None) if c: - def _is_rs(candidate): - if candidate['id'] in circuit_ids_not_to_monitor: - return False - if candidate['product'] in tls_names: - return True - # if candidate['speed'] == 'BGP': - # return True - return False - - if _is_rs(c): + if c['circuit-type'] == 'service': rs[c['id']] = { 'id': c['id'], 'name': c['name'], - 'status': c['status'], - 'circuit_type': 'service', + 'circuit_type': c['circuit-type'], 'service_type': c['product'], 'project': c['project'], 'contacts': sorted(list(c['contacts'])) } + if c['id'] in circuit_ids_to_monitor: + rs[c['id']]['status'] = c['status'] + else: + rs[c['id']]['status'] = 'non-monitored' + if c['sub-circuits']: for sub in c['sub-circuits']: temp_parents = \ @@ -694,10 +686,10 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False): return list(rs.values()) def _format_service(s): - if s['id'] in circuit_ids_not_to_monitor: - s['monitored'] = False - else: - s['monitored'] = True + + if s['circuit_type'] == 'service' \ + and s['id'] not in circuit_ids_to_monitor: + s['status'] = 'non-monitored' pd_a = port_id_details[s['port_a_id']][0] location_a = locations.get(pd_a['equipment_name'], None) if location_a: @@ -758,10 +750,6 @@ def update_circuit_hierarchy_and_port_id_services(self, use_current=False): 'name': hierarchy[x]['name'], 'status': hierarchy[x]['status'] } - if c['id'] in circuit_ids_not_to_monitor: - c['monitored'] = False - else: - c['monitored'] = True circ['fibre-routes'].append(c) circ['related-services'] = \ -- GitLab