Skip to content
Snippets Groups Projects
Commit a27423a9 authored by Robert Latta's avatar Robert Latta
Browse files

schema compliance; corrected snmp look-up

parent 73687bfc
No related branches found
No related tags found
No related merge requests found
......@@ -371,8 +371,8 @@ def peer_info(address_str: str) -> Response:
# canonicalize the input address first ...
try:
obj = ipaddress.ip_address(address_str)
address_str = obj.exploded
address = ipaddress.ip_address(address_str)
address_str = address.exploded
except ValueError:
raise ClassifierProcessingError(
f'unable to parse {address_str} as an ip address')
......@@ -419,12 +419,6 @@ def peer_info(address_str: str) -> Response:
if asn_group_info:
result['asn'] = asn_group_info
try:
address = ipaddress.ip_address(address_str)
except ValueError:
raise ClassifierProcessingError(
f'unable to parse {address_str} as an ip address')
for interface in find_interfaces(address):
ims_equipment = get_ims_equipment_name(interface["router"])
ims_interface = get_ims_interface(interface["interface name"])
......@@ -435,16 +429,14 @@ def peer_info(address_str: str) -> Response:
r
)
result['interfaces'].append(
{
'interface': interface,
'services': services_and_locs['services']
}
)
t = {'interface': interface}
if services_and_locs.get('services', None):
t['services'] = services_and_locs['services']
result['interfaces'].append(t)
result['locations'].extend(services_and_locs['locations'])
snmp_info = r.get(
f'snmp-peerings:remote:{address}')
f'snmp-peerings:remote:{address_str}')
if snmp_info:
snmp_info = json.loads(snmp_info.decode('utf-8'))
result['snmp'] = [
......@@ -455,6 +447,8 @@ def peer_info(address_str: str) -> Response:
} for h in snmp_info]
result['locations'] = _remove_duplicates_from_list(result['locations'])
if not result.get('interfaces', None):
result.pop('interfaces', None)
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