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

always return a skeleton structure for any interface name

parent ac824d4a
No related branches found
No related tags found
No related merge requests found
......@@ -209,6 +209,8 @@ def list_interfaces(netconf_config):
"""
def _ifc_info(e):
# warning: this structure should match the default
# returned from routes.classifier.juniper_link_info
name = e.find('name')
assert name is not None, "expected interface 'name' child element"
ifc = {
......
......@@ -107,6 +107,16 @@ def get_juniper_link_info(source_equipment, interface):
'netconf-interfaces:%s:%s' % (source_equipment, interface))
if ifc_info:
result['interface'] = json.loads(ifc_info.decode('utf-8'))
else:
# warning: this should match the structure returned by
# juniper:list_interfaces:_ifc_info
result['interface'] = {
'name': interface,
'description': '',
'bundle': [],
'ipv4': [],
'ipv6': []
}
def _related_services():
for related in related_interfaces(source_equipment, interface):
......@@ -123,12 +133,14 @@ def get_juniper_link_info(source_equipment, interface):
related_services.extend(top_level_services)
result['related-services'] = related_services
if not result:
return Response(
response="no available info for {} {}".format(
source_equipment, interface),
status=404,
mimetype="text/html")
# no longer possible, now that at least 'interface' is
# returned for unknown interfaces
# if not result:
# return Response(
# response="no available info for {} {}".format(
# source_equipment, interface),
# status=404,
# mimetype="text/html")
result = json.dumps(result)
# cache this data for the next call
......
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