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

added get_node_locations

parent 56b20e7c
No related branches found
No related tags found
No related merge requests found
......@@ -10,37 +10,46 @@ logger = logging.getLogger(__name__)
# Dashboard V3
IMS_OPSDB_STATUS_MAP = {
InventoryStatus.PLANNED: 'Planned',
InventoryStatus.READY_FOR_SERVICE: 'Installed',
InventoryStatus.IN_SERVICE: 'Operational',
InventoryStatus.MIGRATION: 'Planned',
InventoryStatus.OUT_OF_SERVICE: 'Terminated',
InventoryStatus.READY_FOR_CEASURE: 'Disposed'
}
def lookup_pop_info(ds, hostname):
def get_node_locations(ds):
site_nav_props = [
ims.SITE_PROPERTIES['City'],
ims.SITE_PROPERTIES['SiteAliases'],
ims.SITE_PROPERTIES['Country']
ims.SITE_PROPERTIES['Country'],
ims.SITE_PROPERTIES['Nodes']
]
node = ds.get_entity_by_name('Node', hostname)
if not node:
return None
site = ds.get_entity_by_id('Site', node['SiteId'], site_nav_props, True)
city = site['City']
abbreviation = ''
try:
abbreviation = site['SiteAliases'][0]['AliasName']
except IndexError:
pass # no alias - ignore silently
eq = {
'equipment-name': node['Name'],
'status': InventoryStatus(node['InventoryStatusId']).name,
'pop': {
'name': site['Name'],
'city': city['Name'],
'country': city['Country']['Name'],
'abbreviation': abbreviation,
'longitude': site['Longitude'],
'latitude': site['Latitude'],
}
}
return eq
sites = ds.get_all_entities('Site', site_nav_props, step_count=500)
for site in sites:
city = site['city']
abbreviation = ''
try:
abbreviation = site['sitealiases'][0]['aliasname']
except IndexError:
pass # no alias - ignore silently
for node in site['nodes']:
yield (node['name'], {
'equipment-name': node['name'],
'status': IMS_OPSDB_STATUS_MAP.get(
InventoryStatus(node['inventorystatusid']), 'unknown'),
'pop': {
'name': site['name'],
'city': city['name'],
'country': city['country']['name'],
'abbreviation': abbreviation,
'longitude': site['longitude'],
'latitude': site['latitude'],
}
})
# End of Dashboard V3 stuff
......@@ -114,7 +123,7 @@ def lookup_lg_routers(ds):
'latitude': site['latitude'],
}
}
yield(eq)
yield eq
def otrs_get_customer_company_rows(ds):
......
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