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

Added df data retrieval

parent 2f3bc862
No related branches found
No related tags found
No related merge requests found
import logging import logging
import re import re
from collections import OrderedDict from collections import OrderedDict, defaultdict
from inventory_provider import environment from inventory_provider import environment
from inventory_provider.db import ims from inventory_provider.db import ims
...@@ -25,6 +25,55 @@ interface_generators = { ...@@ -25,6 +25,55 @@ interface_generators = {
} }
def get_fibre_info(ds: IMS):
# get all the wdm ots circuits where each node is in a different location
circuit_nav_props = [
ims.CIRCUIT_PROPERTIES['SubCircuits'],
ims.CIRCUIT_PROPERTIES['CalculatedNode'],
ims.CIRCUIT_PROPERTIES['PortA'],
ims.CIRCUIT_PROPERTIES['PortB'],
]
ne_details = {}
for c in ds.get_filtered_entities(
'Circuit',
'product.name == "wdm" | speed.name == "ots" | '
'vendor == "infinera"',
circuit_nav_props,
step_count=1000):
if c["nodeaid"] and c["nodebid"] and \
c["siteaid"] and c["sitebid"] and c["siteaid"] != c["sitebid"]:
if c['subcircuits']:
subs = [s['subcircuit'] for s in c['subcircuits']]
if len(subs) > 1:
# not sure if this is possible in IMS
logger.info('There is more than one Sub-Circuit for'
f'{c["name"]}')
for s in subs:
shelf = c['porta']['shelf']['sequencenumber']
t = {
'ne': c['nodea']['name'] + f'-{shelf}',
'circuit_id': c['id'],
'df_route': s['name'],
'df_route_id': s['id'],
'df_status': IMS_OPSDB_STATUS_MAP.get(
InventoryStatus(s['inventorystatusid']), 'unknown')
}
ne_details[f"{c['nodea']['name']}_{s['id']}"] = t
t = t.copy()
shelf = c['portb']['shelf']['sequencenumber']
t['ne'] = c['nodeb']['name'] + f'-{shelf}'
ne_details[f"{c['nodeb']['name']}_{s['id']}"] = t
by_ne = defaultdict(lambda: [])
for d in ne_details.values():
by_ne[d['ne']].append(d)
yield from by_ne.items()
def get_interface_services(ds: IMS): def get_interface_services(ds: IMS):
# get subset of circuits - # get subset of circuits -
# start with just the ams fra lag, then expand to # start with just the ams fra lag, then expand to
...@@ -141,6 +190,9 @@ def get_circuit_hierarchy(ds: IMS): ...@@ -141,6 +190,9 @@ def get_circuit_hierarchy(ds: IMS):
[c['carriercircuitid'] for c in circuit['carriercircuits']] [c['carriercircuitid'] for c in circuit['carriercircuits']]
yield { yield {
'id': circuit['id'], 'id': circuit['id'],
'name': circuit['name'],
'status': IMS_OPSDB_STATUS_MAP.get(
InventoryStatus(circuit['inventorystatusid']), 'unknown'),
'product': circuit['product']['name'], 'product': circuit['product']['name'],
'project': circuit['customer']['name'], 'project': circuit['customer']['name'],
'sub-circuits': sub_circuits, 'sub-circuits': sub_circuits,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment