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

moved get_top_level_services into standalone function

parent 8c914c25
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,24 @@ def related_interfaces(hostname, interface):
yield k[len(prefix):]
def get_top_level_services(circuit_id, r):
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'], r)
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
@routes.route("/juniper-link-info/<source_equipment>/<path:interface>",
methods=['GET', 'POST'])
@common.require_accepts_json
......@@ -369,25 +387,7 @@ 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'])
top_level_services = get_top_level_services(path['id'], r)
if top_level_services:
result['related-services'] = top_level_services
else:
......
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