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

added handling IP PEERING - NON R&E (PUBLIC)

parent 884a0a97
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ import itertools
import json
import logging
import re
from copy import copy
from functools import lru_cache
from typing import Optional, Iterator, List
......@@ -143,25 +144,34 @@ def get_top_level_services(circuit_id: str, r: Redis) -> List[dict]:
if results:
results = json.loads(results.decode('utf-8'))
def _is_tls(candidate):
tls_names = copy(IMS_SERVICE_NAMES)
# whilst this is a service type the top level for reporting
# are the BGP services on top of it
tls_names.remove('IP PEERING - NON R&E (PUBLIC)')
if candidate['product'] in tls_names:
return True
if candidate['speed'] == 'BGP':
return True
return False
# should only ever be one, may refactor this
for c in results:
if c['product'] in IMS_SERVICE_NAMES:
circuit_type = 'service'
else:
circuit_type = 'circuit'
if c['sub-circuits'] and circuit_type == 'circuit':
for sub in c['sub-circuits']:
temp_parents = \
get_top_level_services(sub, r)
tls.update({t['id']: t for t in temp_parents})
elif circuit_type == 'service':
tls[c['id']] = {
'id': c['id'],
'name': c['name'],
'status': c['status'],
'circuit_type': circuit_type,
'project': c['project']
}
c = results[0]
if _is_tls(c):
tls[c['id']] = {
'id': c['id'],
'name': c['name'],
'status': c['status'],
'circuit_type': 'service',
'project': c['project']
}
elif c['sub-circuits']:
for sub in c['sub-circuits']:
temp_parents = \
get_top_level_services(sub, r)
tls.update({t['id']: t for t in temp_parents})
return list(tls.values())
......
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