Skip to content
Snippets Groups Projects
Commit 79121260 authored by Erik Reid's avatar Erik Reid
Browse files

reformat interface names for cisco devices

parent 25558284
No related branches found
No related tags found
No related merge requests found
......@@ -46,30 +46,37 @@ def _infinera_field_update(record):
def _juniper_field_update(record):
if not record["interface_name"]:
record["interface_name"] = record["card_id"]
if record["port"] is not None and record["port"] != "":
separator = "/" if "-" in record["interface_name"] else ""
record["interface_name"] += separator + str(record["port"])
if record["logical_unit"] is not None and record["logical_unit"] != "":
record["interface_name"] += "." + str(record["logical_unit"])
if not record["other_end_interface_name"]:
record["other_end_interface_name"] = record["other_end_card_id"]
if record["other_end_port"] is not None \
and record["other_end_port"] != "":
separator = ""
if "-" in record["other_end_interface_name"]:
separator = "/"
record["other_end_interface_name"] += \
separator + str(record["other_end_port"])
if record["other_end_logical_unit"] is not None \
and record["other_end_logical_unit"] != "":
record["other_end_interface_name"] += \
"." + str(record["other_end_logical_unit"])
def _separator(ifc_name):
if '-' in ifc_name:
return '/'
if '/' in ifc_name:
return '/'
return ''
def _empty(s):
return s is None or s == ''
for end in ['', 'other_end_']:
if not record[end + "interface_name"]:
record[end + "interface_name"] = record[end + "card_id"]
if not _empty(record[end + "port"]):
record[end + "interface_name"] += \
_separator(record[end + "interface_name"]) \
+ str(record[end + "port"])
if not _empty(record[end + "logical_unit"]):
record[end + "interface_name"] += \
"." + str(record[end + "logical_unit"])
return record
def _cisco_field_update(record):
if record['name'].startswith('EUMET-JEUNO'):
print('here')
return _juniper_field_update(record)
def _coriant_field_update(record):
record["interface_name"] = record["card_id"]
if record["port"] is not None and record["port"] != "":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment