Skip to content
Snippets Groups Projects
Commit d78b22c6 authored by Erik Reid's avatar Erik Reid
Browse files

rework classifier metadata response

parent 08dfe34d
No related branches found
No related tags found
No related merge requests found
......@@ -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'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment