diff --git a/Changelog.md b/Changelog.md index b6cd2534d833a6842d0aad571a8a8a7bd5b3e63b..311b195c637510b4dbbe3d646653dec083755cb6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## [0.82] - 2022-02-24 +- POL1-487: Made filtering for COPERNICUS dashboard more specific +- POL1-560: Added GBS_10G dashboard tag for circuits related to 10G Guaranteed Bandwidth Service + +## [0.81] - 2022-02-17 +- POL1-521: handle RPC timeout error properly, and log errors + ## [0.80] - 2022-02-16 - POL1-487: Adjusted filtering for COPERNICUS dashboard (no longer overrides customer names) diff --git a/inventory_provider/routes/msr.py b/inventory_provider/routes/msr.py index 09c459a3391fe1fae9d39f69cd2dba2a233b15da..95887f10015a6ee23f467616bf5524e5dd9d4312 100644 --- a/inventory_provider/routes/msr.py +++ b/inventory_provider/routes/msr.py @@ -229,6 +229,8 @@ SYSTEM_CORRELATION_SERVICES_LIST_SCHEMA = { 'properties': { 'circuit_id': {'type': 'integer'}, 'sid': {'type': 'string'}, + 'status': {'type': 'string'}, + 'monitored': {'type': 'boolean'}, 'name': {'type': 'string'}, 'speed': {'type': 'integer'}, 'circuit_type': {'type': 'string'}, # TODO: remove this? @@ -238,7 +240,7 @@ SYSTEM_CORRELATION_SERVICES_LIST_SCHEMA = { 'endpoints': {'$ref': '#/definitions/endpoints'} }, 'required': [ - 'circuit_id', 'sid', 'name', 'speed', + 'circuit_id', 'sid', 'name', 'speed', 'status', 'monitored', # 'circuit_type', 'project', # TODO: keeping these?!? 'service_type', 'customer', 'endpoints'], 'additionalProperties': False @@ -772,31 +774,28 @@ def get_system_correlation_services(): if matches: peering_info[matches[1]][doc['value']['name']] = doc['value'] - logical_interface_re = re.compile(r'.*\.\d+$') - def _ip_endpoint_extractor(endpoint_details: Dict): - if logical_interface_re.match(endpoint_details['port']): - hostname = ims_equipment_to_hostname( - endpoint_details['equipment']) - interface = endpoint_details['port'].lower() + hostname = ims_equipment_to_hostname( + endpoint_details['equipment']) + interface = endpoint_details['port'].lower() - ip_endpoint = { - 'hostname': hostname, - 'interface': interface, - } - addresses = {} - host_info = peering_info.get(hostname, {}) - interface_info = host_info.get(interface, {}) - ipv4 = interface_info.get('ipv4') - ipv6 = interface_info.get('ipv6') - if ipv4: - addresses['v4'] = ipv4[0] - if ipv6: - addresses['v6'] = ipv6[0] - if ipv4 or ipv6: - ip_endpoint['addresses'] = addresses - - return ip_endpoint + ip_endpoint = { + 'hostname': hostname, + 'interface': interface, + } + addresses = {} + host_info = peering_info.get(hostname, {}) + interface_info = host_info.get(interface, {}) + ipv4 = interface_info.get('ipv4') + ipv6 = interface_info.get('ipv6') + if ipv4: + addresses['v4'] = ipv4[0] + if ipv6: + addresses['v6'] = ipv6[0] + if ipv4 or ipv6: + ip_endpoint['addresses'] = addresses + + return ip_endpoint def _optical_endpoint_extractor(endpoint_details: Dict): return { @@ -823,6 +822,8 @@ def get_system_correlation_services(): if not service_info.get('sid'): service_info['circuit_id'] = d['circuit_id'] service_info['sid'] = d['sid'] + service_info['status'] = d['status'] + service_info['monitored'] = d['monitored'] service_info['name'] = d['name'] service_info['speed'] = d['speed'] service_info['service_type'] = d['service_type'] diff --git a/inventory_provider/routes/poller.py b/inventory_provider/routes/poller.py index 7ff8494c26edc49339598b64c229f573f9d11041..6d7476e0fd50a2ba20d64b13cea4a2c233555e0e 100644 --- a/inventory_provider/routes/poller.py +++ b/inventory_provider/routes/poller.py @@ -105,6 +105,7 @@ class BRIAN_DASHBOARDS(Enum): IAS_CUSTOMER = auto() IAS_UPSTREAM = auto() GWS_PHY_UPSTREAM = auto() + GBS_10G = auto() # aggregate dashboards CLS_PEERS = auto() @@ -112,13 +113,11 @@ class BRIAN_DASHBOARDS(Enum): GWS_UPSTREAMS = auto() LHCONE = auto() CAE1 = auto() + COPERNICUS = auto() # NREN customer NREN = auto() - # COPERNICUS - COPERNICUS = auto() - # only used in INTERFACE_LIST_SCHEMA and sphinx docs _DASHBOARD_IDS = [d.name for d in list(BRIAN_DASHBOARDS)] @@ -418,7 +417,7 @@ def _get_dashboards(interface): router = interface.get('router', '').lower() ifc_name = interface.get('name', '') description = interface.get('description', '').strip() - if re.search(r'COPERNICUS.*?\|', description, flags=re.IGNORECASE): + if 'SRV_L3VPN' in description and 'COPERNICUS' in description: yield BRIAN_DASHBOARDS.COPERNICUS if 'SRV_CLS' in description: yield BRIAN_DASHBOARDS.CLS @@ -434,6 +433,8 @@ def _get_dashboards(interface): yield BRIAN_DASHBOARDS.IAS_CUSTOMER if 'SRV_IAS UPSTREAM' in description: yield BRIAN_DASHBOARDS.IAS_UPSTREAM + if 'SRV_10GGBS CUSTOMER' in description: + yield BRIAN_DASHBOARDS.GBS_10G if re.match('(SRV_GLOBAL|SRV_L3VPN|LAG) RE_INTERCONNECT', description): yield BRIAN_DASHBOARDS.RE_PEER if re.match(r'(PHY|LAG|SRV_GLOBAL) CUSTOMER', description): diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index aca83241178140922013115cd2727ff337c62074..afa0ddbd3600ce438e0377d2faeafeb2ef4a0d33 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -942,9 +942,11 @@ def transform_ims_data(data): return list(rs.values()) def _format_service(s): - + s['original_status'] = s['status'] + s['monitored'] = True if s['circuit_type'] == 'service' \ and s['id'] not in circuit_ids_to_monitor: + s['monitored'] = False s['status'] = 'non-monitored' pd_a = port_id_details[s['port_a_id']][0] location_a = locations.get(pd_a['equipment_name'], None) @@ -1025,8 +1027,7 @@ def transform_ims_data(data): f"{circ['equipment']}/{circ['other_end_equipment']}" ][circ['id']] = circ - if circ['id'] in circuit_ids_and_sids \ - and circ['status'] == 'operational': + if circ['id'] in circuit_ids_and_sids: sid = circuit_ids_and_sids[circ['id']] circ['sid'] = sid if circ['circuit_type'] == 'circuit': @@ -1036,6 +1037,8 @@ def transform_ims_data(data): sid_info = { 'circuit_id': circ['id'], 'sid': sid, + 'status': circ['original_status'], + 'monitored': circ['monitored'], 'name': circ['name'], 'speed': circ['calculated-speed'], 'service_type': circ['service_type'], @@ -1165,12 +1168,13 @@ def final_task(self): _build_subnet_db(update_callback=self.log_info) _build_snmp_peering_db(update_callback=self.log_info) _build_juniper_peering_db(update_callback=self.log_info) - populate_poller_interfaces_cache() + populate_poller_interfaces_cache(warning_callback=self.log_warning) latch_db(InventoryTask.config) self.log_info('latched current/next dbs') +@log_task_entry_and_exit def populate_poller_interfaces_cache(warning_callback=lambda s: None): no_lab_cache_key = 'classifier-cache:poller-interfaces:all:no_lab' all_cache_key = 'classifier-cache:poller-interfaces:all' diff --git a/setup.py b/setup.py index c53c286396dd23dc7b41aa4a71245306a4690a59..34abd94d96d02f779570b7f7c43fed0f85aafc29 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='inventory-provider', - version="0.81", + version="0.83", author='GEANT', author_email='swd@geant.org', description='Dashboard inventory provider', diff --git a/test/data/router-info.json b/test/data/router-info.json index f343a351d8e821b2ffb14579f134256a23e46483..11cf50f26a517892c3177aaebce341a8dd8207d0 100644 Binary files a/test/data/router-info.json and b/test/data/router-info.json differ diff --git a/test/test_general_poller_routes.py b/test/test_general_poller_routes.py index cda06e6b496aeea370a6b90c2f3025b69ce59d07..01e17d43e355a67c24bec94ab878db90f5e4deae 100644 --- a/test/test_general_poller_routes.py +++ b/test/test_general_poller_routes.py @@ -298,7 +298,9 @@ def test_fw_counter_bytes_oid_values(customer, interface_name, expected_oid): ('SRV_L2CIRCUIT CUSTOMER TENET PSNC #lon-lon-GEANTOPEN-PSNC-TENET-18067 |', # noqa: E501 ['GEANTOPEN', 'L2_CIRCUIT']), ('SRV_L3VPN RE_INTERCONNECT REDCLARA #REDCLARA-MAD-COPERNICUS | ASN27750', - ['LHCONE', 'COPERNICUS', 'RE_PEER']) + ['LHCONE', 'COPERNICUS', 'RE_PEER']), + ('SRV_10GGBS CUSTOMER REDIRIS CERN #gen-mad-LHC-CERN-REDIRIS-07003 |', + ['GBS_10G']) ]) def test_interface_dashboard_mapping(description, expected_dashboards): interface = { diff --git a/test/test_worker.py b/test/test_worker.py index a6a44ab09a9f1ee0dafff65e2074b16b4a875c79..9e6044c463e74b45c23f1c594936a1ce28377f25 100644 --- a/test/test_worker.py +++ b/test/test_worker.py @@ -336,6 +336,8 @@ def test_transform_ims_data(): { 'circuit_id': "sub_circuit_2", 'sid': "SID-01", + 'status': 'operational', + 'monitored': True, 'name': "sub_circuit_2", 'speed': 10 << 30, 'service_type': "PEERING R & E", @@ -348,6 +350,8 @@ def test_transform_ims_data(): { 'circuit_id': "sub_circuit_2", 'sid': "SID-01", + 'status': 'operational', + 'monitored': True, 'name': "sub_circuit_2", 'speed': 10 << 30, 'service_type': "PEERING R & E",