Skip to content
Snippets Groups Projects

feature/DBOARD3-771/include all sites in inventory provider /neteng/pops and /neteng/pop/<lookup>

Merged Mohammad Torkashvand requested to merge feature/DBOARD3-771 into develop
Files
8
@@ -67,6 +67,12 @@ NODE_LOCATION_SCHEMA = {
@@ -67,6 +67,12 @@ NODE_LOCATION_SCHEMA = {
}
}
 
SITE_LOCATION_SCHEMA = {
 
'$schema': 'https://json-schema.org/draft-07/schema#',
 
**_POP_LOCATION_SCHEMA_STRUCT
 
}
 
 
def get_flexils_by_circuitid(ds: IMS):
def get_flexils_by_circuitid(ds: IMS):
by_circuit = defaultdict(list)
by_circuit = defaultdict(list)
found_keys = set()
found_keys = set()
@@ -437,6 +443,45 @@ def get_circuit_hierarchy(ds: IMS):
@@ -437,6 +443,45 @@ def get_circuit_hierarchy(ds: IMS):
}
}
 
@log_entry_and_exit
 
def get_site_locations(ds: IMS):
 
"""
 
return location info for all Sites
 
 
yields dictionaries formatted as:
 
 
.. as_json::
 
inventory_provider.db.ims_data.SITE_LOCATION_SCHEMA
 
 
:param ds:
 
:return: yields dicts as above
 
"""
 
site_nav_props = [
 
ims.SITE_PROPERTIES['City'],
 
ims.SITE_PROPERTIES['SiteAliases'],
 
ims.SITE_PROPERTIES['Country'],
 
ims.SITE_PROPERTIES['Nodes']
 
]
 
sites = ds.get_all_entities('Site', site_nav_props, step_count=500)
 
for site in sites:
 
city = site['city']
 
try:
 
abbreviation = site['sitealiases'][0]['aliasname']
 
except IndexError:
 
abbreviation = '' # no alias - ignore silently
 
 
has_geo_data = bool(site.get('longitude') and site.get('latitude'))
 
if abbreviation and has_geo_data:
 
yield site['name'], {
 
'name': site['name'],
 
'city': city['name'],
 
'country': city['country']['name'],
 
'abbreviation': abbreviation,
 
'longitude': site['longitude'],
 
'latitude': site['latitude'],
 
}
 
 
@log_entry_and_exit
@log_entry_and_exit
def get_node_locations(ds: IMS):
def get_node_locations(ds: IMS):
"""
"""
@@ -459,11 +504,11 @@ def get_node_locations(ds: IMS):
@@ -459,11 +504,11 @@ def get_node_locations(ds: IMS):
sites = ds.get_all_entities('Site', site_nav_props, step_count=500)
sites = ds.get_all_entities('Site', site_nav_props, step_count=500)
for site in sites:
for site in sites:
city = site['city']
city = site['city']
abbreviation = ''
try:
try:
abbreviation = site['sitealiases'][0]['aliasname']
abbreviation = site['sitealiases'][0]['aliasname']
except IndexError:
except IndexError:
pass # no alias - ignore silently
abbreviation = '' # no alias - ignore silently
for node in site['nodes']:
for node in site['nodes']:
if node['inventorystatusid'] in STATUSES_TO_IGNORE:
if node['inventorystatusid'] in STATUSES_TO_IGNORE:
Loading