diff --git a/src/common/tests/MockServicerImpl_Context.py b/src/common/tests/MockServicerImpl_Context.py index 3f4af19eced89843552737ae6f8b773d3fa26a58..667c9ed658cfbe648e345d691523375e1c5f8b79 100644 --- a/src/common/tests/MockServicerImpl_Context.py +++ b/src/common/tests/MockServicerImpl_Context.py @@ -14,6 +14,7 @@ import grpc, json, logging from typing import Any, Dict, Iterator, List, Set +from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.proto.context_pb2 import ( Connection, ConnectionEvent, ConnectionId, ConnectionIdList, ConnectionList, Context, ContextEvent, ContextId, ContextIdList, ContextList, @@ -22,7 +23,7 @@ from common.proto.context_pb2 import ( Link, LinkEvent, LinkId, LinkIdList, LinkList, Service, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, - Topology, TopologyEvent, TopologyId, TopologyIdList, TopologyList) + Topology, TopologyDetails, TopologyEvent, TopologyId, TopologyIdList, TopologyList) from common.proto.context_pb2_grpc import ContextServiceServicer from common.tests.MockMessageBroker import ( TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_DEVICE, TOPIC_LINK, TOPIC_SERVICE, TOPIC_SLICE, TOPIC_TOPOLOGY, @@ -162,6 +163,29 @@ class MockServicerImpl_Context(ContextServiceServicer): LOGGER.info('[GetTopology] reply={:s}'.format(grpc_message_to_json_string(reply))) return reply + def GetTopologyDetails(self, request : TopologyId, context : grpc.ServicerContext) -> TopologyDetails: + LOGGER.info('[GetTopologyDetails] request={:s}'.format(grpc_message_to_json_string(request))) + context_uuid = request.context_id.context_uuid.uuid + container_name = 'topology[{:s}]'.format(str(context_uuid)) + topology_uuid = request.topology_uuid.uuid + _reply = get_entry(context, self.database, container_name, topology_uuid) + reply = TopologyDetails() + reply.topology_id.CopyFrom(_reply.topology_id) + reply.name = _reply.name + if context_uuid == DEFAULT_CONTEXT_NAME and topology_uuid == DEFAULT_TOPOLOGY_NAME: + for device in get_entries(self.database, 'device'): reply.devices.append(device) + for link in get_entries(self.database, 'link'): reply.links.append(link) + else: + # TODO: to be improved; Mock does not associate devices/links to topologies automatically + for device_id in _reply.device_ids: + device = get_entry(context, self.database, 'device', device_id.device_uuid.uuid) + reply.devices.append(device) + for link_id in _reply.link_ids: + link = get_entry(context, self.database, 'link', link_id.link_uuid.uuid) + reply.links.append(link) + LOGGER.info('[GetTopologyDetails] reply={:s}'.format(grpc_message_to_json_string(reply))) + return reply + def SetTopology(self, request: Topology, context : grpc.ServicerContext) -> TopologyId: LOGGER.info('[SetTopology] request={:s}'.format(grpc_message_to_json_string(request))) container_name = 'topology[{:s}]'.format(str(request.topology_id.context_id.context_uuid.uuid)) diff --git a/src/common/tools/object_factory/Device.py b/src/common/tools/object_factory/Device.py index 032aa4fb2781c175eb6f4421055143937750f398..bc5c28740d5635df99c26ef56124c471d2c77d91 100644 --- a/src/common/tools/object_factory/Device.py +++ b/src/common/tools/object_factory/Device.py @@ -136,7 +136,7 @@ def json_device_tfs_disabled( device_uuid, DEVICE_TFS_TYPE, DEVICE_DISABLED, name=name, endpoints=endpoints, config_rules=config_rules, drivers=drivers) -def json_device_connect_rules(address : str, port : int, settings : Dict = {}): +def json_device_connect_rules(address : str, port : int, settings : Dict = {}) -> List[Dict]: return [ json_config_rule_set('_connect/address', address), json_config_rule_set('_connect/port', port), @@ -144,12 +144,7 @@ def json_device_connect_rules(address : str, port : int, settings : Dict = {}): ] def json_device_emulated_connect_rules( - endpoint_descriptors : List[Tuple[str, str, List[int]]], address : str = DEVICE_EMU_ADDRESS, - port : int = DEVICE_EMU_PORT - ): - - settings = {'endpoints': [ - {'uuid': endpoint_uuid, 'type': endpoint_type, 'sample_types': sample_types} - for endpoint_uuid,endpoint_type,sample_types in endpoint_descriptors - ]} + endpoint_descriptors : List[Dict], address : str = DEVICE_EMU_ADDRESS, port : int = DEVICE_EMU_PORT +) -> List[Dict]: + settings = {'endpoints': endpoint_descriptors} return json_device_connect_rules(address, port, settings=settings) diff --git a/src/common/tools/object_factory/EndPoint.py b/src/common/tools/object_factory/EndPoint.py index a38ad0d5c59ee75742459729003d43ef01612f53..a776dfebb42cea5b51bf0a2566038859ffc02fa5 100644 --- a/src/common/tools/object_factory/EndPoint.py +++ b/src/common/tools/object_factory/EndPoint.py @@ -13,7 +13,20 @@ # limitations under the License. import copy -from typing import Dict, List, Optional, Tuple +from typing import Dict, List, Optional + +def json_endpoint_descriptor( + endpoint_uuid : str, endpoint_type : str, endpoint_name : Optional[str] = None, + sample_types : List[int] = [], location : Optional[Dict] = None +) -> Dict: + result = {'uuid': endpoint_uuid, 'type': endpoint_type} + if endpoint_name is not None: + result['name'] = endpoint_name + if sample_types is not None and len(sample_types) > 0: + result['sample_types'] = sample_types + if location is not None and len(location) > 0: + result['location'] = location + return result def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Optional[Dict] = None): result = {'device_id': copy.deepcopy(device_id), 'endpoint_uuid': {'uuid': endpoint_uuid}} @@ -21,11 +34,11 @@ def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Option return result def json_endpoint_ids( - device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]], topology_id : Optional[Dict] = None + device_id : Dict, endpoint_descriptors : List[Dict], topology_id : Optional[Dict] = None ): return [ - json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id) - for endpoint_uuid, _, _ in endpoint_descriptors + json_endpoint_id(device_id, endpoint_data['uuid'], topology_id=topology_id) + for endpoint_data in endpoint_descriptors ] def json_endpoint( @@ -37,16 +50,18 @@ def json_endpoint( 'endpoint_id': json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id), 'endpoint_type': endpoint_type, } - if len(kpi_sample_types) > 0: result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types) - if location: result['endpoint_location'] = copy.deepcopy(location) + if kpi_sample_types is not None and len(kpi_sample_types) > 0: + result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types) + if location is not None: + result['endpoint_location'] = copy.deepcopy(location) return result def json_endpoints( - device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]], topology_id : Optional[Dict] = None + device_id : Dict, endpoint_descriptors : List[Dict], topology_id : Optional[Dict] = None ): return [ json_endpoint( - device_id, endpoint_uuid, endpoint_type, topology_id=topology_id, - kpi_sample_types=endpoint_sample_types) - for endpoint_uuid, endpoint_type, endpoint_sample_types in endpoint_descriptors + device_id, endpoint_data['uuid'], endpoint_data['type'], topology_id=topology_id, + kpi_sample_types=endpoint_data.get('sample_types'), location=endpoint_data.get('location')) + for endpoint_data in endpoint_descriptors ] diff --git a/src/device/tests/Device_Emulated.py b/src/device/tests/Device_Emulated.py index bb5dfa5f39e2e3ec3c07f9f49dc55e03c8e3c88d..0dffd7ad5a1d6da3bb58ca1c874a797c34ca5357 100644 --- a/src/device/tests/Device_Emulated.py +++ b/src/device/tests/Device_Emulated.py @@ -16,13 +16,17 @@ from common.proto.kpi_sample_types_pb2 import KpiSampleType from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_id) +from common.tools.object_factory.EndPoint import json_endpoint_descriptor from device.tests.CommonObjects import PACKET_PORT_SAMPLE_TYPES DEVICE_EMU_UUID = 'R1-EMU' DEVICE_EMU_ID = json_device_id(DEVICE_EMU_UUID) DEVICE_EMU = json_device_emulated_packet_router_disabled(DEVICE_EMU_UUID) DEVICE_EMU_EP_UUIDS = ['EP1', 'EP2', 'EP3', 'EP4'] -DEVICE_EMU_EP_DESCS = [(ep_uuid, '10Gbps', PACKET_PORT_SAMPLE_TYPES) for ep_uuid in DEVICE_EMU_EP_UUIDS] +DEVICE_EMU_EP_DESCS = [ + json_endpoint_descriptor(ep_uuid, '10Gbps', sample_types=PACKET_PORT_SAMPLE_TYPES) + for ep_uuid in DEVICE_EMU_EP_UUIDS +] DEVICE_EMU_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_EMU_EP_DESCS) RSRC_EP = '/endpoints/endpoint[{:s}]' @@ -30,7 +34,10 @@ RSRC_SUBIF = RSRC_EP + '/subinterfaces/subinterface[{:d}]' RSRC_ADDRIPV4 = RSRC_SUBIF + '/ipv4/address[{:s}]' DEVICE_EMU_ENDPOINTS_COOKED = [] -for endpoint_uuid,endpoint_type,endpoint_sample_types in DEVICE_EMU_EP_DESCS: +for endpoint_data in DEVICE_EMU_EP_DESCS: + endpoint_uuid = endpoint_data['uuid'] + endpoint_type = endpoint_data['type'] + endpoint_sample_types = endpoint_data['sample_types'] endpoint_resource_key = RSRC_EP.format(str(endpoint_uuid)) sample_types = {} for endpoint_sample_type in endpoint_sample_types: diff --git a/src/dlt/connector/tests/Objects.py b/src/dlt/connector/tests/Objects.py index 2ff850000a2d20b0556dc6e65a21b7151db849d6..5a7f9f68235eefa93e73d66bb6a2ab3ae210ee14 100644 --- a/src/dlt/connector/tests/Objects.py +++ b/src/dlt/connector/tests/Objects.py @@ -14,7 +14,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import json_device_emulated_packet_router_disabled, json_device_id -from common.tools.object_factory.EndPoint import json_endpoints +from common.tools.object_factory.EndPoint import json_endpoint_descriptor, json_endpoints from common.tools.object_factory.Link import compose_link from common.tools.object_factory.Topology import json_topology, json_topology_id @@ -22,7 +22,10 @@ def compose_device( device_uuid, endpoint_uuids, endpoint_type='copper', endpoint_topology_id=None, endpoint_sample_types=[] ): device_id = json_device_id(device_uuid) - endpoints = [(endpoint_uuid, endpoint_type, endpoint_sample_types) for endpoint_uuid in endpoint_uuids] + endpoints = [ + json_endpoint_descriptor(endpoint_uuid, endpoint_type, endpoint_sample_types) + for endpoint_uuid in endpoint_uuids + ] endpoints = json_endpoints(device_id, endpoints, topology_id=endpoint_topology_id) device = json_device_emulated_packet_router_disabled(device_uuid, endpoints=endpoints) return device_id, endpoints, device diff --git a/src/monitoring/tests/Objects.py b/src/monitoring/tests/Objects.py index 447ed0d601bd7079e55dc30e5cab66d25eb1fd88..c5228981bd0c0a5c9104c286f7daa8fb38baf47b 100644 --- a/src/monitoring/tests/Objects.py +++ b/src/monitoring/tests/Objects.py @@ -15,6 +15,7 @@ from common.proto.kpi_sample_types_pb2 import KpiSampleType from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled) +from common.tools.object_factory.EndPoint import json_endpoint_descriptor PACKET_PORT_SAMPLE_TYPES = [ KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED, @@ -25,6 +26,8 @@ PACKET_PORT_SAMPLE_TYPES = [ DEVICE_DEV1_UUID = 'DEV1' ENDPOINT_END1_UUID = 'END1' -DEVICE_DEV1_ENDPOINT_DEFS = [(ENDPOINT_END1_UUID, 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_DEV1_ENDPOINT_DEFS = [ + json_endpoint_descriptor(ENDPOINT_END1_UUID, 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES) +] DEVICE_DEV1 = json_device_emulated_packet_router_disabled(DEVICE_DEV1_UUID) DEVICE_DEV1_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_DEV1_ENDPOINT_DEFS) diff --git a/src/pathcomp/frontend/service/algorithms/tools/EroPathToHops.py b/src/pathcomp/frontend/service/algorithms/tools/EroPathToHops.py index eb9e862753d3834f7dd7b7c6529d7d9ae5e38f1f..c3e1a0d5738bc2fe4706c336b587ece97746da85 100644 --- a/src/pathcomp/frontend/service/algorithms/tools/EroPathToHops.py +++ b/src/pathcomp/frontend/service/algorithms/tools/EroPathToHops.py @@ -116,12 +116,10 @@ def eropath_to_hops( if link_tuple is None: raise Exception('Malformed path') ingress = next(iter([ - ep_id for ep_id in link_tuple[0]['link_endpoint_ids'] - if (ep_id['endpoint_id']['device_id'] == device_uuid) and\ - (ep_id['endpoint_id']['endpoint_uuid'] != endpoint_uuid) + ep_id + for ep_id in link_tuple[0]['link_endpoint_ids'] + if ep_id['endpoint_id']['device_id'] != device_uuid ]), None) - if ingress['endpoint_id']['device_id'] != device_uuid: - raise Exception('Malformed path') ingress_ep = ingress['endpoint_id']['endpoint_uuid'] ingress_ep = MAP_TAPI_UUIDS.get(ingress_ep, ingress_ep) diff --git a/src/pathcomp/frontend/tests/Objects_A_B_C.py b/src/pathcomp/frontend/tests/Objects_A_B_C.py index 5290123b62251a58d8e0a7f273ea23c38ee2cc8a..4bd1907cd71530973424d623428d8318acdf8ea9 100644 --- a/src/pathcomp/frontend/tests/Objects_A_B_C.py +++ b/src/pathcomp/frontend/tests/Objects_A_B_C.py @@ -16,14 +16,14 @@ from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.tools.object_factory.Constraint import json_constraint_sla_capacity, json_constraint_sla_latency from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import json_device_emulated_packet_router_disabled, json_device_id -from common.tools.object_factory.EndPoint import json_endpoints +from common.tools.object_factory.EndPoint import json_endpoint_descriptor, json_endpoints from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Service import get_service_uuid, json_service_l3nm_planned from common.tools.object_factory.Topology import json_topology, json_topology_id def compose_device(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] endpoints = json_endpoints(device_id, endpoints, topology_id=topology_id) device = json_device_emulated_packet_router_disabled(device_uuid, endpoints=endpoints) return device_id, endpoints, device diff --git a/src/pathcomp/frontend/tests/Objects_DC_CSGW_TN.py b/src/pathcomp/frontend/tests/Objects_DC_CSGW_TN.py index 053dfd4c45e3822914745905c71f9b64300e1a2f..38218e987a2aadf1d3a7152fa64125f606e3f947 100644 --- a/src/pathcomp/frontend/tests/Objects_DC_CSGW_TN.py +++ b/src/pathcomp/frontend/tests/Objects_DC_CSGW_TN.py @@ -18,7 +18,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_datacenter_disabled, json_device_emulated_packet_router_disabled, json_device_id) -from common.tools.object_factory.EndPoint import json_endpoints +from common.tools.object_factory.EndPoint import json_endpoint_descriptor, json_endpoints from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Service import get_service_uuid, json_service_l3nm_planned from common.tools.object_factory.Topology import json_topology, json_topology_id @@ -29,7 +29,7 @@ ADD_CONNECT_RULES_TO_DEVICES = False def compose_router(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints @@ -38,7 +38,7 @@ def compose_router(device_uuid, endpoint_uuids, topology_id=None): def compose_datacenter(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints diff --git a/src/pathcomp/frontend/tests/Objects_DC_CSGW_TN_OLS.py b/src/pathcomp/frontend/tests/Objects_DC_CSGW_TN_OLS.py index 2c8428568c001a53cbf2c08aa13b61ad14a1bd51..3b385412038edfcfa8a1c7c8d5a805c867c69993 100644 --- a/src/pathcomp/frontend/tests/Objects_DC_CSGW_TN_OLS.py +++ b/src/pathcomp/frontend/tests/Objects_DC_CSGW_TN_OLS.py @@ -18,8 +18,9 @@ from common.tools.object_factory.Constraint import json_constraint_sla_capacity, from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_datacenter_disabled, - json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, json_device_id) -from common.tools.object_factory.EndPoint import json_endpoints + json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, + json_device_id) +from common.tools.object_factory.EndPoint import json_endpoint_descriptor, json_endpoints from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Service import get_service_uuid, json_service_l3nm_planned from common.tools.object_factory.Topology import json_topology, json_topology_id @@ -30,7 +31,7 @@ ADD_CONNECT_RULES_TO_DEVICES = False def compose_router(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints @@ -39,7 +40,7 @@ def compose_router(device_uuid, endpoint_uuids, topology_id=None): def compose_ols(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'optical', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'optical') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints @@ -48,7 +49,7 @@ def compose_ols(device_uuid, endpoint_uuids, topology_id=None): def compose_datacenter(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints diff --git a/src/pathcomp/frontend/tests/test_ero_path.py b/src/pathcomp/frontend/tests/test_ero_path.py new file mode 100644 index 0000000000000000000000000000000000000000..e263544a00e104065495fda3f2c85f1528ad8561 --- /dev/null +++ b/src/pathcomp/frontend/tests/test_ero_path.py @@ -0,0 +1,198 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +from typing import Any, Dict, List, Tuple +#from common.proto.context_pb2 import Link + +logging.basicConfig(level=logging.DEBUG) +LOGGER = logging.getLogger(__name__) + +ERO_PATH = [ + {'device_id': 'DC1-GW', 'endpoint_uuid': 'int'}, + {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth1'}, + {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/2'}, + {'device_id': 'TN-R2', 'endpoint_uuid': '2/1'}, + {'device_id': 'TN-OLS', 'endpoint_uuid': '77486d5b0a15'}, + {'device_id': 'TN-R4', 'endpoint_uuid': '1/2'}, + {'device_id': 'CS2-GW1', 'endpoint_uuid': '10/1'}, + {'device_id': 'DC2-GW', 'endpoint_uuid': 'int'} +] + +ENDPOINT_TO_LINK_DICT = { + ('CS1-GW1', '1/1' , 'dst'): ({'link_Id': 'TN-R1/1/1==CS1-GW1/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/1'}}]}, None), + ('CS1-GW1', '1/1' , 'src'): ({'link_Id': 'CS1-GW1/1/1==TN-R1/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '1/1'}}]}, None), + ('CS1-GW1', '1/2' , 'dst'): ({'link_Id': 'TN-R2/1/2==CS1-GW1/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/2'}}]}, None), + ('CS1-GW1', '1/2' , 'src'): ({'link_Id': 'CS1-GW1/1/2==TN-R2/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '1/2'}}]}, None), + ('CS1-GW1', '10/1' , 'dst'): ({'link_Id': 'DC1-GW/eth1==CS1-GW1/10/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth1'}}, {'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '10/1'}}]}, None), + ('CS1-GW1', '10/1' , 'src'): ({'link_Id': 'CS1-GW1/10/1==DC1-GW/eth1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '10/1'}}, {'endpoint_id': {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth1'}}]}, None), + ('CS1-GW2', '1/1' , 'dst'): ({'link_Id': 'TN-R2/1/1==CS1-GW2/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '1/1'}}]}, None), + ('CS1-GW2', '1/1' , 'src'): ({'link_Id': 'CS1-GW2/1/1==TN-R2/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '1/1'}}]}, None), + ('CS1-GW2', '1/2' , 'dst'): ({'link_Id': 'TN-R1/1/2==CS1-GW2/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '1/2'}}]}, None), + ('CS1-GW2', '1/2' , 'src'): ({'link_Id': 'CS1-GW2/1/2==TN-R1/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '1/2'}}]}, None), + ('CS1-GW2', '10/1' , 'dst'): ({'link_Id': 'DC1-GW/eth2==CS1-GW2/10/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth2'}}, {'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '10/1'}}]}, None), + ('CS1-GW2', '10/1' , 'src'): ({'link_Id': 'CS1-GW2/10/1==DC1-GW/eth2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '10/1'}}, {'endpoint_id': {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth2'}}]}, None), + ('CS2-GW1', '1/1' , 'dst'): ({'link_Id': 'TN-R3/1/1==CS2-GW1/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '1/1'}}]}, None), + ('CS2-GW1', '1/1' , 'src'): ({'link_Id': 'CS2-GW1/1/1==TN-R3/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '1/1'}}]}, None), + ('CS2-GW1', '1/2' , 'dst'): ({'link_Id': 'TN-R4/1/2==CS2-GW1/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '1/2'}}]}, None), + ('CS2-GW1', '1/2' , 'src'): ({'link_Id': 'CS2-GW1/1/2==TN-R4/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '1/2'}}]}, None), + ('CS2-GW1', '10/1' , 'dst'): ({'link_Id': 'DC2-GW/eth1==CS2-GW1/10/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'DC2-GW', 'endpoint_uuid': 'eth1'}}, {'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '10/1'}}]}, None), + ('CS2-GW1', '10/1' , 'src'): ({'link_Id': 'CS2-GW1/10/1==DC2-GW/eth1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '10/1'}}, {'endpoint_id': {'device_id': 'DC2-GW', 'endpoint_uuid': 'eth1'}}]}, None), + ('CS2-GW2', '1/1' , 'dst'): ({'link_Id': 'TN-R4/1/1==CS2-GW2/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '1/1'}}]}, None), + ('CS2-GW2', '1/1' , 'src'): ({'link_Id': 'CS2-GW2/1/1==TN-R4/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '1/1'}}]}, None), + ('CS2-GW2', '1/2' , 'dst'): ({'link_Id': 'TN-R3/1/2==CS2-GW2/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '1/2'}}]}, None), + ('CS2-GW2', '1/2' , 'src'): ({'link_Id': 'CS2-GW2/1/2==TN-R3/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '1/2'}}]}, None), + ('CS2-GW2', '10/1' , 'dst'): ({'link_Id': 'DC2-GW/eth2==CS2-GW2/10/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'DC2-GW', 'endpoint_uuid': 'eth2'}}, {'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '10/1'}}]}, None), + ('CS2-GW2', '10/1' , 'src'): ({'link_Id': 'CS2-GW2/10/1==DC2-GW/eth2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '10/1'}}, {'endpoint_id': {'device_id': 'DC2-GW', 'endpoint_uuid': 'eth2'}}]}, None), + ('DC1-GW' , 'eth1' , 'dst'): ({'link_Id': 'CS1-GW1/10/1==DC1-GW/eth1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '10/1'}}, {'endpoint_id': {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth1'}}]}, None), + ('DC1-GW' , 'eth1' , 'src'): ({'link_Id': 'DC1-GW/eth1==CS1-GW1/10/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth1'}}, {'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '10/1'}}]}, None), + ('DC1-GW' , 'eth2' , 'dst'): ({'link_Id': 'CS1-GW2/10/1==DC1-GW/eth2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '10/1'}}, {'endpoint_id': {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth2'}}]}, None), + ('DC1-GW' , 'eth2' , 'src'): ({'link_Id': 'DC1-GW/eth2==CS1-GW2/10/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'DC1-GW', 'endpoint_uuid': 'eth2'}}, {'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '10/1'}}]}, None), + ('DC2-GW' , 'eth1' , 'dst'): ({'link_Id': 'CS2-GW1/10/1==DC2-GW/eth1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '10/1'}}, {'endpoint_id': {'device_id': 'DC2-GW', 'endpoint_uuid': 'eth1'}}]}, None), + ('DC2-GW' , 'eth1' , 'src'): ({'link_Id': 'DC2-GW/eth1==CS2-GW1/10/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'DC2-GW', 'endpoint_uuid': 'eth1'}}, {'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '10/1'}}]}, None), + ('DC2-GW' , 'eth2' , 'dst'): ({'link_Id': 'CS2-GW2/10/1==DC2-GW/eth2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '10/1'}}, {'endpoint_id': {'device_id': 'DC2-GW', 'endpoint_uuid': 'eth2'}}]}, None), + ('DC2-GW' , 'eth2' , 'src'): ({'link_Id': 'DC2-GW/eth2==CS2-GW2/10/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'DC2-GW', 'endpoint_uuid': 'eth2'}}, {'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '10/1'}}]}, None), + ('TN-OLS' , '3c5ace9aaf9f', 'dst'): ({'link_Id': 'TN-R1/2/1==TN-OLS/3c5ace9aaf9f', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '2/1'}}, {'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '3c5ace9aaf9f'}}]}, None), + ('TN-OLS' , '3c5ace9aaf9f', 'src'): ({'link_Id': 'TN-OLS/3c5ace9aaf9f==TN-R1/2/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '3c5ace9aaf9f'}}, {'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '2/1'}}]}, None), + ('TN-OLS' , '3c9fd5178cd5', 'dst'): ({'link_Id': 'TN-R2/2/1==TN-OLS/3c9fd5178cd5', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '2/1'}}, {'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '3c9fd5178cd5'}}]}, None), + ('TN-OLS' , '3c9fd5178cd5', 'src'): ({'link_Id': 'TN-OLS/3c9fd5178cd5==TN-R2/2/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '3c9fd5178cd5'}}, {'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '2/1'}}]}, None), + ('TN-OLS' , '77486d5b0a15', 'dst'): ({'link_Id': 'TN-R4/2/1==TN-OLS/77486d5b0a15', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '2/1'}}, {'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '77486d5b0a15'}}]}, None), + ('TN-OLS' , '77486d5b0a15', 'src'): ({'link_Id': 'TN-OLS/77486d5b0a15==TN-R4/2/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '77486d5b0a15'}}, {'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '2/1'}}]}, None), + ('TN-OLS' , 'e4072030a6d6', 'dst'): ({'link_Id': 'TN-R3/2/1==TN-OLS/e4072030a6d6', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '2/1'}}, {'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': 'e4072030a6d6'}}]}, None), + ('TN-OLS' , 'e4072030a6d6', 'src'): ({'link_Id': 'TN-OLS/e4072030a6d6==TN-R3/2/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': 'e4072030a6d6'}}, {'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '2/1'}}]}, None), + ('TN-R1' , '1/1' , 'dst'): ({'link_Id': 'CS1-GW1/1/1==TN-R1/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '1/1'}}]}, None), + ('TN-R1' , '1/1' , 'src'): ({'link_Id': 'TN-R1/1/1==CS1-GW1/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/1'}}]}, None), + ('TN-R1' , '1/2' , 'dst'): ({'link_Id': 'CS1-GW2/1/2==TN-R1/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '1/2'}}]}, None), + ('TN-R1' , '1/2' , 'src'): ({'link_Id': 'TN-R1/1/2==CS1-GW2/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '1/2'}}]}, None), + ('TN-R1' , '2/1' , 'dst'): ({'link_Id': 'TN-OLS/3c5ace9aaf9f==TN-R1/2/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '3c5ace9aaf9f'}}, {'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '2/1'}}]}, None), + ('TN-R1' , '2/1' , 'src'): ({'link_Id': 'TN-R1/2/1==TN-OLS/3c5ace9aaf9f', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R1', 'endpoint_uuid': '2/1'}}, {'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '3c5ace9aaf9f'}}]}, None), + ('TN-R2' , '1/1' , 'dst'): ({'link_Id': 'CS1-GW2/1/1==TN-R2/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '1/1'}}]}, None), + ('TN-R2' , '1/1' , 'src'): ({'link_Id': 'TN-R2/1/1==CS1-GW2/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'CS1-GW2', 'endpoint_uuid': '1/1'}}]}, None), + ('TN-R2' , '1/2' , 'dst'): ({'link_Id': 'CS1-GW1/1/2==TN-R2/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '1/2'}}]}, None), + ('TN-R2' , '1/2' , 'src'): ({'link_Id': 'TN-R2/1/2==CS1-GW1/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'CS1-GW1', 'endpoint_uuid': '1/2'}}]}, None), + ('TN-R2' , '2/1' , 'dst'): ({'link_Id': 'TN-OLS/3c9fd5178cd5==TN-R2/2/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '3c9fd5178cd5'}}, {'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '2/1'}}]}, None), + ('TN-R2' , '2/1' , 'src'): ({'link_Id': 'TN-R2/2/1==TN-OLS/3c9fd5178cd5', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R2', 'endpoint_uuid': '2/1'}}, {'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '3c9fd5178cd5'}}]}, None), + ('TN-R3' , '1/1' , 'dst'): ({'link_Id': 'CS2-GW1/1/1==TN-R3/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '1/1'}}]}, None), + ('TN-R3' , '1/1' , 'src'): ({'link_Id': 'TN-R3/1/1==CS2-GW1/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '1/1'}}]}, None), + ('TN-R3' , '1/2' , 'dst'): ({'link_Id': 'CS2-GW2/1/2==TN-R3/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '1/2'}}]}, None), + ('TN-R3' , '1/2' , 'src'): ({'link_Id': 'TN-R3/1/2==CS2-GW2/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '1/2'}}]}, None), + ('TN-R3' , '2/1' , 'dst'): ({'link_Id': 'TN-OLS/e4072030a6d6==TN-R3/2/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': 'e4072030a6d6'}}, {'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '2/1'}}]}, None), + ('TN-R3' , '2/1' , 'src'): ({'link_Id': 'TN-R3/2/1==TN-OLS/e4072030a6d6', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R3', 'endpoint_uuid': '2/1'}}, {'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': 'e4072030a6d6'}}]}, None), + ('TN-R4' , '1/1' , 'dst'): ({'link_Id': 'CS2-GW2/1/1==TN-R4/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '1/1'}}]}, None), + ('TN-R4' , '1/1' , 'src'): ({'link_Id': 'TN-R4/1/1==CS2-GW2/1/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '1/1'}}, {'endpoint_id': {'device_id': 'CS2-GW2', 'endpoint_uuid': '1/1'}}]}, None), + ('TN-R4' , '1/2' , 'dst'): ({'link_Id': 'CS2-GW1/1/2==TN-R4/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '1/2'}}]}, None), + ('TN-R4' , '1/2' , 'src'): ({'link_Id': 'TN-R4/1/2==CS2-GW1/1/2', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '1/2'}}, {'endpoint_id': {'device_id': 'CS2-GW1', 'endpoint_uuid': '1/2'}}]}, None), + ('TN-R4' , '2/1' , 'dst'): ({'link_Id': 'TN-OLS/77486d5b0a15==TN-R4/2/1', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '77486d5b0a15'}}, {'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '2/1'}}]}, None), + ('TN-R4' , '2/1' , 'src'): ({'link_Id': 'TN-R4/2/1==TN-OLS/77486d5b0a15', 'link_endpoint_ids': [{'endpoint_id': {'device_id': 'TN-R4', 'endpoint_uuid': '2/1'}}, {'endpoint_id': {'device_id': 'TN-OLS', 'endpoint_uuid': '77486d5b0a15'}}]}, None), +} + +MAP_TAPI_UUIDS = { + "c3dbaa44-9cda-5d54-8f99-0f282362be65": "5b835e46-53f7-52e8-9c8a-077322679e36", # node-1-port-13-input => node-1-port-13-output + "1fb9ac86-b7ad-5d6d-87b1-a09d995f1ddd": "c9df6ece-1650-5078-876a-1e488a453625", # node-1-port-14-input => node-1-port-14-output + "aa109937-8291-5a09-853a-97bff463e569": "b245480f-027c-53a0-9320-fca5b9d7a1e1", # node-1-port-15-input => node-1-port-15-output + "6653ae16-42a3-56b5-adf3-71adda024a61": "ac356900-ce2f-5c15-b038-1b05e6f50bf7", # node-1-port-17-input => node-1-port-17-output + "d782ef85-a473-50b4-93b5-2af86024a42a": "dcfeedd3-2d47-5bc8-b31c-ed9f973d8b76", # node-2-port-13-input => node-2-port-13-output + "bbbd83ef-6053-55dc-ab08-06fb0c2bd081": "57bcf45b-eb47-5a9c-86d1-d9cff0c910fd", # node-2-port-14-input => node-2-port-14-output + "27cdf70d-4e48-53ff-bc4f-20addf6524c0": "fd31eff5-392e-5fb5-a6f4-6dfca583344d", # node-2-port-15-input => node-2-port-15-output + "55ac2364-fad8-5a05-ac2b-5003997ff89e": "d12a2591-7f4a-575d-8fda-0bc3d6b7ca32", # node-2-port-17-input => node-2-port-17-output + "59f44a3c-32a5-5abf-af58-45e6fa7ca657": "1977ef5c-4383-5195-9221-0cdf8ee26cb7", # node-3-port-13-input => node-3-port-13-output + "1be3f905-d553-5291-9906-47c0772d45aa": "9def067b-9a75-54df-8867-853f35a42e87", # node-3-port-14-input => node-3-port-14-output + "fb4ece7a-2dd1-593a-b6ca-a787b3b59fc5": "1f294257-132a-54ad-b653-ef8b7517c9d8", # node-3-port-15-input => node-3-port-15-output + "a571d2fe-c7f8-5ac8-b2af-8e5b92a558b0": "5b60a688-deac-567a-8e36-0d52e56fd4fc", # node-3-port-16-input => node-3-port-16-output + "9ea9dc53-2d6a-5f28-b81a-e930f7cbedf9": "2aec14c1-3a84-5cba-8f22-783bd0273cd0", # node-3-port-17-input => node-3-port-17-output + "9ec8e0f3-3378-55e0-bed1-be1fe120a1a9": "ece2ed55-ce16-59d3-8137-3f4cf17e67ab", # node-3-port-18-input => node-3-port-18-output + "a7e114aa-a3b6-52ae-b7b7-0e5fe4dd4d1c": "0a05e43d-a13c-5276-9839-613600f3ff28", # node-4-port-13-input => node-4-port-13-output + "4ca8357a-3468-51e6-bba8-65137486666f": "18926fdf-de5c-5a52-be88-cccc065e5e03", # node-4-port-14-input => node-4-port-14-output + "a7e9f06f-6fd2-594e-8a0c-25bfe8c652d7": "1adb9e17-e499-58dc-8aa2-881ed5ce9670", # node-4-port-15-input => node-4-port-15-output + "9f6a23b2-c71c-5559-8fb3-f76421bea1d9": "049bb1f1-cc04-5b72-8c0f-43891d9637bf", # node-4-port-16-input => node-4-port-16-output + "f1d74c96-41f5-5eb9-a160-a38463184934": "2206440b-ef66-5d3e-8da5-40608fb00a10", # node-4-port-17-input => node-4-port-17-output + + "5b835e46-53f7-52e8-9c8a-077322679e36": "c3dbaa44-9cda-5d54-8f99-0f282362be65", # node-1-port-13-output => node-1-port-13-input + "c9df6ece-1650-5078-876a-1e488a453625": "1fb9ac86-b7ad-5d6d-87b1-a09d995f1ddd", # node-1-port-14-output => node-1-port-14-input + "b245480f-027c-53a0-9320-fca5b9d7a1e1": "aa109937-8291-5a09-853a-97bff463e569", # node-1-port-15-output => node-1-port-15-input + "ac356900-ce2f-5c15-b038-1b05e6f50bf7": "6653ae16-42a3-56b5-adf3-71adda024a61", # node-1-port-17-output => node-1-port-17-input + "dcfeedd3-2d47-5bc8-b31c-ed9f973d8b76": "d782ef85-a473-50b4-93b5-2af86024a42a", # node-2-port-13-output => node-2-port-13-input + "57bcf45b-eb47-5a9c-86d1-d9cff0c910fd": "bbbd83ef-6053-55dc-ab08-06fb0c2bd081", # node-2-port-14-output => node-2-port-14-input + "fd31eff5-392e-5fb5-a6f4-6dfca583344d": "27cdf70d-4e48-53ff-bc4f-20addf6524c0", # node-2-port-15-output => node-2-port-15-input + "d12a2591-7f4a-575d-8fda-0bc3d6b7ca32": "55ac2364-fad8-5a05-ac2b-5003997ff89e", # node-2-port-17-output => node-2-port-17-input + "1977ef5c-4383-5195-9221-0cdf8ee26cb7": "59f44a3c-32a5-5abf-af58-45e6fa7ca657", # node-3-port-13-output => node-3-port-13-input + "9def067b-9a75-54df-8867-853f35a42e87": "1be3f905-d553-5291-9906-47c0772d45aa", # node-3-port-14-output => node-3-port-14-input + "1f294257-132a-54ad-b653-ef8b7517c9d8": "fb4ece7a-2dd1-593a-b6ca-a787b3b59fc5", # node-3-port-15-output => node-3-port-15-input + "5b60a688-deac-567a-8e36-0d52e56fd4fc": "a571d2fe-c7f8-5ac8-b2af-8e5b92a558b0", # node-3-port-16-output => node-3-port-16-input + "2aec14c1-3a84-5cba-8f22-783bd0273cd0": "9ea9dc53-2d6a-5f28-b81a-e930f7cbedf9", # node-3-port-17-output => node-3-port-17-input + "ece2ed55-ce16-59d3-8137-3f4cf17e67ab": "9ec8e0f3-3378-55e0-bed1-be1fe120a1a9", # node-3-port-18-output => node-3-port-18-input + "0a05e43d-a13c-5276-9839-613600f3ff28": "a7e114aa-a3b6-52ae-b7b7-0e5fe4dd4d1c", # node-4-port-13-output => node-4-port-13-input + "18926fdf-de5c-5a52-be88-cccc065e5e03": "4ca8357a-3468-51e6-bba8-65137486666f", # node-4-port-14-output => node-4-port-14-input + "1adb9e17-e499-58dc-8aa2-881ed5ce9670": "a7e9f06f-6fd2-594e-8a0c-25bfe8c652d7", # node-4-port-15-output => node-4-port-15-input + "049bb1f1-cc04-5b72-8c0f-43891d9637bf": "9f6a23b2-c71c-5559-8fb3-f76421bea1d9", # node-4-port-16-output => node-4-port-16-input + "2206440b-ef66-5d3e-8da5-40608fb00a10": "f1d74c96-41f5-5eb9-a160-a38463184934", # node-4-port-17-output => node-4-port-17-input +} + +def eropath_to_hops( + ero_path : List[Dict], endpoint_to_link_dict : Dict[Tuple[str, str, str], Tuple[Dict, Any]] +) -> List[Dict]: + LOGGER.debug('ero_path = {:s}'.format(str(ero_path))) + try: + path_hops = [] + num_ero_hops = len(ero_path) + for endpoint in ero_path: + LOGGER.info('endpoint={:s}'.format(str(endpoint))) + + device_uuid = endpoint['device_id'] + endpoint_uuid = endpoint['endpoint_uuid'] + + if len(path_hops) == 0: + LOGGER.info(' first hop') + path_hops.append({'device': device_uuid, 'ingress_ep': endpoint_uuid}) + continue + + LOGGER.info(' next hop') + last_hop = path_hops[-1] + LOGGER.info(' last_hop={:s}'.format(str(last_hop))) + if last_hop['device'] != device_uuid: raise Exception('Malformed path') + last_hop['egress_ep'] = endpoint_uuid + + if num_ero_hops - 1 == len(path_hops): break + + endpoint_key = (last_hop['device'], last_hop['egress_ep'], 'src') + LOGGER.info(' endpoint_key={:s}'.format(str(endpoint_key))) + link_tuple = endpoint_to_link_dict[endpoint_key] + LOGGER.info(' link_tuple={:s}'.format(str(link_tuple))) + if link_tuple is None: raise Exception('Malformed path') + + ingress = next(iter([ + ep_id + for ep_id in link_tuple[0]['link_endpoint_ids'] + if ep_id['endpoint_id']['device_id'] != device_uuid + ]), None) + LOGGER.info(' ingress={:s}'.format(str(ingress))) + #if ingress['endpoint_id']['device_id'] != device_uuid: + # raise Exception('Malformed path') + + ingress_ep = ingress['endpoint_id']['endpoint_uuid'] + ingress_ep = MAP_TAPI_UUIDS.get(ingress_ep, ingress_ep) + path_hops.append({ + 'device': ingress['endpoint_id']['device_id'], + 'ingress_ep': ingress_ep, + 'egress_ep': endpoint_uuid, + }) + LOGGER.debug('path_hops = {:s}'.format(str(path_hops))) + return path_hops + except: + #LOGGER.exception('Unhandled exception: ero_path={:s} endpoint_to_link_dict={:s}'.format( + # str(ero_path), str(endpoint_to_link_dict))) + raise + +res = eropath_to_hops(ERO_PATH, ENDPOINT_TO_LINK_DICT) +LOGGER.warning('res = {:s}'.format(str(res))) diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py index 11d191d4b08d642c228bbfc5ce33c45bd587021a..141c6cb3ce84709d601b0510a61e1c497aa3f598 100644 --- a/src/service/service/ServiceServiceServicerImpl.py +++ b/src/service/service/ServiceServiceServicerImpl.py @@ -18,7 +18,8 @@ from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_m from common.method_wrappers.ServiceExceptions import ( AlreadyExistsException, InvalidArgumentException, NotFoundException, NotImplementedException, OperationFailedException) -from common.proto.context_pb2 import Connection, Empty, Service, ServiceId, ServiceStatusEnum, ServiceTypeEnum, ConstraintActionEnum +from common.proto.context_pb2 import ( + Connection, Empty, Service, ServiceId, ServiceStatusEnum, ServiceTypeEnum, ConstraintActionEnum) from common.proto.pathcomp_pb2 import PathCompRequest from common.proto.service_pb2_grpc import ServiceServiceServicer from common.tools.context_queries.Service import get_service_by_id @@ -94,30 +95,22 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): context_client = ContextClient() _service : Optional[Service] = get_service_by_id( context_client, request.service_id, rw_copy=False, - include_config_rules=False, include_constraints=False, include_endpoint_ids=False) - service = Service() - service.CopyFrom(request if _service is None else _service) + include_config_rules=True, include_constraints=True, include_endpoint_ids=True) + location_aware = False for constraint in request.service_constraints: - if constraint.action == ConstraintActionEnum.CONSTRAINTACTION_SET: - if constraint.WhichOneof('constraint') == 'endpoint_location' and not constraint.endpoint_location.HasField('endpoint_id'): - device_list = context_client.ListDevices(Empty()) - service_location = constraint.endpoint_location.location - distances = {} - for device in device_list.devices: - for endpoint in device.device_endpoints: - if not endpoint.endpoint_location.HasField('gps_position'): continue - - distance = gps_distance(service_location.gps_position, endpoint.endpoint_location.gps_position) - distances[distance] = endpoint.endpoint_id - - closer_endpoint_id = distances[min(distances)] - constraint.endpoint_location.endpoint_id.CopyFrom(closer_endpoint_id) - - if closer_endpoint_id not in [endpoint.endpoint_id.endpoint_uuid for endpoint in service.service_endpoint_ids]: - service.service_endpoint_ids.append(closer_endpoint_id) + if constraint.WhichOneof('constraint') != 'endpoint_location': continue + location_aware = True + LOGGER.debug('location_aware={:s}'.format(str(location_aware))) + if _service is not None and location_aware: + LOGGER.debug(' Removing previous service') + tasks_scheduler = TasksScheduler(self.service_handler_factory) + tasks_scheduler.compose_from_service(_service, is_delete=True) + tasks_scheduler.execute_all() + service = Service() + service.CopyFrom(request if _service is None else _service) if service.service_type == ServiceTypeEnum.SERVICETYPE_UNKNOWN: # pylint: disable=no-member service.service_type = request.service_type # pylint: disable=no-member @@ -127,6 +120,39 @@ class ServiceServiceServicerImpl(ServiceServiceServicer): for endpoint_id in request.service_endpoint_ids: service.service_endpoint_ids.add().CopyFrom(endpoint_id) # pylint: disable=no-member + device_list = context_client.ListDevices(Empty()) + + LOGGER.debug('[before] request={:s}'.format(grpc_message_to_json_string(request))) + for constraint in request.service_constraints: + if constraint.action == ConstraintActionEnum.CONSTRAINTACTION_UNDEFINED: + # Field action is new; assume if not set, it means SET + constraint.action = ConstraintActionEnum.CONSTRAINTACTION_SET + + if constraint.action != ConstraintActionEnum.CONSTRAINTACTION_SET: continue + if constraint.WhichOneof('constraint') != 'endpoint_location': continue + if constraint.endpoint_location.HasField('endpoint_id'): continue + + service_location = constraint.endpoint_location.location + distances = {} + for device in device_list.devices: + for endpoint in device.device_endpoints: + if not endpoint.endpoint_location.HasField('gps_position'): continue + distance = gps_distance(service_location.gps_position, endpoint.endpoint_location.gps_position) + distances[distance] = endpoint.endpoint_id + + closer_endpoint_id = distances[min(distances)] + constraint.endpoint_location.endpoint_id.CopyFrom(closer_endpoint_id) + + service_endpoint_ids = [ + endpoint_id.endpoint_uuid + for endpoint_id in service.service_endpoint_ids + ] + if closer_endpoint_id not in service_endpoint_ids: + service.service_endpoint_ids.append(closer_endpoint_id) + + LOGGER.debug('[after] request={:s}'.format(grpc_message_to_json_string(request))) + LOGGER.debug('[after] service={:s}'.format(grpc_message_to_json_string(service))) + del service.service_constraints[:] # pylint: disable=no-member for constraint in request.service_constraints: service.service_constraints.add().CopyFrom(constraint) # pylint: disable=no-member diff --git a/src/service/tests/PrepareTestScenario.py b/src/service/tests/PrepareTestScenario.py index a5244f5a7c3fe35089c52c077db5a57b1e69ba5b..6397d95495d4e06cbb6fa2d055a293cfac0bf48f 100644 --- a/src/service/tests/PrepareTestScenario.py +++ b/src/service/tests/PrepareTestScenario.py @@ -22,7 +22,7 @@ from service.client.ServiceClient import ServiceClient from service.service.ServiceService import ServiceService from service.service.service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory from service.service.service_handlers import SERVICE_HANDLERS -from service.tests.MockService_Dependencies import MockService_Dependencies +#from service.tests.MockService_Dependencies import MockService_Dependencies LOCAL_HOST = '127.0.0.1' MOCKSERVICE_PORT = 10000 @@ -30,22 +30,24 @@ SERVICE_SERVICE_PORT = MOCKSERVICE_PORT + int(get_service_port_grpc(ServiceNameE os.environ[get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_HOST )] = str(LOCAL_HOST) os.environ[get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(SERVICE_SERVICE_PORT) -@pytest.fixture(scope='session') -def mock_service(): - _service = MockService_Dependencies(MOCKSERVICE_PORT) - _service.configure_env_vars() - _service.start() - yield _service - _service.stop() +#@pytest.fixture(scope='session') +#def mock_service(): +# _service = MockService_Dependencies(MOCKSERVICE_PORT) +# _service.configure_env_vars() +# _service.start() +# yield _service +# _service.stop() @pytest.fixture(scope='session') -def context_client(mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name +#def context_client(mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name +def context_client(): _client = ContextClient() yield _client _client.close() @pytest.fixture(scope='session') -def device_client(mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name +#def device_client(mock_service : MockService_Dependencies): # pylint: disable=redefined-outer-name +def device_client(): _client = DeviceClient() yield _client _client.close() diff --git a/src/service/tests/ServiceHandler_L3NM_EMU.py b/src/service/tests/ServiceHandler_L3NM_EMU.py index 2618e204c00a1bb956812daeb6f831275cac7b5a..2f58aabd987eb391c195fb1f170959178ba40be6 100644 --- a/src/service/tests/ServiceHandler_L3NM_EMU.py +++ b/src/service/tests/ServiceHandler_L3NM_EMU.py @@ -18,24 +18,27 @@ from common.tools.object_factory.Location import json_location, json_gps_positio from common.tools.object_factory.ConfigRule import json_config_rule_set from common.tools.object_factory.Constraint import json_constraint_custom, json_constraint_endpoint_location_gps from common.tools.object_factory.Device import ( - json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, json_device_id) -from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id + json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, + json_device_emulated_tapi_disabled, json_device_id) +from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_descriptor, json_endpoint_id from common.tools.object_factory.Link import json_link, json_link_id from common.tools.object_factory.Service import json_service_id, json_service_l3nm_planned from .CommonObjects import CONTEXT, CONTEXT_ID, PACKET_PORT_SAMPLE_TYPES, TOPOLOGY, TOPOLOGY_ID SERVICE_HANDLER_NAME = 'l3nm_emulated' -def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, str]]): +def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Dict]): return [ - json_endpoint_id(device_id, ep_uuid) - for ep_uuid, _, _ in endpoint_descriptors + json_endpoint_id(device_id, ep_data['uuid']) + for ep_data in endpoint_descriptors ] -def json_endpoints(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, str]]): +def json_endpoints(device_id : Dict, endpoint_descriptors : List[Dict]): return [ - json_endpoint(device_id, ep_uuid, ep_type, kpi_sample_types=PACKET_PORT_SAMPLE_TYPES, location=ep_location) - for ep_uuid, ep_type, ep_location in endpoint_descriptors + json_endpoint( + device_id, ep_data['uuid'], ep_data['type'], kpi_sample_types=PACKET_PORT_SAMPLE_TYPES, + location=ep_data.get('location')) + for ep_data in endpoint_descriptors ] @@ -54,50 +57,53 @@ ALBACETE_GPS = (38.998249, -1.858145) # ----- Devices -------------------------------------------------------------------------------------------------------- DEVICE_R1_UUID = 'R1' DEVICE_R1_ENDPOINT_DEFS = [ - ('EP1', 'optical', json_location(gps_position=json_gps_position(*BARCELONA_GPS))), - ('EP100', 'copper', json_location(gps_position=json_gps_position(*BARCELONA_GPS))) + json_endpoint_descriptor('EP1', 'optical', location=json_location(gps_position=json_gps_position(*BARCELONA_GPS))), + json_endpoint_descriptor('EP100', 'copper', location=json_location(gps_position=json_gps_position(*BARCELONA_GPS))) ] DEVICE_R1_ID = json_device_id(DEVICE_R1_UUID) -DEVICE_R1_ENDPOINTS = json_endpoints(DEVICE_R1_ID, DEVICE_R1_ENDPOINT_DEFS) +DEVICE_R1_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_R1_ENDPOINT_DEFS) +DEVICE_R1 = json_device_emulated_packet_router_disabled( + DEVICE_R1_UUID, config_rules=DEVICE_R1_CONNECT_RULES) DEVICE_R1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R1_ID, DEVICE_R1_ENDPOINT_DEFS) -DEVICE_R1 = json_device_emulated_packet_router_disabled(DEVICE_R1_UUID, endpoints=DEVICE_R1_ENDPOINTS) ENDPOINT_ID_R1_EP1 = DEVICE_R1_ENDPOINT_IDS[0] ENDPOINT_ID_R1_EP100 = DEVICE_R1_ENDPOINT_IDS[1] DEVICE_R2_UUID = 'R2' DEVICE_R2_ENDPOINT_DEFS = [ - ('EP1', 'optical', json_location(gps_position=json_gps_position(*MADRID_GPS))), - ('EP100', 'copper', json_location(gps_position=json_gps_position(*MADRID_GPS))) + json_endpoint_descriptor('EP1', 'optical', location=json_location(gps_position=json_gps_position(*MADRID_GPS))), + json_endpoint_descriptor('EP100', 'copper', location=json_location(gps_position=json_gps_position(*MADRID_GPS))) ] DEVICE_R2_ID = json_device_id(DEVICE_R2_UUID) -DEVICE_R2_ENDPOINTS = json_endpoints(DEVICE_R2_ID, DEVICE_R2_ENDPOINT_DEFS) +DEVICE_R2_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_R2_ENDPOINT_DEFS) +DEVICE_R2 = json_device_emulated_packet_router_disabled( + DEVICE_R2_UUID, config_rules=DEVICE_R2_CONNECT_RULES) DEVICE_R2_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R2_ID, DEVICE_R2_ENDPOINT_DEFS) -DEVICE_R2 = json_device_emulated_packet_router_disabled(DEVICE_R2_UUID, endpoints=DEVICE_R2_ENDPOINTS) ENDPOINT_ID_R2_EP1 = DEVICE_R2_ENDPOINT_IDS[0] ENDPOINT_ID_R2_EP100 = DEVICE_R2_ENDPOINT_IDS[1] DEVICE_R3_UUID = 'R3' DEVICE_R3_ENDPOINT_DEFS = [ - ('EP1', 'optical', json_location(gps_position=json_gps_position(*MALAGA_GPS))), - ('EP100', 'copper', json_location(gps_position=json_gps_position(*MALAGA_GPS))) + json_endpoint_descriptor('EP1', 'optical', location=json_location(gps_position=json_gps_position(*MALAGA_GPS))), + json_endpoint_descriptor('EP100', 'copper', location=json_location(gps_position=json_gps_position(*MALAGA_GPS))) ] DEVICE_R3_ID = json_device_id(DEVICE_R3_UUID) -DEVICE_R3_ENDPOINTS = json_endpoints(DEVICE_R3_ID, DEVICE_R3_ENDPOINT_DEFS) +DEVICE_R2_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_R2_ENDPOINT_DEFS) +DEVICE_R3 = json_device_emulated_packet_router_disabled( + DEVICE_R3_UUID, config_rules=DEVICE_R2_CONNECT_RULES) DEVICE_R3_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R3_ID, DEVICE_R3_ENDPOINT_DEFS) -DEVICE_R3 = json_device_emulated_packet_router_disabled(DEVICE_R3_UUID, endpoints=DEVICE_R3_ENDPOINTS) ENDPOINT_ID_R3_EP1 = DEVICE_R3_ENDPOINT_IDS[0] ENDPOINT_ID_R3_EP100 = DEVICE_R3_ENDPOINT_IDS[1] DEVICE_O1_UUID = 'O1' DEVICE_O1_ENDPOINT_DEFS = [ - ('EP1', 'optical', json_location(gps_position=json_gps_position(*PONFERRADA_GPS))), - ('EP2', 'optical', json_location(gps_position=json_gps_position(*PONFERRADA_GPS))), - ('EP3', 'optical', json_location(gps_position=json_gps_position(*PONFERRADA_GPS))) + json_endpoint_descriptor('EP1', 'optical', location=json_location(gps_position=json_gps_position(*PONFERRADA_GPS))), + json_endpoint_descriptor('EP2', 'optical', location=json_location(gps_position=json_gps_position(*PONFERRADA_GPS))), + json_endpoint_descriptor('EP3', 'optical', location=json_location(gps_position=json_gps_position(*PONFERRADA_GPS))) ] DEVICE_O1_ID = json_device_id(DEVICE_O1_UUID) -DEVICE_O1_ENDPOINTS = json_endpoints(DEVICE_O1_ID, DEVICE_O1_ENDPOINT_DEFS) +DEVICE_O1_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_O1_ENDPOINT_DEFS) +DEVICE_O1 = json_device_emulated_tapi_disabled(DEVICE_O1_UUID, config_rules=DEVICE_O1_CONNECT_RULES) DEVICE_O1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_O1_ID, DEVICE_O1_ENDPOINT_DEFS) -DEVICE_O1 = json_device_emulated_tapi_disabled(DEVICE_O1_UUID, endpoints=DEVICE_O1_ENDPOINTS) ENDPOINT_ID_O1_EP1 = DEVICE_O1_ENDPOINT_IDS[0] ENDPOINT_ID_O1_EP2 = DEVICE_O1_ENDPOINT_IDS[1] ENDPOINT_ID_O1_EP3 = DEVICE_O1_ENDPOINT_IDS[2] @@ -133,7 +139,6 @@ SERVICE_R1_R3_CONSTRAINTS = [ json_constraint_custom('jitter_us', 1.2), ] - SERVICE_R1_R3_CONSTRAINTS_LOCATION = [ json_constraint_endpoint_location_gps(None, ZARAGOZA_GPS[0], ZARAGOZA_GPS[1]), json_constraint_endpoint_location_gps(None, TOLEDO_GPS[0], TOLEDO_GPS[1]), @@ -143,7 +148,6 @@ SERVICE_R1_R3_CONSTRAINTS_LOCATION_NEW = [ json_constraint_endpoint_location_gps(None, GRANADA_GPS[0], GRANADA_GPS[1]), ] - SERVICE_R1_R3_CONFIG_RULES = [ json_config_rule_set( '/settings', diff --git a/src/service/tests/ServiceHandler_L3NM_OC.py b/src/service/tests/ServiceHandler_L3NM_OC.py index a8f1e315a136838cdea4e2c7c4c9e444be250a4b..2dcf089e0263d77203adfc45e5d06dbe54727347 100644 --- a/src/service/tests/ServiceHandler_L3NM_OC.py +++ b/src/service/tests/ServiceHandler_L3NM_OC.py @@ -19,28 +19,31 @@ from common.tools.object_factory.Constraint import json_constraint_custom from common.tools.object_factory.Device import ( json_device_connect_rules, json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, json_device_id) -from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id +from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_descriptor, json_endpoint_id from common.tools.object_factory.Link import json_link, json_link_id from common.tools.object_factory.Service import json_service_id, json_service_l3nm_planned from .CommonObjects import CONTEXT, CONTEXT_ID, PACKET_PORT_SAMPLE_TYPES, TOPOLOGY, TOPOLOGY_ID SERVICE_HANDLER_NAME = 'l3nm_openconfig' -def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Tuple[str, str]]): +def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Dict]): return [ - json_endpoint_id(device_id, ep_uuid) - for ep_uuid, _ in endpoint_descriptors + json_endpoint_id(device_id, ep_data['uuid']) + for ep_data in endpoint_descriptors ] -def json_endpoints(device_id : Dict, endpoint_descriptors : List[Tuple[str, str]]): +def json_endpoints(device_id : Dict, endpoint_descriptors : List[Dict]): return [ - json_endpoint(device_id, ep_uuid, ep_type, kpi_sample_types=PACKET_PORT_SAMPLE_TYPES) - for ep_uuid, ep_type in endpoint_descriptors + json_endpoint( + device_id, ep_data['uuid'], ep_data['type'], kpi_sample_types=PACKET_PORT_SAMPLE_TYPES, + location=ep_data.get('location')) + for ep_data in endpoint_descriptors ] # ----- Devices -------------------------------------------------------------------------------------------------------- DEVICE_R1_UUID = 'R1' -DEVICE_R1_ENDPOINT_DEFS = [('EP1', 'optical'), ('EP100', 'copper')] +DEVICE_R1_ENDPOINT_DEFS = [json_endpoint_descriptor('EP1', 'optical'), + json_endpoint_descriptor('EP100', 'copper')] DEVICE_R1_ADDRESS = '10.0.0.1' DEVICE_R1_PORT = 830 DEVICE_R1_USERNAME = 'admin' @@ -60,7 +63,8 @@ DEVICE_R1_CONNECT_RULES = json_device_connect_rules(DEVICE_R1_ADDRESS, DEVICE_R1 DEVICE_R2_UUID = 'R2' -DEVICE_R2_ENDPOINT_DEFS = [('EP1', 'optical'), ('EP100', 'copper')] +DEVICE_R2_ENDPOINT_DEFS = [json_endpoint_descriptor('EP1', 'optical'), + json_endpoint_descriptor('EP100', 'copper')] DEVICE_R2_ADDRESS = '10.0.0.2' DEVICE_R2_PORT = 830 DEVICE_R2_USERNAME = 'admin' @@ -80,7 +84,8 @@ DEVICE_R2_CONNECT_RULES = json_device_connect_rules(DEVICE_R2_ADDRESS, DEVICE_R2 DEVICE_O1_UUID = 'O1' -DEVICE_O1_ENDPOINT_DEFS = [(str(uuid.uuid4()), 'optical'), (str(uuid.uuid4()), 'optical')] +DEVICE_O1_ENDPOINT_DEFS = [json_endpoint_descriptor(str(uuid.uuid4()), 'optical'), + json_endpoint_descriptor(str(uuid.uuid4()), 'optical')] DEVICE_O1_ADDRESS = '10.0.0.3' DEVICE_O1_PORT = 4900 DEVICE_O1_TIMEOUT = 120 @@ -137,14 +142,15 @@ SERVICE_R1_R2_DESCRIPTOR = json_service_l3nm_planned(SERVICE_R1_R2_UUID) # ----- Test Descriptor ------------------------------------------------------------------------------------------------ TEST_SERVICE_HANDLER = (SERVICE_HANDLER_NAME, { - 'contexts' : [CONTEXT], - 'topologies' : [TOPOLOGY], - 'devices' : [DEVICE_R1, DEVICE_R2, DEVICE_O1], - 'links' : [LINK_R1_O1, LINK_R2_O1], - - 'service_id' : SERVICE_R1_R2_ID, - 'service_descriptor' : SERVICE_R1_R2_DESCRIPTOR, - 'service_endpoint_ids' : SERVICE_R1_R2_ENDPOINT_IDS, - 'service_config_rules' : SERVICE_R1_R2_CONFIG_RULES, - 'service_constraints' : SERVICE_R1_R2_CONSTRAINTS, + 'contexts' : [CONTEXT], + 'topologies' : [TOPOLOGY], + 'devices' : [DEVICE_R1, DEVICE_R2, DEVICE_O1], + 'links' : [LINK_R1_O1, LINK_R2_O1], + 'service_id' : SERVICE_R1_R2_ID, + 'service_descriptor' : SERVICE_R1_R2_DESCRIPTOR, + 'service_endpoint_ids' : SERVICE_R1_R2_ENDPOINT_IDS, + 'service_config_rules' : SERVICE_R1_R2_CONFIG_RULES, + 'service_constraints' : SERVICE_R1_R2_CONSTRAINTS, + 'service_constraints_location' : [], + 'service_constraints_location_new' : [], }) diff --git a/src/service/tests/ServiceHandlersToTest.py b/src/service/tests/ServiceHandlersToTest.py index c50a0b45774f15497578a9c5b365e1e331d6d95e..9b45cad7b9def99a5285f4a249af5cd608a91770 100644 --- a/src/service/tests/ServiceHandlersToTest.py +++ b/src/service/tests/ServiceHandlersToTest.py @@ -22,8 +22,8 @@ try: except ImportError: pass -try: - from service.tests.ServiceHandler_L3NM_OC import TEST_SERVICE_HANDLER - SERVICE_HANDLERS_TO_TEST.append(TEST_SERVICE_HANDLER) -except ImportError: - pass +#try: +# from service.tests.ServiceHandler_L3NM_OC import TEST_SERVICE_HANDLER +# SERVICE_HANDLERS_TO_TEST.append(TEST_SERVICE_HANDLER) +#except ImportError: +# pass diff --git a/src/service/tests/test_unitary.py b/src/service/tests/test_unitary.py index aa44714af081307377fe52106cb715f5e0774c73..366add517994c255abd29056f2ab523de3752a37 100644 --- a/src/service/tests/test_unitary.py +++ b/src/service/tests/test_unitary.py @@ -22,7 +22,9 @@ from device.client.DeviceClient import DeviceClient from service.client.ServiceClient import ServiceClient from .PrepareTestScenario import ( # pylint: disable=unused-import # be careful, order of symbols is important here! - mock_service, service_service, context_client, device_client, service_client) + # mock_service, + service_service, context_client, device_client, service_client +) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) @@ -37,9 +39,8 @@ class TestServiceHandlers: scenarios = SERVICE_HANDLERS_TO_TEST def test_prepare_environment( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -51,9 +52,8 @@ class TestServiceHandlers: def test_service_create_error_cases( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -93,9 +93,8 @@ class TestServiceHandlers: def test_service_create_correct( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -104,9 +103,8 @@ class TestServiceHandlers: def test_service_get_created( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -116,9 +114,8 @@ class TestServiceHandlers: def test_service_update_configure( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -136,9 +133,8 @@ class TestServiceHandlers: str(device_id), i, grpc_message_to_json_string(config_rule))) def test_service_update_deconfigure( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -156,9 +152,8 @@ class TestServiceHandlers: def test_service_get_updated( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -168,9 +163,8 @@ class TestServiceHandlers: def test_service_update_configure_loc( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -189,9 +183,8 @@ class TestServiceHandlers: def test_service_get_updated_1( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -201,9 +194,8 @@ class TestServiceHandlers: def test_service_update_configure_loc_new( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -222,9 +214,8 @@ class TestServiceHandlers: def test_service_get_updated_2( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -233,9 +224,8 @@ class TestServiceHandlers: LOGGER.info('service_data = {:s}'.format(grpc_message_to_json_string(service_data))) def test_service_delete_loc( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name @@ -243,9 +233,8 @@ class TestServiceHandlers: service_client.DeleteService(ServiceId(**service_id)) def test_cleanup_environment( - self, service_id, service_descriptor, service_endpoint_ids, service_config_rules, service_constraints, - service_constraints_location, service_constraints_location_new, - contexts, topologies, devices, links, + self, contexts, topologies, devices, links, service_id, service_descriptor, service_endpoint_ids, + service_config_rules, service_constraints, service_constraints_location, service_constraints_location_new, context_client : ContextClient, # pylint: disable=redefined-outer-name device_client : DeviceClient, # pylint: disable=redefined-outer-name service_client : ServiceClient): # pylint: disable=redefined-outer-name diff --git a/src/tests/benchmark/automation/tests/Objects.py b/src/tests/benchmark/automation/tests/Objects.py index 8558d1fe7af84f1e312bc44eb458a3624ed694ae..a364abdc9d5dadec25e44e497f36db0c90e98e0b 100644 --- a/src/tests/benchmark/automation/tests/Objects.py +++ b/src/tests/benchmark/automation/tests/Objects.py @@ -18,7 +18,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_connect_rules, json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, json_device_id, json_device_packetrouter_disabled, json_device_tapi_disabled) -from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id +from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_descriptor, json_endpoint_id from common.tools.object_factory.Link import json_link, json_link_id from common.tools.object_factory.Topology import json_topology, json_topology_id from common.proto.kpi_sample_types_pb2 import KpiSampleType @@ -40,7 +40,8 @@ PACKET_PORT_SAMPLE_TYPES = [ ] # ----- Devices -------------------------------------------------------------------------------------------------------- -DEVICE_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_ENDPOINT_DEFS) # ----- Object Collections --------------------------------------------------------------------------------------------- diff --git a/src/tests/ecoc22/tests/Tools.py b/src/tests/ecoc22/tests/Tools.py index 26a3eda7101907f63fc51bc042bd59dee463d7d9..ea83d06bbe19c05d8f1932c03fd595ae760cc83f 100644 --- a/src/tests/ecoc22/tests/Tools.py +++ b/src/tests/ecoc22/tests/Tools.py @@ -16,16 +16,18 @@ from typing import Dict, List, Tuple from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id from common.tools.object_factory.Link import json_link, json_link_id -def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]]): +def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Dict]]): return [ - json_endpoint_id(device_id, ep_uuid, topology_id=None) - for ep_uuid, _, _ in endpoint_descriptors + json_endpoint_id(device_id, ep_data['uuid'], topology_id=None) + for ep_data in endpoint_descriptors ] -def json_endpoints(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]]): +def json_endpoints(device_id : Dict, endpoint_descriptors : List[Dict]]): return [ - json_endpoint(device_id, ep_uuid, ep_type, topology_id=None, kpi_sample_types=ep_sample_types) - for ep_uuid, ep_type, ep_sample_types in endpoint_descriptors + json_endpoint( + device_id, ep_data['uuid'], ep_data['type'], topology_id=None, + kpi_sample_types=ep_data['sample_types']) + for ep_data in endpoint_descriptors ] def get_link_uuid(a_endpoint_id : Dict, z_endpoint_id : Dict) -> str: diff --git a/src/tests/ecoc22/tests/old_code/Objects_BigNet.py b/src/tests/ecoc22/tests/old_code/Objects_BigNet.py index fb96914678e646840400e5270892b82428c428ee..f52d4fa2bde90ef0cc4bf7fad01625e782d2b086 100644 --- a/src/tests/ecoc22/tests/old_code/Objects_BigNet.py +++ b/src/tests/ecoc22/tests/old_code/Objects_BigNet.py @@ -17,6 +17,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_datacenter_disabled, json_device_emulated_packet_router_disabled, json_device_id) +from common.tools.object_factory.EndPoint import json_endpoint_descriptor from common.tools.object_factory.Topology import json_topology, json_topology_id from .Tools import compose_bearer, compose_service_endpoint_id, json_endpoint_ids, link @@ -32,7 +33,7 @@ TOPOLOGY = json_topology(DEFAULT_TOPOLOGY_NAME, context_id=CONTEXT_ID) # ----- Customer Equipment (CE) Devices -------------------------------------------------------------------------------- DEVICE_CE1_UUID = 'CE1' -DEVICE_CE1_ENDPOINT_DEFS = [('1/1', 'copper', [])] +DEVICE_CE1_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper')] DEVICE_CE1_ID = json_device_id(DEVICE_CE1_UUID) DEVICE_CE1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_CE1_ID, DEVICE_CE1_ENDPOINT_DEFS) DEVICE_CE1 = json_device_emulated_packet_router_disabled(DEVICE_CE1_UUID) @@ -40,7 +41,7 @@ ENDPOINT_ID_CE1_1_1 = DEVICE_CE1_ENDPOINT_IDS[0] DEVICE_CE1_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_CE1_ENDPOINT_DEFS) DEVICE_CE2_UUID = 'CE2' -DEVICE_CE2_ENDPOINT_DEFS = [('1/1', 'copper', [])] +DEVICE_CE2_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper')] DEVICE_CE2_ID = json_device_id(DEVICE_CE2_UUID) DEVICE_CE2_ENDPOINT_IDS = json_endpoint_ids(DEVICE_CE2_ID, DEVICE_CE2_ENDPOINT_DEFS) DEVICE_CE2 = json_device_emulated_packet_router_disabled(DEVICE_CE2_UUID) @@ -48,7 +49,7 @@ ENDPOINT_ID_CE2_1_1 = DEVICE_CE2_ENDPOINT_IDS[0] DEVICE_CE2_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_CE2_ENDPOINT_DEFS) DEVICE_CE3_UUID = 'CE3' -DEVICE_CE3_ENDPOINT_DEFS = [('1/1', 'copper', [])] +DEVICE_CE3_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper')] DEVICE_CE3_ID = json_device_id(DEVICE_CE3_UUID) DEVICE_CE3_ENDPOINT_IDS = json_endpoint_ids(DEVICE_CE3_ID, DEVICE_CE3_ENDPOINT_DEFS) DEVICE_CE3 = json_device_emulated_packet_router_disabled(DEVICE_CE3_UUID) @@ -56,7 +57,7 @@ ENDPOINT_ID_CE3_1_1 = DEVICE_CE3_ENDPOINT_IDS[0] DEVICE_CE3_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_CE3_ENDPOINT_DEFS) DEVICE_CE4_UUID = 'CE4' -DEVICE_CE4_ENDPOINT_DEFS = [('1/1', 'copper', [])] +DEVICE_CE4_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper')] DEVICE_CE4_ID = json_device_id(DEVICE_CE4_UUID) DEVICE_CE4_ENDPOINT_IDS = json_endpoint_ids(DEVICE_CE4_ID, DEVICE_CE4_ENDPOINT_DEFS) DEVICE_CE4 = json_device_emulated_packet_router_disabled(DEVICE_CE4_UUID) @@ -65,8 +66,9 @@ DEVICE_CE4_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_CE4_ENDPOIN # ----- Provider Equipment (PE) Devices -------------------------------------------------------------------------------- DEVICE_PE1_UUID = 'PE1' -DEVICE_PE1_ENDPOINT_DEFS = [('1/1', 'copper', []), - ('2/1', 'copper', []), ('2/2', 'copper', [])] +DEVICE_PE1_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper'), + json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper')] DEVICE_PE1_ID = json_device_id(DEVICE_PE1_UUID) DEVICE_PE1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_PE1_ID, DEVICE_PE1_ENDPOINT_DEFS) DEVICE_PE1 = json_device_emulated_packet_router_disabled(DEVICE_PE1_UUID) @@ -76,8 +78,9 @@ ENDPOINT_ID_PE1_2_2 = DEVICE_PE1_ENDPOINT_IDS[2] DEVICE_PE1_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_PE1_ENDPOINT_DEFS) DEVICE_PE2_UUID = 'PE2' -DEVICE_PE2_ENDPOINT_DEFS = [('1/1', 'copper', []), - ('2/1', 'copper', []), ('2/2', 'copper', [])] +DEVICE_PE2_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper'), + json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper')] DEVICE_PE2_ID = json_device_id(DEVICE_PE2_UUID) DEVICE_PE2_ENDPOINT_IDS = json_endpoint_ids(DEVICE_PE2_ID, DEVICE_PE2_ENDPOINT_DEFS) DEVICE_PE2 = json_device_emulated_packet_router_disabled(DEVICE_PE2_UUID) @@ -87,8 +90,9 @@ ENDPOINT_ID_PE2_2_2 = DEVICE_PE2_ENDPOINT_IDS[2] DEVICE_PE2_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_PE2_ENDPOINT_DEFS) DEVICE_PE3_UUID = 'PE3' -DEVICE_PE3_ENDPOINT_DEFS = [('1/1', 'copper', []), - ('2/1', 'copper', []), ('2/2', 'copper', [])] +DEVICE_PE3_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper'), + json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper')] DEVICE_PE3_ID = json_device_id(DEVICE_PE3_UUID) DEVICE_PE3_ENDPOINT_IDS = json_endpoint_ids(DEVICE_PE3_ID, DEVICE_PE3_ENDPOINT_DEFS) DEVICE_PE3 = json_device_emulated_packet_router_disabled(DEVICE_PE3_UUID) @@ -98,8 +102,9 @@ ENDPOINT_ID_PE3_2_2 = DEVICE_PE3_ENDPOINT_IDS[2] DEVICE_PE3_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_PE3_ENDPOINT_DEFS) DEVICE_PE4_UUID = 'PE4' -DEVICE_PE4_ENDPOINT_DEFS = [('1/1', 'copper', []), - ('2/1', 'copper', []), ('2/2', 'copper', [])] +DEVICE_PE4_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper'), + json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper')] DEVICE_PE4_ID = json_device_id(DEVICE_PE4_UUID) DEVICE_PE4_ENDPOINT_IDS = json_endpoint_ids(DEVICE_PE4_ID, DEVICE_PE4_ENDPOINT_DEFS) DEVICE_PE4 = json_device_emulated_packet_router_disabled(DEVICE_PE4_UUID) @@ -110,8 +115,11 @@ DEVICE_PE4_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_PE4_ENDPOIN # ----- BackBone (BB) Devices ------------------------------------------------------------------------------------------ DEVICE_BB1_UUID = 'BB1' -DEVICE_BB1_ENDPOINT_DEFS = [('1/1', 'copper', []), ('1/2', 'copper', []), - ('2/1', 'copper', []), ('2/2', 'copper', []), ('2/3', 'copper', [])] +DEVICE_BB1_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper'), + json_endpoint_descriptor('1/2', 'copper'), + json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper'), + json_endpoint_descriptor('2/3', 'copper')] DEVICE_BB1_ID = json_device_id(DEVICE_BB1_UUID) DEVICE_BB1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_BB1_ID, DEVICE_BB1_ENDPOINT_DEFS) DEVICE_BB1 = json_device_emulated_packet_router_disabled(DEVICE_BB1_UUID) @@ -123,8 +131,11 @@ ENDPOINT_ID_BB1_2_3 = DEVICE_BB1_ENDPOINT_IDS[4] DEVICE_BB1_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_BB1_ENDPOINT_DEFS) DEVICE_BB2_UUID = 'BB2' -DEVICE_BB2_ENDPOINT_DEFS = [('1/1', 'copper', []), ('1/2', 'copper', []), - ('2/1', 'copper', []), ('2/2', 'copper', []), ('2/3', 'copper', [])] +DEVICE_BB2_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper'), + json_endpoint_descriptor('1/2', 'copper'), + json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper'), + json_endpoint_descriptor('2/3', 'copper')] DEVICE_BB2_ID = json_device_id(DEVICE_BB2_UUID) DEVICE_BB2_ENDPOINT_IDS = json_endpoint_ids(DEVICE_BB2_ID, DEVICE_BB2_ENDPOINT_DEFS) DEVICE_BB2 = json_device_emulated_packet_router_disabled(DEVICE_BB2_UUID) @@ -136,7 +147,9 @@ ENDPOINT_ID_BB2_2_3 = DEVICE_BB2_ENDPOINT_IDS[4] DEVICE_BB2_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_BB2_ENDPOINT_DEFS) DEVICE_BB3_UUID = 'BB3' -DEVICE_BB3_ENDPOINT_DEFS = [('2/1', 'copper', []), ('2/2', 'copper', []), ('2/3', 'copper', [])] +DEVICE_BB3_ENDPOINT_DEFS = [json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper'), + json_endpoint_descriptor('2/3', 'copper')] DEVICE_BB3_ID = json_device_id(DEVICE_BB3_UUID) DEVICE_BB3_ENDPOINT_IDS = json_endpoint_ids(DEVICE_BB3_ID, DEVICE_BB3_ENDPOINT_DEFS) DEVICE_BB3 = json_device_emulated_packet_router_disabled(DEVICE_BB3_UUID) @@ -146,8 +159,11 @@ ENDPOINT_ID_BB3_2_3 = DEVICE_BB3_ENDPOINT_IDS[2] DEVICE_BB3_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_BB3_ENDPOINT_DEFS) DEVICE_BB4_UUID = 'BB4' -DEVICE_BB4_ENDPOINT_DEFS = [('1/1', 'copper', []), ('1/2', 'copper', []), - ('2/1', 'copper', []), ('2/2', 'copper', []), ('2/3', 'copper', [])] +DEVICE_BB4_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper'), + json_endpoint_descriptor('1/2', 'copper'), + json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper'), + json_endpoint_descriptor('2/3', 'copper')] DEVICE_BB4_ID = json_device_id(DEVICE_BB4_UUID) DEVICE_BB4_ENDPOINT_IDS = json_endpoint_ids(DEVICE_BB4_ID, DEVICE_BB4_ENDPOINT_DEFS) DEVICE_BB4 = json_device_emulated_packet_router_disabled(DEVICE_BB4_UUID) @@ -159,8 +175,11 @@ ENDPOINT_ID_BB4_2_3 = DEVICE_BB4_ENDPOINT_IDS[4] DEVICE_BB4_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_BB4_ENDPOINT_DEFS) DEVICE_BB5_UUID = 'BB5' -DEVICE_BB5_ENDPOINT_DEFS = [('1/1', 'copper', []), ('1/2', 'copper', []), - ('2/1', 'copper', []), ('2/2', 'copper', []), ('2/3', 'copper', [])] +DEVICE_BB5_ENDPOINT_DEFS = [json_endpoint_descriptor('1/1', 'copper'), + json_endpoint_descriptor('1/2', 'copper'), + json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper'), + json_endpoint_descriptor('2/3', 'copper')] DEVICE_BB5_ID = json_device_id(DEVICE_BB5_UUID) DEVICE_BB5_ENDPOINT_IDS = json_endpoint_ids(DEVICE_BB5_ID, DEVICE_BB5_ENDPOINT_DEFS) DEVICE_BB5 = json_device_emulated_packet_router_disabled(DEVICE_BB5_UUID) @@ -172,7 +191,9 @@ ENDPOINT_ID_BB5_2_3 = DEVICE_BB5_ENDPOINT_IDS[4] DEVICE_BB5_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_BB5_ENDPOINT_DEFS) DEVICE_BB6_UUID = 'BB6' -DEVICE_BB6_ENDPOINT_DEFS = [('2/1', 'copper', []), ('2/2', 'copper', []), ('2/3', 'copper', [])] +DEVICE_BB6_ENDPOINT_DEFS = [json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper'), + json_endpoint_descriptor('2/3', 'copper')] DEVICE_BB6_ID = json_device_id(DEVICE_BB6_UUID) DEVICE_BB6_ENDPOINT_IDS = json_endpoint_ids(DEVICE_BB6_ID, DEVICE_BB6_ENDPOINT_DEFS) DEVICE_BB6 = json_device_emulated_packet_router_disabled(DEVICE_BB6_UUID) @@ -182,8 +203,12 @@ ENDPOINT_ID_BB6_2_3 = DEVICE_BB6_ENDPOINT_IDS[2] DEVICE_BB6_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_BB6_ENDPOINT_DEFS) DEVICE_BB7_UUID = 'BB7' -DEVICE_BB7_ENDPOINT_DEFS = [('2/1', 'copper', []), ('2/2', 'copper', []), ('2/3', 'copper', []), ('2/4', 'copper', []), - ('2/5', 'copper', []), ('2/6', 'copper', [])] +DEVICE_BB7_ENDPOINT_DEFS = [json_endpoint_descriptor('2/1', 'copper'), + json_endpoint_descriptor('2/2', 'copper'), + json_endpoint_descriptor('2/3', 'copper'), + json_endpoint_descriptor('2/4', 'copper'), + json_endpoint_descriptor('2/5', 'copper'), + json_endpoint_descriptor('2/6', 'copper')] DEVICE_BB7_ID = json_device_id(DEVICE_BB7_UUID) DEVICE_BB7_ENDPOINT_IDS = json_endpoint_ids(DEVICE_BB7_ID, DEVICE_BB7_ENDPOINT_DEFS) DEVICE_BB7 = json_device_emulated_packet_router_disabled(DEVICE_BB7_UUID) diff --git a/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_OLS.py b/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_OLS.py index 522c25d6b272247093edb72cdbfa0ba515ed8cf8..ce16b9bf3241011f1326ae7bccb533c3201608fe 100644 --- a/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_OLS.py +++ b/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_OLS.py @@ -18,7 +18,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_datacenter_disabled, json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, json_device_id) -from common.tools.object_factory.EndPoint import json_endpoints +from common.tools.object_factory.EndPoint import json_endpoint_descriptor, json_endpoints from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Service import get_service_uuid, json_service_l3nm_planned from common.tools.object_factory.Topology import json_topology, json_topology_id @@ -30,7 +30,7 @@ ADD_CONNECT_RULES_TO_DEVICES = ADD_CONNECT_RULES_TO_DEVICES.upper() in {'T', 'TR def compose_router(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints @@ -39,7 +39,7 @@ def compose_router(device_uuid, endpoint_uuids, topology_id=None): def compose_ols(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'optical', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'optical') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints @@ -48,7 +48,7 @@ def compose_ols(device_uuid, endpoint_uuids, topology_id=None): def compose_datacenter(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints diff --git a/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_TN.py b/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_TN.py index c02f5d0c880f4bf570b7d14278c4bcbb1cffe72d..1de362a91665b73e36d4b3e9fd22ddfad184e50a 100644 --- a/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_TN.py +++ b/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_TN.py @@ -18,7 +18,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_datacenter_disabled, json_device_emulated_packet_router_disabled, json_device_id) -from common.tools.object_factory.EndPoint import json_endpoints +from common.tools.object_factory.EndPoint import json_endpoint_descriptor, json_endpoints from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Service import get_service_uuid, json_service_l3nm_planned from common.tools.object_factory.Topology import json_topology, json_topology_id @@ -30,7 +30,7 @@ ADD_CONNECT_RULES_TO_DEVICES = ADD_CONNECT_RULES_TO_DEVICES.upper() in {'T', 'TR def compose_router(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints @@ -39,7 +39,7 @@ def compose_router(device_uuid, endpoint_uuids, topology_id=None): def compose_datacenter(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints diff --git a/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_TN_OLS.py b/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_TN_OLS.py index 6c34ec01d4c9b466aa81d306078a0ab242a334ad..2a19b7f1880f31c3e315fcd4383bc36d1fd74385 100644 --- a/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_TN_OLS.py +++ b/src/tests/ecoc22/tests/old_code/Objects_DC_CSGW_TN_OLS.py @@ -18,7 +18,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_datacenter_disabled, json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, json_device_id) -from common.tools.object_factory.EndPoint import json_endpoints +from common.tools.object_factory.EndPoint import json_endpoint_descriptor, json_endpoints from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Service import get_service_uuid, json_service_l3nm_planned from common.tools.object_factory.Topology import json_topology, json_topology_id @@ -30,7 +30,7 @@ ADD_CONNECT_RULES_TO_DEVICES = ADD_CONNECT_RULES_TO_DEVICES.upper() in {'T', 'TR def compose_router(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints @@ -39,7 +39,7 @@ def compose_router(device_uuid, endpoint_uuids, topology_id=None): def compose_ols(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'optical', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'optical') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints @@ -48,7 +48,7 @@ def compose_ols(device_uuid, endpoint_uuids, topology_id=None): def compose_datacenter(device_uuid, endpoint_uuids, topology_id=None): device_id = json_device_id(device_uuid) - r_endpoints = [(endpoint_uuid, 'copper', []) for endpoint_uuid in endpoint_uuids] + r_endpoints = [json_endpoint_descriptor(endpoint_uuid, 'copper') for endpoint_uuid in endpoint_uuids] config_rules = json_device_emulated_connect_rules(r_endpoints) if ADD_CONNECT_RULES_TO_DEVICES else [] endpoints = json_endpoints(device_id, r_endpoints, topology_id=topology_id) j_endpoints = [] if ADD_CONNECT_RULES_TO_DEVICES else endpoints diff --git a/src/tests/oeccpsc22/tests/Objects_Domain_1.py b/src/tests/oeccpsc22/tests/Objects_Domain_1.py index 2f35aa76eea8f7adfc89011cbc4822daecbd1d14..19c9324d232ef927ec7ab6ce8419eb5cfa9743d4 100644 --- a/src/tests/oeccpsc22/tests/Objects_Domain_1.py +++ b/src/tests/oeccpsc22/tests/Objects_Domain_1.py @@ -16,6 +16,7 @@ from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_id) +from common.tools.object_factory.EndPoint import json_endpoint_descriptor from common.tools.object_factory.Link import json_link, json_link_id from common.tools.object_factory.Topology import json_topology, json_topology_id from .Tools import get_link_uuid, json_endpoint_ids @@ -32,12 +33,24 @@ D1_TOPOLOGY = json_topology(DEFAULT_TOPOLOGY_NAME, context_id=D1_CONTEXT_ID) # Assume all devices have the same architecture of endpoints D1_DEVICE_ENDPOINT_DEFS = [ # Trunk ports - ('1/1', '25Gbps', []), ('1/2', '25Gbps', []), ('1/3', '25Gbps', []), ('1/4', '25Gbps', []), + json_endpoint_descriptor('1/1', '25Gbps'), + json_endpoint_descriptor('1/2', '25Gbps'), + json_endpoint_descriptor('1/3', '25Gbps'), + json_endpoint_descriptor('1/4', '25Gbps'), + # Inter-domain ports - ('2/1', '100Gbps', []), ('2/2', '100Gbps', []), + json_endpoint_descriptor('2/1', '100Gbps'), + json_endpoint_descriptor('2/2', '100Gbps'), + # Access ports - ('3/1', '10Gbps', []), ('3/2', '10Gbps', []), ('3/3', '10Gbps', []), ('3/4', '10Gbps', []), - ('3/5', '10Gbps', []), ('3/6', '10Gbps', []), ('3/7', '10Gbps', []), ('3/8', '10Gbps', []), + json_endpoint_descriptor('3/1', '10Gbps'), + json_endpoint_descriptor('3/2', '10Gbps'), + json_endpoint_descriptor('3/3', '10Gbps'), + json_endpoint_descriptor('3/4', '10Gbps'), + json_endpoint_descriptor('3/5', '10Gbps'), + json_endpoint_descriptor('3/6', '10Gbps'), + json_endpoint_descriptor('3/7', '10Gbps'), + json_endpoint_descriptor('3/8', '10Gbps'), ] D1_DEVICE_D1R1_UUID = 'R1@D1' diff --git a/src/tests/oeccpsc22/tests/Objects_Domain_2.py b/src/tests/oeccpsc22/tests/Objects_Domain_2.py index 0e5065c3b6ec3e1d44a16f0ee8231aca28e2c2d1..7235290b3823eb6f99b7e8246071623381612a40 100644 --- a/src/tests/oeccpsc22/tests/Objects_Domain_2.py +++ b/src/tests/oeccpsc22/tests/Objects_Domain_2.py @@ -16,6 +16,7 @@ from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_id) +from common.tools.object_factory.EndPoint import json_endpoint_descriptor from common.tools.object_factory.Link import json_link, json_link_id from common.tools.object_factory.Topology import json_topology, json_topology_id from .Tools import get_link_uuid, json_endpoint_ids @@ -32,12 +33,24 @@ D2_TOPOLOGY = json_topology(DEFAULT_TOPOLOGY_NAME, context_id=D2_CONTEXT_ID) # Assume all devices have the same architecture of endpoints D2_DEVICE_ENDPOINT_DEFS = [ # Trunk ports - ('1/1', '25Gbps', []), ('1/2', '25Gbps', []), ('1/3', '25Gbps', []), ('1/4', '25Gbps', []), + json_endpoint_descriptor('1/1', '25Gbps'), + json_endpoint_descriptor('1/2', '25Gbps'), + json_endpoint_descriptor('1/3', '25Gbps'), + json_endpoint_descriptor('1/4', '25Gbps'), + # Inter-domain ports - ('2/1', '100Gbps', []), ('2/2', '100Gbps', []), + json_endpoint_descriptor('2/1', '100Gbps'), + json_endpoint_descriptor('2/2', '100Gbps'), + # Access ports - ('3/1', '10Gbps', []), ('3/2', '10Gbps', []), ('3/3', '10Gbps', []), ('3/4', '10Gbps', []), - ('3/5', '10Gbps', []), ('3/6', '10Gbps', []), ('3/7', '10Gbps', []), ('3/8', '10Gbps', []), + json_endpoint_descriptor('3/1', '10Gbps'), + json_endpoint_descriptor('3/2', '10Gbps'), + json_endpoint_descriptor('3/3', '10Gbps'), + json_endpoint_descriptor('3/4', '10Gbps'), + json_endpoint_descriptor('3/5', '10Gbps'), + json_endpoint_descriptor('3/6', '10Gbps'), + json_endpoint_descriptor('3/7', '10Gbps'), + json_endpoint_descriptor('3/8', '10Gbps'), ] D2_DEVICE_D2R1_UUID = 'R1@D2' diff --git a/src/tests/oeccpsc22/tests/Tools.py b/src/tests/oeccpsc22/tests/Tools.py index 30333b6f47b31bda76626545b78aaa3c96bff7c0..483090f8b8c0e1524bbdf98a5f3208b485c9ddaa 100644 --- a/src/tests/oeccpsc22/tests/Tools.py +++ b/src/tests/oeccpsc22/tests/Tools.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Dict, List, Tuple +from typing import Dict, List from common.tools.object_factory.EndPoint import json_endpoint_id -def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]]): +def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Dict]): return { device_id['device_uuid']['uuid']: { - ep_uuid: json_endpoint_id(device_id, ep_uuid, topology_id=None) - for ep_uuid, _, _ in endpoint_descriptors + ep_data['uuid']: json_endpoint_id(device_id, ep_data['uuid'], topology_id=None) + for ep_data in endpoint_descriptors } } diff --git a/src/tests/ofc22/tests/ObjectsXr.py b/src/tests/ofc22/tests/ObjectsXr.py index 9871a50b8181b53cfbb767be76a1a0978eaf1d27..89c6cb7ce56644332af046606b6b5774afeb4e42 100644 --- a/src/tests/ofc22/tests/ObjectsXr.py +++ b/src/tests/ofc22/tests/ObjectsXr.py @@ -18,7 +18,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_connect_rules, json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, json_device_id, json_device_packetrouter_disabled, json_device_tapi_disabled) -from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id +from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_descriptor, json_endpoint_id from common.tools.object_factory.Link import json_link, json_link_id from common.tools.object_factory.Topology import json_topology, json_topology_id from common.proto.kpi_sample_types_pb2 import KpiSampleType @@ -63,16 +63,17 @@ DEVICE_X1_PORT = 443 #USE_REAL_DEVICES = False # Uncomment to force to use emulated devices -def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]]): +def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Dict]): return [ - json_endpoint_id(device_id, ep_uuid, topology_id=None) - for ep_uuid, _, _ in endpoint_descriptors + json_endpoint_id(device_id, ep_data['uuid'], topology_id=None) + for ep_data in endpoint_descriptors ] -def json_endpoints(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]]): +def json_endpoints(device_id : Dict, endpoint_descriptors : List[Dict]): return [ - json_endpoint(device_id, ep_uuid, ep_type, topology_id=None, kpi_sample_types=ep_sample_types) - for ep_uuid, ep_type, ep_sample_types in endpoint_descriptors + json_endpoint( + device_id, ep_data['uuid'], ep_data['type'], topology_id=None, kpi_sample_types=ep_data['sample_types']) + for ep_data in endpoint_descriptors ] def get_link_uuid(a_device_id : Dict, a_endpoint_id : Dict, z_device_id : Dict, z_endpoint_id : Dict) -> str: @@ -88,7 +89,8 @@ if not USE_REAL_DEVICES: DEVICE_R1_UUID = 'R1-EMU' DEVICE_R1_TIMEOUT = 120 -DEVICE_R1_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_R1_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_R1_ID = json_device_id(DEVICE_R1_UUID) #DEVICE_R1_ENDPOINTS = json_endpoints(DEVICE_R1_ID, DEVICE_R1_ENDPOINT_DEFS) DEVICE_R1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R1_ID, DEVICE_R1_ENDPOINT_DEFS) @@ -103,7 +105,8 @@ DEVICE_R1_CONNECT_RULES = json_device_connect_rules(DEVICE_R1_ADDRESS, DEVICE_R1 DEVICE_R2_UUID = 'R2-EMU' -DEVICE_R2_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_R2_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_R2_ID = json_device_id(DEVICE_R2_UUID) #DEVICE_R2_ENDPOINTS = json_endpoints(DEVICE_R2_ID, DEVICE_R2_ENDPOINT_DEFS) DEVICE_R2_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R2_ID, DEVICE_R2_ENDPOINT_DEFS) @@ -115,7 +118,8 @@ DEVICE_R2_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_R2_ENDPOINT_ DEVICE_R3_UUID = 'R3-EMU' DEVICE_R3_TIMEOUT = 120 -DEVICE_R3_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_R3_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_R3_ID = json_device_id(DEVICE_R3_UUID) #DEVICE_R3_ENDPOINTS = json_endpoints(DEVICE_R3_ID, DEVICE_R3_ENDPOINT_DEFS) DEVICE_R3_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R3_ID, DEVICE_R3_ENDPOINT_DEFS) @@ -130,7 +134,8 @@ DEVICE_R3_CONNECT_RULES = json_device_connect_rules(DEVICE_R3_ADDRESS, DEVICE_R3 DEVICE_R4_UUID = 'R4-EMU' -DEVICE_R4_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_R4_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_R4_ID = json_device_id(DEVICE_R4_UUID) #DEVICE_R4_ENDPOINTS = json_endpoints(DEVICE_R4_ID, DEVICE_R4_ENDPOINT_DEFS) DEVICE_R4_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R4_ID, DEVICE_R4_ENDPOINT_DEFS) @@ -143,12 +148,12 @@ DEVICE_R4_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_R4_ENDPOINT_ DEVICE_X1_UUID = 'X1-XR-CONSTELLATION' DEVICE_X1_TIMEOUT = 120 DEVICE_X1_ENDPOINT_DEFS = [ - ('XR HUB 1|XR-T1', 'optical', []), - ('XR HUB 1|XR-T2', 'optical', []), - ('XR HUB 1|XR-T3', 'optical', []), - ('XR HUB 1|XR-T4', 'optical', []), - ('XR LEAF 1|XR-T1', 'optical', []), - ('XR LEAF 2|XR-T1', 'optical', []), + json_endpoint_descriptor('XR HUB 1|XR-T1', 'optical'), + json_endpoint_descriptor('XR HUB 1|XR-T2', 'optical'), + json_endpoint_descriptor('XR HUB 1|XR-T3', 'optical'), + json_endpoint_descriptor('XR HUB 1|XR-T4', 'optical'), + json_endpoint_descriptor('XR LEAF 1|XR-T1', 'optical'), + json_endpoint_descriptor('XR LEAF 2|XR-T1', 'optical'), ] DEVICE_X1_ID = json_device_id(DEVICE_X1_UUID) DEVICE_X1 = json_device_tapi_disabled(DEVICE_X1_UUID) diff --git a/src/tests/p4/tests/Objects.py b/src/tests/p4/tests/Objects.py index 9a9b230170fb492e94bac7cb19172f623daa3394..fcf618308a1e56a6e9e68205bdc0566408e26b65 100644 --- a/src/tests/p4/tests/Objects.py +++ b/src/tests/p4/tests/Objects.py @@ -25,6 +25,7 @@ from common.tools.object_factory.Service import ( from common.tools.object_factory.ConfigRule import ( json_config_rule_set, json_config_rule_delete) from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_ids, json_endpoints, json_endpoint_id +from common.tools.object_factory.EndPoint import json_endpoint_descriptor from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Topology import json_topology, json_topology_id from common.proto.kpi_sample_types_pb2 import KpiSampleType @@ -68,7 +69,10 @@ DEVICE_SW1_SW_VER = 'Stratum' DEVICE_SW1_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW1_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW1_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', []), ('3', 'port', []), ('4', 'port', [])] +DEVICE_SW1_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port'), + json_endpoint_descriptor('3', 'port'), + json_endpoint_descriptor('4', 'port')] DEVICE_SW1_ENDPOINTS = json_endpoints(DEVICE_SW1_ID, DEVICE_SW1_ENDPOINT_DEFS) DEVICE_SW1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW1_ID, DEVICE_SW1_ENDPOINT_DEFS) ENDPOINT_ID_SW1_1 = DEVICE_SW1_ENDPOINTS[0]['endpoint_id'] @@ -107,7 +111,8 @@ DEVICE_SW2_SW_VER = 'Stratum' DEVICE_SW2_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW2_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW2_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW2_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW2_ENDPOINTS = json_endpoints(DEVICE_SW2_ID, DEVICE_SW2_ENDPOINT_DEFS) DEVICE_SW2_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW2_ID, DEVICE_SW2_ENDPOINT_DEFS) ENDPOINT_ID_SW2_1 = DEVICE_SW2_ENDPOINTS[0]['endpoint_id'] @@ -144,7 +149,8 @@ DEVICE_SW3_SW_VER = 'Stratum' DEVICE_SW3_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW3_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW3_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW3_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW3_ENDPOINTS = json_endpoints(DEVICE_SW3_ID, DEVICE_SW3_ENDPOINT_DEFS) DEVICE_SW3_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW3_ID, DEVICE_SW3_ENDPOINT_DEFS) ENDPOINT_ID_SW3_1 = DEVICE_SW3_ENDPOINTS[0]['endpoint_id'] @@ -181,7 +187,8 @@ DEVICE_SW4_SW_VER = 'Stratum' DEVICE_SW4_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW4_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW4_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW4_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW4_ENDPOINTS = json_endpoints(DEVICE_SW4_ID, DEVICE_SW4_ENDPOINT_DEFS) DEVICE_SW4_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW4_ID, DEVICE_SW4_ENDPOINT_DEFS) ENDPOINT_ID_SW4_1 = DEVICE_SW4_ENDPOINTS[0]['endpoint_id'] @@ -218,7 +225,8 @@ DEVICE_SW5_SW_VER = 'Stratum' DEVICE_SW5_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW5_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW5_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW5_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW5_ENDPOINTS = json_endpoints(DEVICE_SW5_ID, DEVICE_SW5_ENDPOINT_DEFS) DEVICE_SW5_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW5_ID, DEVICE_SW5_ENDPOINT_DEFS) ENDPOINT_ID_SW5_1 = DEVICE_SW5_ENDPOINTS[0]['endpoint_id'] @@ -255,7 +263,8 @@ DEVICE_SW6_SW_VER = 'Stratum' DEVICE_SW6_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW6_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW6_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW6_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW6_ENDPOINTS = json_endpoints(DEVICE_SW6_ID, DEVICE_SW6_ENDPOINT_DEFS) DEVICE_SW6_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW6_ID, DEVICE_SW6_ENDPOINT_DEFS) ENDPOINT_ID_SW6_1 = DEVICE_SW6_ENDPOINTS[0]['endpoint_id'] @@ -292,7 +301,8 @@ DEVICE_SW7_SW_VER = 'Stratum' DEVICE_SW7_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW7_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW7_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW7_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW7_ENDPOINTS = json_endpoints(DEVICE_SW7_ID, DEVICE_SW7_ENDPOINT_DEFS) DEVICE_SW7_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW7_ID, DEVICE_SW7_ENDPOINT_DEFS) ENDPOINT_ID_SW7_1 = DEVICE_SW7_ENDPOINTS[0]['endpoint_id'] @@ -329,7 +339,10 @@ DEVICE_SW8_SW_VER = 'Stratum' DEVICE_SW8_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW8_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW8_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', []), ('3', 'port', []), ('4', 'port', [])] +DEVICE_SW8_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port'), + json_endpoint_descriptor('3', 'port'), + json_endpoint_descriptor('4', 'port')] DEVICE_SW8_ENDPOINTS = json_endpoints(DEVICE_SW8_ID, DEVICE_SW8_ENDPOINT_DEFS) DEVICE_SW8_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW8_ID, DEVICE_SW8_ENDPOINT_DEFS) ENDPOINT_ID_SW8_1 = DEVICE_SW8_ENDPOINTS[0]['endpoint_id'] diff --git a/src/tests/p4/tests/topologies/6switchObjects.py b/src/tests/p4/tests/topologies/6switchObjects.py index 29f01cd61aca58712cb0bc27b7f80c04b2f37d52..c5e4b616cdf3cfe0757514ac78f958837591a36c 100644 --- a/src/tests/p4/tests/topologies/6switchObjects.py +++ b/src/tests/p4/tests/topologies/6switchObjects.py @@ -25,6 +25,7 @@ from common.tools.object_factory.Service import ( from common.tools.object_factory.ConfigRule import ( json_config_rule_set, json_config_rule_delete) from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_ids, json_endpoints, json_endpoint_id +from common.tools.object_factory.EndPoint import json_endpoint_descriptor from common.tools.object_factory.Link import get_link_uuid, json_link, json_link_id from common.tools.object_factory.Topology import json_topology, json_topology_id from common.proto.kpi_sample_types_pb2 import KpiSampleType @@ -68,7 +69,9 @@ DEVICE_SW1_SW_VER = 'Stratum' DEVICE_SW1_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW1_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW1_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', []), ('3', 'port', [])] +DEVICE_SW1_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port'), + json_endpoint_descriptor('3', 'port')] DEVICE_SW1_ENDPOINTS = json_endpoints(DEVICE_SW1_ID, DEVICE_SW1_ENDPOINT_DEFS) DEVICE_SW1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW1_ID, DEVICE_SW1_ENDPOINT_DEFS) ENDPOINT_ID_SW1_1 = DEVICE_SW1_ENDPOINTS[0]['endpoint_id'] @@ -106,7 +109,8 @@ DEVICE_SW2_SW_VER = 'Stratum' DEVICE_SW2_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW2_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW2_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW2_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW2_ENDPOINTS = json_endpoints(DEVICE_SW2_ID, DEVICE_SW2_ENDPOINT_DEFS) DEVICE_SW2_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW2_ID, DEVICE_SW2_ENDPOINT_DEFS) ENDPOINT_ID_SW2_1 = DEVICE_SW2_ENDPOINTS[0]['endpoint_id'] @@ -143,7 +147,8 @@ DEVICE_SW3_SW_VER = 'Stratum' DEVICE_SW3_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW3_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW3_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW3_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW3_ENDPOINTS = json_endpoints(DEVICE_SW3_ID, DEVICE_SW3_ENDPOINT_DEFS) DEVICE_SW3_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW3_ID, DEVICE_SW3_ENDPOINT_DEFS) ENDPOINT_ID_SW3_1 = DEVICE_SW3_ENDPOINTS[0]['endpoint_id'] @@ -180,7 +185,8 @@ DEVICE_SW4_SW_VER = 'Stratum' DEVICE_SW4_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW4_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW4_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW4_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW4_ENDPOINTS = json_endpoints(DEVICE_SW4_ID, DEVICE_SW4_ENDPOINT_DEFS) DEVICE_SW4_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW4_ID, DEVICE_SW4_ENDPOINT_DEFS) ENDPOINT_ID_SW4_1 = DEVICE_SW4_ENDPOINTS[0]['endpoint_id'] @@ -217,7 +223,8 @@ DEVICE_SW5_SW_VER = 'Stratum' DEVICE_SW5_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW5_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW5_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', [])] +DEVICE_SW5_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port')] DEVICE_SW5_ENDPOINTS = json_endpoints(DEVICE_SW5_ID, DEVICE_SW5_ENDPOINT_DEFS) DEVICE_SW5_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW5_ID, DEVICE_SW5_ENDPOINT_DEFS) ENDPOINT_ID_SW5_1 = DEVICE_SW5_ENDPOINTS[0]['endpoint_id'] @@ -254,7 +261,9 @@ DEVICE_SW6_SW_VER = 'Stratum' DEVICE_SW6_BIN_PATH = '/root/p4/bmv2.json' DEVICE_SW6_INFO_PATH = '/root/p4/p4info.txt' -DEVICE_SW6_ENDPOINT_DEFS = [('1', 'port', []), ('2', 'port', []), ('3', 'port', [])] +DEVICE_SW6_ENDPOINT_DEFS = [json_endpoint_descriptor('1', 'port'), + json_endpoint_descriptor('2', 'port'), + json_endpoint_descriptor('3', 'port')] DEVICE_SW6_ENDPOINTS = json_endpoints(DEVICE_SW6_ID, DEVICE_SW6_ENDPOINT_DEFS) DEVICE_SW6_ENDPOINT_IDS = json_endpoint_ids(DEVICE_SW6_ID, DEVICE_SW6_ENDPOINT_DEFS) ENDPOINT_ID_SW6_1 = DEVICE_SW6_ENDPOINTS[0]['endpoint_id'] diff --git a/src/tests/scenario2/old_tests/tests/Objects.py b/src/tests/scenario2/old_tests/tests/Objects.py index 7eea0f4c3262793e9ba00ae80c66cc5b1ed0b8dc..43df127495d16b8494ff74cdf7dea64e44b072e1 100644 --- a/src/tests/scenario2/old_tests/tests/Objects.py +++ b/src/tests/scenario2/old_tests/tests/Objects.py @@ -18,7 +18,7 @@ from common.tools.object_factory.Context import json_context, json_context_id from common.tools.object_factory.Device import ( json_device_connect_rules, json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_emulated_tapi_disabled, json_device_id, json_device_packetrouter_disabled, json_device_tapi_disabled) -from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_id +from common.tools.object_factory.EndPoint import json_endpoint, json_endpoint_descriptor, json_endpoint_id from common.tools.object_factory.Link import json_link, json_link_id from common.tools.object_factory.Topology import json_topology, json_topology_id from common.proto.kpi_sample_types_pb2 import KpiSampleType @@ -63,16 +63,18 @@ except ImportError: #USE_REAL_DEVICES = False # Uncomment to force to use emulated devices -def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]]): +def json_endpoint_ids(device_id : Dict, endpoint_descriptors : List[Dict]]): return [ - json_endpoint_id(device_id, ep_uuid, topology_id=None) - for ep_uuid, _, _ in endpoint_descriptors + json_endpoint_id(device_id, ep_data['uuid'], topology_id=None) + for ep_data in endpoint_descriptors ] -def json_endpoints(device_id : Dict, endpoint_descriptors : List[Tuple[str, str, List[int]]]): +def json_endpoints(device_id : Dict, endpoint_descriptors : List[Dict]]): return [ - json_endpoint(device_id, ep_uuid, ep_type, topology_id=None, kpi_sample_types=ep_sample_types) - for ep_uuid, ep_type, ep_sample_types in endpoint_descriptors + json_endpoint( + device_id, ep_data['uuid'], ep_data['type'], topology_id=None, + kpi_sample_types=ep_data['sample_types']) + for ep_data in endpoint_descriptors ] def get_link_uuid(a_device_id : Dict, a_endpoint_id : Dict, z_device_id : Dict, z_endpoint_id : Dict) -> str: @@ -88,7 +90,8 @@ if not USE_REAL_DEVICES: DEVICE_R1_UUID = 'R1-EMU' DEVICE_R1_TIMEOUT = 120 -DEVICE_R1_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_R1_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_R1_ID = json_device_id(DEVICE_R1_UUID) #DEVICE_R1_ENDPOINTS = json_endpoints(DEVICE_R1_ID, DEVICE_R1_ENDPOINT_DEFS) DEVICE_R1_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R1_ID, DEVICE_R1_ENDPOINT_DEFS) @@ -103,7 +106,8 @@ DEVICE_R1_CONNECT_RULES = json_device_connect_rules(DEVICE_R1_ADDRESS, DEVICE_R1 DEVICE_R2_UUID = 'R2-EMU' -DEVICE_R2_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_R2_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_R2_ID = json_device_id(DEVICE_R2_UUID) #DEVICE_R2_ENDPOINTS = json_endpoints(DEVICE_R2_ID, DEVICE_R2_ENDPOINT_DEFS) DEVICE_R2_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R2_ID, DEVICE_R2_ENDPOINT_DEFS) @@ -115,7 +119,8 @@ DEVICE_R2_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_R2_ENDPOINT_ DEVICE_R3_UUID = 'R3-EMU' DEVICE_R3_TIMEOUT = 120 -DEVICE_R3_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_R3_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_R3_ID = json_device_id(DEVICE_R3_UUID) #DEVICE_R3_ENDPOINTS = json_endpoints(DEVICE_R3_ID, DEVICE_R3_ENDPOINT_DEFS) DEVICE_R3_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R3_ID, DEVICE_R3_ENDPOINT_DEFS) @@ -130,7 +135,8 @@ DEVICE_R3_CONNECT_RULES = json_device_connect_rules(DEVICE_R3_ADDRESS, DEVICE_R3 DEVICE_R4_UUID = 'R4-EMU' -DEVICE_R4_ENDPOINT_DEFS = [('13/0/0', 'optical', []), ('13/1/2', 'copper', PACKET_PORT_SAMPLE_TYPES)] +DEVICE_R4_ENDPOINT_DEFS = [json_endpoint_descriptor('13/0/0', 'optical'), + json_endpoint_descriptor('13/1/2', 'copper', sample_types=PACKET_PORT_SAMPLE_TYPES)] DEVICE_R4_ID = json_device_id(DEVICE_R4_UUID) #DEVICE_R4_ENDPOINTS = json_endpoints(DEVICE_R4_ID, DEVICE_R4_ENDPOINT_DEFS) DEVICE_R4_ENDPOINT_IDS = json_endpoint_ids(DEVICE_R4_ID, DEVICE_R4_ENDPOINT_DEFS) @@ -143,10 +149,10 @@ DEVICE_R4_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_R4_ENDPOINT_ DEVICE_O1_UUID = 'O1-OLS' DEVICE_O1_TIMEOUT = 120 DEVICE_O1_ENDPOINT_DEFS = [ - ('aade6001-f00b-5e2f-a357-6a0a9d3de870', 'optical', []), # node_1_port_13 - ('eb287d83-f05e-53ec-ab5a-adf6bd2b5418', 'optical', []), # node_2_port_13 - ('0ef74f99-1acc-57bd-ab9d-4b958b06c513', 'optical', []), # node_3_port_13 - ('50296d99-58cc-5ce7-82f5-fc8ee4eec2ec', 'optical', []), # node_4_port_13 + json_endpoint_descriptor('aade6001-f00b-5e2f-a357-6a0a9d3de870', 'optical', endpoint_name='node_1_port_13'), + json_endpoint_descriptor('eb287d83-f05e-53ec-ab5a-adf6bd2b5418', 'optical', endpoint_name='node_2_port_13'), + json_endpoint_descriptor('0ef74f99-1acc-57bd-ab9d-4b958b06c513', 'optical', endpoint_name='node_3_port_13'), + json_endpoint_descriptor('50296d99-58cc-5ce7-82f5-fc8ee4eec2ec', 'optical', endpoint_name='node_4_port_13'), ] DEVICE_O1_ID = json_device_id(DEVICE_O1_UUID) DEVICE_O1 = json_device_tapi_disabled(DEVICE_O1_UUID)