diff --git a/inventory_provider/routes/classifier.py b/inventory_provider/routes/classifier.py index 0a9602b8a92c737005567918e1bb9983f09b166b..5f984cec14036cbb2a7ec13d464c3388a6d8bc56 100644 --- a/inventory_provider/routes/classifier.py +++ b/inventory_provider/routes/classifier.py @@ -19,34 +19,25 @@ def get_trap_metadata(source_equipment, interface): if result: result = result.decode('utf-8') else: - # TODO: Change this to a call to the yet-to-be-created one source of - # call relevant information - # This could be different calls dependant on vendor, in which case - # we may need to check the trap type, or it could be a case of a key - # check for each possible data source - interface_info = r.get( + result = {} + + services = r.get( 'opsdb:interface_services:%s:%s' % (source_equipment, interface)) + if services: + result['services'] = json.loads(services.decode('utf=8')) + + ifc_info = r.get( + 'netconf-interfaces:%s:%s' % (source_equipment, interface)) + if ifc_info: + result['interface'] = json.loads(ifc_info.decode('utf-8')) - if not interface_info: + if not result: return Response( response="no available info for {} {}".format( source_equipment, interface), status=404, mimetype="text/html") - interface_info = json.loads(interface_info.decode('utf-8')) - - # TODO: refactor once structure of new source is decided, - # currently this is just a list of services - vendor = interface_info[0]['manufacturer'] - hostname = interface_info[0]['equipment'] - # TODO: don't copy unecessary data into response (let client do this) - result = { - "vendor": vendor, - "equipment-name": hostname, - "interface-name": interface, - "services": interface_info - } result = json.dumps(result) # cache this data for the next call r.set(cache_key, result.encode('utf-8'))