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

updated interfaces to services

parent 771438b1
No related branches found
No related tags found
No related merge requests found
......@@ -20,11 +20,16 @@ IMS_OPSDB_STATUS_MAP = {
InventoryStatus.READY_FOR_CEASURE: 'Disposed'
}
interface_generators = {
'infinera': lambda x: f"{x['shelf']['sequencenumber']}-{x['name']}"
}
def get_interface_services(ds: IMS):
# get subset of circuits -
# start with just the ams fra lag, then expand to
# include the relevant carrier circuits
# service types come from the 'product' information
service_types = {
'geant lambda',
'geant plus',
......@@ -34,35 +39,63 @@ def get_interface_services(ds: IMS):
'ip peering - non r&e (private)',
'ip peering - r&e',
'ip trunk',
'ip access',
'geant cloud peering',
'geant open port',
'geant open cross connect',
'pop lan link',
'SERVER LINK'
'SERVER LINK',
'GEANT - GBS',
}
speeds = {
'L3VPN',
'LAG',
'FIBRE_ROUTE'
}
circuit_nav_props = [
ims.CIRCUIT_PROPERTIES['Speed'],
ims.CIRCUIT_PROPERTIES['Product'],
ims.CIRCUIT_PROPERTIES['Ports'],
ims.CIRCUIT_PROPERTIES['InternalPorts'],
ims.CIRCUIT_PROPERTIES['PortsFullDetails'],
ims.CIRCUIT_PROPERTIES['InternalPortsFullDetails'],
]
circuits = ds.get_filtered_entities(
'Circuit', 'name like amsterdam', circuit_nav_props, step_count=1000)
def _populate_end_info(_circuit, _port_info):
def _get_circuits():
for st in service_types:
yield from ds.get_filtered_entities(
'Circuit',
f'product.name == "{st}"',
circuit_nav_props,
step_count=1000)
for spd in speeds:
yield from ds.get_filtered_entities(
'Circuit',
f'speed.name == "{spd}"',
circuit_nav_props,
step_count=1000)
circuits = _get_circuits()
def _populate_end_info(_circuit, _port_info, vendor):
port_count = len(_port_info)
if _port_info:
port = _port_info[0]
_circuit['equipment'] = port['node']['name']
_circuit['interface_name'] = port['name']
_circuit['interface_name'] = interface_generators.get(
vendor.lower(), lambda x: x['name'])(port)
_circuit['other_end_equipment'] = ''
_circuit['other_end_interface_name'] = ''
if port_count > 1:
port = _port_info[1]
_circuit['other_end_equipment'] = port['node']['name']
_circuit['other_end_interface_name'] = port['name']
_circuit['other_end_interface_name'] = \
interface_generators.get(
vendor.lower(),
lambda x: x['name'])(port)
_circuit['other_end_location'] = port['site']['name']
if port_count > 2:
logger.error(
'More that two (internal)ports found for'
f' {_circuit["name"]} ({_circuit["id"]}')
f' {_circuit["name"]} ({_circuit["id"]})')
yield _circuit
if port_count > 1:
_circuit['equipment'], _circuit['other_end_equipment'] = \
......@@ -84,8 +117,9 @@ def get_interface_services(ds: IMS):
'service_type': circuit['product']['name'],
'project': circuit['product']['name']
}
yield from _populate_end_info(cd, circuit['ports'])
yield from _populate_end_info(cd, circuit['internalports'])
yield from _populate_end_info(cd, circuit['ports'], circuit['vendor'])
yield from _populate_end_info(
cd, circuit['internalports'], circuit['vendor'])
def get_circuit_hierarchy(ds: IMS):
......
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