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

added flexILS data retrieval

parent 11cf7d29
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,16 @@ NODE_LOCATION_SCHEMA = {
}
def get_flex_ils_entities(ds: IMS):
for f in ds.get_all_entities('FLEXILS_SCHF_SUBINTERFACES'):
yield {
'circuit_id': f['circuitid'],
'node_name': f['nodename'],
'port_name': f['port'],
'full_port_name': f['port_ref']
}
def get_non_monitored_circuit_ids(ds: IMS):
# note the id for the relevant field is hard-coded. I didn't want to use
# the name of the field as this can be changed by users
......
......@@ -8,7 +8,8 @@ from inventory_provider.db.ims import InventoryStatus
from inventory_provider.db.ims_data import lookup_lg_routers, \
get_node_locations, IMS_OPSDB_STATUS_MAP, \
get_port_id_services, get_port_details, \
get_circuit_hierarchy, get_ids_and_sids, NODE_LOCATION_SCHEMA
get_circuit_hierarchy, get_ids_and_sids, NODE_LOCATION_SCHEMA, \
get_flex_ils_entities
def _json_test_data(filename):
......@@ -385,3 +386,63 @@ def test_get_circuit_ids_and_sids(mocker):
'dummy_base', 'dummy_username', 'dummy_password')
res = list(get_ids_and_sids(ds))
assert res == expected_response
def test_get_flex_ils_entities(mocker):
ims = mocker.patch('inventory_provider.db.ims.IMS')
ims.return_value.get_all_entities.return_value = \
[
{
"$id": "1630",
"circuitid": 702203,
"circuitname": "GEANT LAB-GEANT LAB-OCH-003",
"id": 1,
"nodename": "CAM01-MTC6-3",
"node_id": 130498,
"port": "A-1-S1",
"port_ref": "1-A-1-S1-1",
"shelfname": "1-MTC-6",
"rowVersion": "0001-01-01T00:00:00",
"circuit": None,
"node_": None,
"errors": None,
"haserrors": False,
"customproperties": {}
},
{
"$id": "1631",
"circuitid": 702203,
"circuitname": "GEANT LAB-GEANT LAB-OCH-003",
"id": 2,
"nodename": "CAM01-MTC6-3",
"node_id": 130498,
"port": "A-1-L1",
"port_ref": "1-A-1-L1-1",
"shelfname": "1-MTC-6",
"rowversion": "0001-01-01T00:00:00",
"circuit": None,
"node_": None,
"errors": None,
"haserrors": False,
"customproperties": {}
}
]
expected_result = [
{
'circuit_id': 702203,
'node_name': 'CAM01-MTC6-3',
'port_name': 'A-1-S1',
'full_port_name': '1-A-1-S1-1'
},
{
'circuit_id': 702203,
'node_name': 'CAM01-MTC6-3',
'port_name': 'A-1-L1',
'full_port_name': '1-A-1-L1-1'
}
]
ds = inventory_provider.db.ims.IMS(
'dummy_base', 'dummy_username', 'dummy_password')
res = list(get_flex_ils_entities(ds))
assert res == expected_result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment