Skip to content
Snippets Groups Projects
Commit 33a48e34 authored by Release Webservice's avatar Release Webservice
Browse files

Finished release 0.22.

parents dd3065b3 2cfc844b
No related branches found
Tags 0.22
No related merge requests found
......@@ -36,3 +36,4 @@
added top-level services to responses
0.20: included both v4 & v6 addresses in peering info
0.21: added parsing of 'logical-systems' (DBOARD3-150)
0.22: return a skeleton response for unknown interfaces (DBOARD3-169)
......@@ -132,7 +132,8 @@ retrieve_services_query = """SELECT *
WHERE
equipment IS NOT NULL
AND equipment != ''
AND circuit_type IN ('path', 'service', 'l2circuit')
AND circuit_type IN (
'path', 'service', 'l2circuit', 'link-aggr-group')
ORDER BY
name,
FIELD(status,
......@@ -165,6 +166,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
......@@ -176,6 +196,20 @@ def _juniper_field_update(record):
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"])
return record
......
......@@ -209,6 +209,8 @@ def list_interfaces(netconf_config):
"""
def _ifc_info(e):
# warning: this structure should match the default
# returned from routes.classifier.juniper_link_info
name = e.find('name')
assert name is not None, "expected interface 'name' child element"
ifc = {
......
......@@ -107,6 +107,16 @@ def get_juniper_link_info(source_equipment, interface):
'netconf-interfaces:%s:%s' % (source_equipment, interface))
if ifc_info:
result['interface'] = json.loads(ifc_info.decode('utf-8'))
else:
# warning: this should match the structure returned by
# juniper:list_interfaces:_ifc_info
result['interface'] = {
'name': interface,
'description': '',
'bundle': [],
'ipv4': [],
'ipv6': []
}
def _related_services():
for related in related_interfaces(source_equipment, interface):
......@@ -123,12 +133,14 @@ def get_juniper_link_info(source_equipment, interface):
related_services.extend(top_level_services)
result['related-services'] = related_services
if not result:
return Response(
response="no available info for {} {}".format(
source_equipment, interface),
status=404,
mimetype="text/html")
# no longer possible, now that at least 'interface' is
# returned for unknown interfaces
# if not result:
# return Response(
# response="no available info for {} {}".format(
# source_equipment, interface),
# status=404,
# mimetype="text/html")
result = json.dumps(result)
# cache this data for the next call
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='inventory-provider',
version="0.21",
version="0.22",
author='GEANT',
author_email='swd@geant.org',
description='Dashboard inventory provider',
......
......@@ -25,80 +25,124 @@ 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():
i = {
"interface_name": "xe-1/2",
"logical_unit": None
"logical_unit": None,
"other_end_interface_name": "xe-3/2",
"other_end_logical_unit": None
}
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-1/2"
assert r["other_end_interface_name"] == "xe-3/2"
i["interface_name"] = "xe-1/2"
i["logical_unit"] = 101
i["other_end_interface_name"] = "xe-3/2"
i["other_end_logical_unit"] = 301
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-1/2.101"
assert r["other_end_interface_name"] == "xe-3/2.301"
i["interface_name"] = "xe-1/2"
i["logical_unit"] = 0
i["other_end_interface_name"] = "xe-3/2"
i["other_end_logical_unit"] = 0
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-1/2.0"
assert r["other_end_interface_name"] == "xe-3/2.0"
i["interface_name"] = "xe-1/2"
i["logical_unit"] = None
i["port"] = 0
i["other_end_interface_name"] = "xe-3/2"
i["other_end_logical_unit"] = None
i["other_end_port"] = 0
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-1/2"
assert r["other_end_interface_name"] == "xe-3/2"
i["interface_name"] = None
i["card_id"] = "xe-2/0"
i["logical_unit"] = None
i["port"] = None
i["other_end_interface_name"] = None
i["other_end_card_id"] = "xe-3/0"
i["other_end_logical_unit"] = None
i["other_end_port"] = None
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-2/0"
assert r["other_end_interface_name"] == "xe-3/0"
i["interface_name"] = None
i["port"] = "0"
i["other_end_interface_name"] = None
i["other_end_port"] = "0"
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-2/0/0"
assert r["other_end_interface_name"] == "xe-3/0/0"
i["interface_name"] = None
i["port"] = 0
i["other_end_interface_name"] = None
i["other_end_port"] = 0
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-2/0/0"
assert r["other_end_interface_name"] == "xe-3/0/0"
i["interface_name"] = None
i["logical_unit"] = "123"
i["other_end_interface_name"] = None
i["other_end_logical_unit"] = "323"
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-2/0/0.123"
assert r["other_end_interface_name"] == "xe-3/0/0.323"
i["interface_name"] = None
i["logical_unit"] = 123
i["other_end_interface_name"] = None
i["other_end_logical_unit"] = 323
r = inventory_provider.db.opsdb._juniper_field_update(i)
assert r["interface_name"] == "xe-2/0/0.123"
assert r["other_end_interface_name"] == "xe-3/0/0.323"
def test_coriant_update_fields():
......
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