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

updated to work with lowercase keys from IMS data

parent 8795be0f
Branches
Tags
No related merge requests found
......@@ -59,13 +59,13 @@ def lookup_lg_routers(ds):
pattern = re.compile("vpn-proxy|vrr|taas", re.IGNORECASE)
def _matching_node(node_):
if InventoryStatus(node_['InventoryStatusId']) not in [
if InventoryStatus(node_['inventorystatusid']) not in [
InventoryStatus.IN_SERVICE,
InventoryStatus.PLANNED # remove once data fully migrated
]:
return False
if pattern.match(node_['Name']):
if pattern.match(node_['name']):
return False
return True
......@@ -82,36 +82,36 @@ def lookup_lg_routers(ds):
ims.EQUIP_DEF_PROPERTIES['Nodes'])
for eq_def in eq_definitions:
nodes = eq_def['Nodes']
nodes = eq_def['nodes']
for node in nodes:
if not _matching_node(node):
continue
site = ds.get_entity_by_id('Site', node['SiteId'], site_nav_props,
site = ds.get_entity_by_id('Site', node['siteid'], site_nav_props,
True)
city = site['City']
city = site['city']
abbreviation = ''
try:
abbreviation = site['SiteAliases'][0]['AliasName']
abbreviation = site['sitealiases'][0]['aliasname']
except IndexError:
pass # no alias - ignore silently
eq = {
'equipment name': node['Name'],
'equipment name': node['name'],
'type':
'INTERNAL'
if site['Name'] in INTERNAL_POP_NAMES
if site['name'] in INTERNAL_POP_NAMES
else 'CORE',
'pop': {
'name': site['Name'],
'city': city['Name'],
'country': city['Country']['Name'],
'country code': city['Country']['Abbreviation'],
'name': site['name'],
'city': city['name'],
'country': city['country']['name'],
'country code': city['country']['abbreviation'],
'abbreviation': abbreviation,
'longitude': site['Longitude'],
'latitude': site['Latitude'],
'longitude': site['longitude'],
'latitude': site['latitude'],
}
}
yield(eq)
......
This diff is collapsed.
......@@ -13,19 +13,19 @@ def test_lookup_lg_routers(mocker):
with open('test/data/ims_lg_data.json') as data:
ims.return_value.get_filtered_entities.return_value = json.load(data)
ims.return_value.get_entity_by_id.return_value = {
'Name': 'pop name',
'Longitude': 'long',
'Latitude': 'lat',
'City': {
'Name': 'city name',
'Country': {
'Name': 'country name',
'Abbreviation': 'country code'
'name': 'pop name',
'longitude': 'long',
'latitude': 'lat',
'city': {
'name': 'city name',
'country': {
'name': 'country name',
'abbreviation': 'country code'
}
},
'SiteAliases': [
'sitealiases': [
{
'AliasName': 'abbr'
'aliasname': 'abbr'
}
]
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment