diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index 42a03400cb3d5db9dbe59b4383a475deaaaa4ccb..89e4015716dba0f8fce6a324d17e11e443aea98a 100644 --- a/inventory_provider/db/ims_data.py +++ b/inventory_provider/db/ims_data.py @@ -14,12 +14,12 @@ logger = logging.getLogger(__name__) # Dashboard V3 IMS_OPSDB_STATUS_MAP = { - InventoryStatus.PLANNED: 'Planned', - InventoryStatus.READY_FOR_SERVICE: 'Installed', - InventoryStatus.IN_SERVICE: 'Operational', - InventoryStatus.MIGRATION: 'Planned', - InventoryStatus.OUT_OF_SERVICE: 'Terminated', - InventoryStatus.READY_FOR_CEASURE: 'Disposed' + InventoryStatus.PLANNED: 'planned', + InventoryStatus.READY_FOR_SERVICE: 'installed', + InventoryStatus.IN_SERVICE: 'operational', + InventoryStatus.MIGRATION: 'planned', + InventoryStatus.OUT_OF_SERVICE: 'terminated', + InventoryStatus.READY_FOR_CEASURE: 'disposed' } @@ -87,6 +87,7 @@ def get_port_id_services(ds: IMS): # 'BGP', } circuit_nav_props = [ + ims.CIRCUIT_PROPERTIES['Customer'], ims.CIRCUIT_PROPERTIES['Speed'], ims.CIRCUIT_PROPERTIES['Product'], ims.CIRCUIT_PROPERTIES['Ports'], @@ -142,7 +143,7 @@ def get_port_id_services(ds: IMS): InventoryStatus(circuit['inventorystatusid']), 'unknown'), 'circuit_type': circuit['circuit_type'], 'service_type': circuit['product']['name'], - 'project': circuit['product']['name'] + 'project': circuit['customer']['name'] } ports = [] if circuit['internalports']: diff --git a/inventory_provider/routes/ims_classifier.py b/inventory_provider/routes/ims_classifier.py index 393babe68661b7d5d7cacc6be6f4456c023f6601..f5482d01538621de9d79348d62313178bce5a1a5 100644 --- a/inventory_provider/routes/ims_classifier.py +++ b/inventory_provider/routes/ims_classifier.py @@ -13,6 +13,7 @@ from redis import Redis from inventory_provider.db.ims import IMS_SERVICE_NAMES from inventory_provider.routes import common +from inventory_provider.routes.classifier import _asn_group_info routes = Blueprint("ims-inventory-data-classifier-support-routes", __name__) @@ -274,6 +275,8 @@ def get_interface_services_and_locs(ims_source_equipment, ims_interface, r): result['locations'].append(loc) result['services'] = list(services_dict.values()) result['related-services'] = list(rs_dict.values()) + for r in result['related-services']: + r.pop('id', None) if not result.get('locations'): result['locations'] = [ @@ -336,6 +339,15 @@ def get_juniper_link_info(source_equipment: str, interface: str) -> Response: else: result['interface']['bundle_members'] = [] + snmp_info = r.get( + f'snmp-interfaces-single:{source_equipment}:{interface}') + if snmp_info: + snmp_info = json.loads(snmp_info.decode('utf-8')) + ifc_info['snmp'] = { + 'community': snmp_info['community'], + 'index': snmp_info['index'] + } + result.update(get_interface_services_and_locs( ims_source_equipment, ims_interface, @@ -465,6 +477,10 @@ def peer_info(address_str: str) -> Response: _location_from_equipment( get_ims_equipment_name(info['router']), r))) + asn_group_info = _asn_group_info(r, address_str) + if asn_group_info: + result['asn'] = asn_group_info + try: address = ipaddress.ip_address(address_str) except ValueError: @@ -489,6 +505,17 @@ def peer_info(address_str: str) -> Response: ) result['locations'].extend(services_and_locs['locations']) + snmp_info = r.get( + f'snmp-peerings:remote:{address}') + if snmp_info: + snmp_info = json.loads(snmp_info.decode('utf-8')) + result['snmp'] = [ + { + 'hostname': h['hostname'], + 'community': h['community'], + 'oid': h['oid'] + } for h in snmp_info] + result['locations'] = _remove_duplicates_from_list(result['locations']) result = json.dumps(result) # cache this data for the next call @@ -527,6 +554,9 @@ def get_trap_metadata(source_equipment: str, interface: str, circuit_id: str) \ } top_level_services = [] + + # todo - carry on from here + services = r.get( f'ims:interface_services:{source_equipment}:{interface}') if services: