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

removed redundant functions

parent 45555c53
No related branches found
No related tags found
No related merge requests found
...@@ -41,25 +41,6 @@ def _remove_duplicates_from_list(all): ...@@ -41,25 +41,6 @@ def _remove_duplicates_from_list(all):
return list(tmp_dict.values()) return list(tmp_dict.values())
def _locations_from_router(router_name, r):
result = r.get(f'ims:location:{router_name}')
if not result:
logger.error(f'error looking up location for {router_name}')
return []
result = json.loads(result.decode('utf-8'))
if not result:
logger.error(f'sanity failure: empty list for location {router_name}')
return []
return [{
'a': _LOCATION(
equipment=result[0]['equipment-name'],
name=result[0]['pop']['name'],
abbreviation=result[0]['pop']['abbreviation'])
}]
# once the switchover is done then will refactor to get rid of # once the switchover is done then will refactor to get rid of
# _locations_from_router # _locations_from_router
def _location_from_equipment(equipment_name, r): def _location_from_equipment(equipment_name, r):
...@@ -88,26 +69,6 @@ def _location_from_services(services, r): ...@@ -88,26 +69,6 @@ def _location_from_services(services, r):
yield build_locations(loc_a, loc_b) yield build_locations(loc_a, loc_b)
# def _location_from_service_dict(s):
# location = {
# 'a': _LOCATION(
# equipment=s['equipment'],
# name=s['pop_name'],
# abbreviation=s['pop_abbreviation'])
# }
#
# if all(s[n] for n in (
# 'other_end_equipment',
# 'other_end_pop_name',
# 'other_end_pop_abbreviation')):
# location['b'] = _LOCATION(
# equipment=s['other_end_equipment'],
# name=s['other_end_pop_name'],
# abbreviation=s['other_end_pop_abbreviation'])
#
# return location
class ClassifierRequestError(Exception): class ClassifierRequestError(Exception):
status_code = 500 status_code = 500
...@@ -399,7 +360,8 @@ def peer_info(address): ...@@ -399,7 +360,8 @@ def peer_info(address):
info = json.loads(info) info = json.loads(info)
result['ix-public-peer-info'] = ix_peering_info(info) result['ix-public-peer-info'] = ix_peering_info(info)
result['locations'].append(build_locations( result['locations'].append(build_locations(
_location_from_equipment(info['router'], r))) _location_from_equipment(
get_ims_equipment_name(info['router']), r)))
info = r.get(f'vpn_rr_peer:{address}') info = r.get(f'vpn_rr_peer:{address}')
if info: if info:
...@@ -407,23 +369,28 @@ def peer_info(address): ...@@ -407,23 +369,28 @@ def peer_info(address):
info = json.loads(info) info = json.loads(info)
result['vpn-rr-peer-info'] = info result['vpn-rr-peer-info'] = info
result['locations'].append(build_locations( result['locations'].append(build_locations(
_location_from_equipment(info['router'], r))) _location_from_equipment(
get_ims_equipment_name(info['router']), r)))
interfaces = list(find_interfaces_and_services(address)) interfaces = list(find_interfaces_and_services(address))
rs_dict = {}
if interfaces: if interfaces:
result['interfaces'] = interfaces result['interfaces'] = interfaces
for i in interfaces: for i in interfaces:
for s in i['services']: for s in i['services']:
# use a dict to get rid of duplicates
for rs in get_related_services(
s['equipment'], s['interface_name'], r):
rs_dict[rs['id']] = rs
result['locations'].append( result['locations'].append(
build_locations( build_locations(
_location_from_equipment(s['router'], r), _location_from_equipment(s['equipment'], r),
_location_from_equipment( _location_from_equipment(
s['other_end_equipment'], r)) s['other_end_equipment'], r))
) )
# result['locations'] += \ result['related-services'] = list(rs_dict.values())
# _location_from_equipment(s['equipment'], r)
# result['locations'] += \
# _location_from_equipment(s['other_end_equipment'], r)
result['locations'] = _remove_duplicates_from_list(result['locations']) result['locations'] = _remove_duplicates_from_list(result['locations'])
result = json.dumps(result) result = json.dumps(result)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment