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

ensure location dict is a common structure

parent 1eded5c7
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,14 @@ routes = Blueprint("inventory-data-classifier-support-routes", __name__)
logger = logging.getLogger(__name__)
def _LOCATION(equipment, name, abbreviation):
return {
'equipment': equipment,
'name': name,
'abbreviation': abbreviation
}
def _unique_dicts_from_list(l):
tmp_dict = dict([(json.dumps(item, sort_keys=True), item) for item in l])
return list(tmp_dict.values())
......@@ -31,32 +39,29 @@ def _location_from_router(router_name):
return None
return {
'a': {
'equipment': result[0]['equipment-name'],
'name': result[0]['pop']['name'],
'abbreviation': result[0]['pop']['abbreviation']
}
'a': _LOCATION(
equipment=result[0]['equipment-name'],
name=result[0]['pop']['name'],
abbreviation=result[0]['pop']['abbreviation'])
}
def _location_from_service_dict(s):
location = {
'a': {
'equipment': s['equipment'],
'name': s['pop_name'],
'abbreviation': s['pop_abbreviation']
}
'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'] = {
'equipment': s['other_end_equipment'],
'name': s['other_end_pop_name'],
'abbreviation': s['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
......@@ -441,16 +446,14 @@ def get_coriant_info(equipment_name, entity_string):
if path:
result['path'] = path
result['locations'] += [{
'a': {
'equipment': path['a']['equipment name'],
'name': path['a']['pop']['name'],
'abbreviation': path['a']['pop']['abbreviation']
},
'b': {
'equipment': path['b']['equipment name'],
'name': path['b']['pop']['name'],
'abbreviation': path['b']['pop']['abbreviation']
}
'a': _LOCATION(
equipment=path['a']['equipment name'],
name=path['a']['pop']['name'],
abbreviation=path['a']['pop']['abbreviation']),
'b': _LOCATION(
equipment=path['b']['equipment name'],
name=path['b']['pop']['name'],
abbreviation=path['b']['pop']['abbreviation']),
}]
top_level_services = get_top_level_services(path['id'], r)
......
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