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): ...@@ -46,30 +46,37 @@ def _infinera_field_update(record):
def _juniper_field_update(record): def _juniper_field_update(record):
if not record["interface_name"]:
record["interface_name"] = record["card_id"] def _separator(ifc_name):
if record["port"] is not None and record["port"] != "": if '-' in ifc_name:
separator = "/" if "-" in record["interface_name"] else "" return '/'
record["interface_name"] += separator + str(record["port"]) if '/' in ifc_name:
if record["logical_unit"] is not None and record["logical_unit"] != "": return '/'
record["interface_name"] += "." + str(record["logical_unit"]) return ''
if not record["other_end_interface_name"]: def _empty(s):
record["other_end_interface_name"] = record["other_end_card_id"] return s is None or s == ''
if record["other_end_port"] is not None \
and record["other_end_port"] != "": for end in ['', 'other_end_']:
separator = "" if not record[end + "interface_name"]:
if "-" in record["other_end_interface_name"]: record[end + "interface_name"] = record[end + "card_id"]
separator = "/" if not _empty(record[end + "port"]):
record["other_end_interface_name"] += \ record[end + "interface_name"] += \
separator + str(record["other_end_port"]) _separator(record[end + "interface_name"]) \
if record["other_end_logical_unit"] is not None \ + str(record[end + "port"])
and record["other_end_logical_unit"] != "": if not _empty(record[end + "logical_unit"]):
record["other_end_interface_name"] += \ record[end + "interface_name"] += \
"." + str(record["other_end_logical_unit"]) "." + str(record[end + "logical_unit"])
return record 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): def _coriant_field_update(record):
record["interface_name"] = record["card_id"] record["interface_name"] = record["card_id"]
if record["port"] is not None and record["port"] != "": 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.
Finish editing this message first!
Please register or to comment