Skip to content
Snippets Groups Projects
Commit 5f6087f6 authored by Sam Roberts's avatar Sam Roberts
Browse files

fetch all required redis docs in one call (slow but functional)

parent 78ccaa1c
No related branches found
No related tags found
2 merge requests!22Feature/pol1 744 fix speed issues,!21Draft: Feature/pol1 744 fix speed issues
......@@ -701,13 +701,17 @@ def _load_interfaces(
def _add_speeds(config, interfaces):
all_netconf_interfaces = list(common.load_json_docs(config, 'classifier-cache:netconf-interfaces:all'))
netconf_interface_index = {f"{ifc['router']}---{ifc['name']}": ifc for ifc in all_netconf_interfaces[0]['value']}
all_netconf_interfaces = list(common.load_json_docs(config, 'netconf-interfaces:*'))
netconf_interface_index = {}
for netconf_interface_doc in all_netconf_interfaces:
nc_ifc = netconf_interface_doc['value']
if 'router' in nc_ifc and 'name' in nc_ifc:
netconf_interface_index[f"{nc_ifc['router']}---{nc_ifc['name']}"] = nc_ifc
for ifc in interfaces:
netconf_interface = netconf_interface_index.get(f"{ifc['router']}---{ifc['name']}", {})
if 'speed' in netconf_interface:
ifc['speed'] = netconf_interface['speed']
nc_ifc = netconf_interface_index.get(f"{ifc['router']}---{ifc['name']}", {})
if 'speed' in nc_ifc:
ifc['speed'] = nc_ifc['speed']
else:
ifc['speed'] = ''
yield ifc
......
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