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

added related services for coriant path

parent 576444b8
No related branches found
No related tags found
No related merge requests found
......@@ -326,6 +326,9 @@ def get_coriant_info(equipment_name, entity_string):
equipment_name, entity_string)
result = r.get(cache_key)
# this is just for development to save deleting the cache every time
# result = False
if result:
result = result.decode('utf-8')
else:
......@@ -353,6 +356,28 @@ def get_coriant_info(equipment_name, entity_string):
if path:
result['path'] = path
def _get_top_level_services(circuit_id):
tls = []
results = r.get(
"opsdb:services:children:{}".format(circuit_id))
if results:
results = json.loads(results.decode('utf-8'))
for c in results:
temp_parents = \
_get_top_level_services(c['parent_circuit_id'])
if not temp_parents and \
c['parent_circuit_type'].lower() == 'service':
tls.append(
{'name': c['parent_circuit'],
'status': c['parent_circuit_status']})
tls.extend(temp_parents)
return tls
top_level_services = _get_top_level_services(path['id'])
if top_level_services:
result['related-services'] = top_level_services
else:
logger.error('no path found for {}:{}'.format(
equipment_name, entity_string))
......
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