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

Added other-end info for Infinera; Updated test to check other-end info

parent 01a2d0fd
No related branches found
No related tags found
No related merge requests found
......@@ -165,6 +165,25 @@ def _infinera_field_update(record):
record["interface_name"] += "-" + record["port"]
record["interface_name"] = record["interface_name"] \
.replace("--", "-").upper()
#
equipment_parts = record["other_end_equipment"].rsplit("-", 1)
card_parts = record["other_end_card_id"].split("-", 1)
record["other_end_interface_name"] = ""
record["other_end_equipment"] = equipment_parts[0]
try:
record["other_end_interface_name"] = equipment_parts[1] + "-"
except IndexError:
pass # Nothing to see here
try:
record["other_end_interface_name"] += card_parts[1]
except IndexError:
record["other_end_interface_name"] += card_parts[0]
if record["other_end_port"] is not None and record["other_end_port"] != "":
record["other_end_interface_name"] += "-" + record["other_end_port"]
record["other_end_interface_name"] = record["other_end_interface_name"] \
.replace("--", "-").upper()
return record
......
......@@ -25,28 +25,42 @@ def test_infinera_field_update():
i = {
"equipment": "AMS01-DTNX10-1-1",
"card_id": "tim-b-5-7",
"port": "1"
"port": "1",
"other_end_equipment": "LON01-DTNX10-1-1",
"other_end_card_id": "tim-b-5-8",
"other_end_port": "2"
}
r = inventory_provider.db.opsdb._infinera_field_update(i)
assert r["equipment"] == "AMS01-DTNX10-1"
assert r["interface_name"] == "1-B-5-7-1"
assert r["other_end_equipment"] == "LON01-DTNX10-1"
assert r["other_end_interface_name"] == "1-B-5-8-2"
i = {
"equipment": "BUD01_CX_01",
"card_id": "tim-1/2",
"port": "1"
"port": "1",
"other_end_equipment": "LON01_CX_01",
"other_end_card_id": "tim-2/3",
"other_end_port": "4"
}
r = inventory_provider.db.opsdb._infinera_field_update(i)
assert r["equipment"] == "BUD01_CX_01"
assert r["interface_name"] == "1/2-1"
assert r["other_end_equipment"] == "LON01_CX_01"
assert r["other_end_interface_name"] == "2/3-4"
i = {
"equipment": "irrelevant",
"card_id": "tim_1/2",
"port": "1"
"port": "1",
"other_end_equipment": "irrelevant",
"other_end_card_id": "tim_2/3",
"other_end_port": "4"
}
r = inventory_provider.db.opsdb._infinera_field_update(i)
assert r["interface_name"] == "TIM_1/2-1"
assert r["other_end_interface_name"] == "TIM_2/3-4"
def test_juniper_field_update():
......
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