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

generate poller api response based on new backend schema

parent 9522c3da
No related branches found
No related tags found
No related merge requests found
......@@ -88,12 +88,23 @@ def poller_interface_oids(hostname):
@common.require_accepts_json
def service_category_interfaces(category):
result = []
r = common.get_current_redis()
for k in r.scan_iter(f'interface-services:{category.lower()}:*'):
ifc = r.get(k.decode('utf-8'))
result.append(json.loads(ifc.decode('utf-8')))
def _interfaces():
r = common.get_current_redis()
for k in r.scan_iter(f'interface-services:{category.lower()}:*'):
cached_ifc = r.get(k.decode('utf-8')).decode('utf-8')
cached_ifc = json.loads(cached_ifc)
basic_ifc_info = dict()
for k in ['description', 'interface', 'router']:
basic_ifc_info[k] = cached_ifc[k]
if not cached_ifc['users']:
yield basic_ifc_info
else:
for user in cached_ifc['users']:
ifc = {'user': user}
ifc.update(basic_ifc_info)
yield ifc
result = list(_interfaces())
if not result:
return Response(
......
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