Loading src/common/tests/MockServicerImpl_Context.py +25 −1 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,7 @@ import grpc, json, logging import grpc, json, logging from typing import Any, Dict, Iterator, List, Set from typing import Any, Dict, Iterator, List, Set from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.proto.context_pb2 import ( from common.proto.context_pb2 import ( Connection, ConnectionEvent, ConnectionId, ConnectionIdList, ConnectionList, Connection, ConnectionEvent, ConnectionId, ConnectionIdList, ConnectionList, Context, ContextEvent, ContextId, ContextIdList, ContextList, Context, ContextEvent, ContextId, ContextIdList, ContextList, Loading @@ -22,7 +23,7 @@ from common.proto.context_pb2 import ( Link, LinkEvent, LinkId, LinkIdList, LinkList, Link, LinkEvent, LinkId, LinkIdList, LinkList, Service, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Service, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, 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.proto.context_pb2_grpc import ContextServiceServicer from common.tests.MockMessageBroker import ( from common.tests.MockMessageBroker import ( TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_DEVICE, TOPIC_LINK, TOPIC_SERVICE, TOPIC_SLICE, TOPIC_TOPOLOGY, TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_DEVICE, TOPIC_LINK, TOPIC_SERVICE, TOPIC_SLICE, TOPIC_TOPOLOGY, Loading Loading @@ -162,6 +163,29 @@ class MockServicerImpl_Context(ContextServiceServicer): LOGGER.info('[GetTopology] reply={:s}'.format(grpc_message_to_json_string(reply))) LOGGER.info('[GetTopology] reply={:s}'.format(grpc_message_to_json_string(reply))) return 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: def SetTopology(self, request: Topology, context : grpc.ServicerContext) -> TopologyId: LOGGER.info('[SetTopology] request={:s}'.format(grpc_message_to_json_string(request))) 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)) container_name = 'topology[{:s}]'.format(str(request.topology_id.context_id.context_uuid.uuid)) Loading src/common/tools/object_factory/Device.py +4 −9 Original line number Original line Diff line number Diff line Loading @@ -136,7 +136,7 @@ def json_device_tfs_disabled( device_uuid, DEVICE_TFS_TYPE, DEVICE_DISABLED, name=name, endpoints=endpoints, config_rules=config_rules, device_uuid, DEVICE_TFS_TYPE, DEVICE_DISABLED, name=name, endpoints=endpoints, config_rules=config_rules, drivers=drivers) 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 [ return [ json_config_rule_set('_connect/address', address), json_config_rule_set('_connect/address', address), json_config_rule_set('_connect/port', port), json_config_rule_set('_connect/port', port), Loading @@ -144,12 +144,7 @@ def json_device_connect_rules(address : str, port : int, settings : Dict = {}): ] ] def json_device_emulated_connect_rules( def json_device_emulated_connect_rules( endpoint_descriptors : List[Tuple[str, str, List[int]]], address : str = DEVICE_EMU_ADDRESS, endpoint_descriptors : List[Dict], address : str = DEVICE_EMU_ADDRESS, port : int = DEVICE_EMU_PORT port : int = DEVICE_EMU_PORT ) -> List[Dict]: ): settings = {'endpoints': endpoint_descriptors} settings = {'endpoints': [ {'uuid': endpoint_uuid, 'type': endpoint_type, 'sample_types': sample_types} for endpoint_uuid,endpoint_type,sample_types in endpoint_descriptors ]} return json_device_connect_rules(address, port, settings=settings) return json_device_connect_rules(address, port, settings=settings) src/common/tools/object_factory/EndPoint.py +25 −10 Original line number Original line Diff line number Diff line Loading @@ -13,7 +13,20 @@ # limitations under the License. # limitations under the License. import copy 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): 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}} result = {'device_id': copy.deepcopy(device_id), 'endpoint_uuid': {'uuid': endpoint_uuid}} Loading @@ -21,11 +34,11 @@ def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Option return result return result def json_endpoint_ids( 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 [ return [ json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id) json_endpoint_id(device_id, endpoint_data['uuid'], topology_id=topology_id) for endpoint_uuid, _, _ in endpoint_descriptors for endpoint_data in endpoint_descriptors ] ] def json_endpoint( def json_endpoint( Loading @@ -37,16 +50,18 @@ def json_endpoint( 'endpoint_id': json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id), 'endpoint_id': json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id), 'endpoint_type': endpoint_type, 'endpoint_type': endpoint_type, } } if len(kpi_sample_types) > 0: result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types) if kpi_sample_types is not None and len(kpi_sample_types) > 0: if location: result['endpoint_location'] = copy.deepcopy(location) result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types) if location is not None: result['endpoint_location'] = copy.deepcopy(location) return result return result def json_endpoints( 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 [ return [ json_endpoint( json_endpoint( device_id, endpoint_uuid, endpoint_type, topology_id=topology_id, device_id, endpoint_data['uuid'], endpoint_data['type'], topology_id=topology_id, kpi_sample_types=endpoint_sample_types) kpi_sample_types=endpoint_data.get('sample_types'), location=endpoint_data.get('location')) for endpoint_uuid, endpoint_type, endpoint_sample_types in endpoint_descriptors for endpoint_data in endpoint_descriptors ] ] src/device/tests/Device_Emulated.py +9 −2 Original line number Original line Diff line number Diff line Loading @@ -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.ConfigRule import json_config_rule_delete, json_config_rule_set from common.tools.object_factory.Device import ( from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_id) 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 from device.tests.CommonObjects import PACKET_PORT_SAMPLE_TYPES DEVICE_EMU_UUID = 'R1-EMU' DEVICE_EMU_UUID = 'R1-EMU' DEVICE_EMU_ID = json_device_id(DEVICE_EMU_UUID) DEVICE_EMU_ID = json_device_id(DEVICE_EMU_UUID) DEVICE_EMU = json_device_emulated_packet_router_disabled(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_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) DEVICE_EMU_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_EMU_EP_DESCS) RSRC_EP = '/endpoints/endpoint[{:s}]' RSRC_EP = '/endpoints/endpoint[{:s}]' Loading @@ -30,7 +34,10 @@ RSRC_SUBIF = RSRC_EP + '/subinterfaces/subinterface[{:d}]' RSRC_ADDRIPV4 = RSRC_SUBIF + '/ipv4/address[{:s}]' RSRC_ADDRIPV4 = RSRC_SUBIF + '/ipv4/address[{:s}]' DEVICE_EMU_ENDPOINTS_COOKED = [] 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)) endpoint_resource_key = RSRC_EP.format(str(endpoint_uuid)) sample_types = {} sample_types = {} for endpoint_sample_type in endpoint_sample_types: for endpoint_sample_type in endpoint_sample_types: Loading src/dlt/connector/tests/Objects.py +5 −2 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,7 @@ from common.tools.object_factory.Context import json_context, json_context_id 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.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.Link import compose_link from common.tools.object_factory.Topology import json_topology, json_topology_id from common.tools.object_factory.Topology import json_topology, json_topology_id Loading @@ -22,7 +22,10 @@ def compose_device( device_uuid, endpoint_uuids, endpoint_type='copper', endpoint_topology_id=None, endpoint_sample_types=[] device_uuid, endpoint_uuids, endpoint_type='copper', endpoint_topology_id=None, endpoint_sample_types=[] ): ): device_id = json_device_id(device_uuid) 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) endpoints = json_endpoints(device_id, endpoints, topology_id=endpoint_topology_id) device = json_device_emulated_packet_router_disabled(device_uuid, endpoints=endpoints) device = json_device_emulated_packet_router_disabled(device_uuid, endpoints=endpoints) return device_id, endpoints, device return device_id, endpoints, device Loading Loading
src/common/tests/MockServicerImpl_Context.py +25 −1 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,7 @@ import grpc, json, logging import grpc, json, logging from typing import Any, Dict, Iterator, List, Set from typing import Any, Dict, Iterator, List, Set from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.proto.context_pb2 import ( from common.proto.context_pb2 import ( Connection, ConnectionEvent, ConnectionId, ConnectionIdList, ConnectionList, Connection, ConnectionEvent, ConnectionId, ConnectionIdList, ConnectionList, Context, ContextEvent, ContextId, ContextIdList, ContextList, Context, ContextEvent, ContextId, ContextIdList, ContextList, Loading @@ -22,7 +23,7 @@ from common.proto.context_pb2 import ( Link, LinkEvent, LinkId, LinkIdList, LinkList, Link, LinkEvent, LinkId, LinkIdList, LinkList, Service, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Service, ServiceEvent, ServiceFilter, ServiceId, ServiceIdList, ServiceList, Slice, SliceEvent, SliceFilter, SliceId, SliceIdList, SliceList, 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.proto.context_pb2_grpc import ContextServiceServicer from common.tests.MockMessageBroker import ( from common.tests.MockMessageBroker import ( TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_DEVICE, TOPIC_LINK, TOPIC_SERVICE, TOPIC_SLICE, TOPIC_TOPOLOGY, TOPIC_CONNECTION, TOPIC_CONTEXT, TOPIC_DEVICE, TOPIC_LINK, TOPIC_SERVICE, TOPIC_SLICE, TOPIC_TOPOLOGY, Loading Loading @@ -162,6 +163,29 @@ class MockServicerImpl_Context(ContextServiceServicer): LOGGER.info('[GetTopology] reply={:s}'.format(grpc_message_to_json_string(reply))) LOGGER.info('[GetTopology] reply={:s}'.format(grpc_message_to_json_string(reply))) return 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: def SetTopology(self, request: Topology, context : grpc.ServicerContext) -> TopologyId: LOGGER.info('[SetTopology] request={:s}'.format(grpc_message_to_json_string(request))) 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)) container_name = 'topology[{:s}]'.format(str(request.topology_id.context_id.context_uuid.uuid)) Loading
src/common/tools/object_factory/Device.py +4 −9 Original line number Original line Diff line number Diff line Loading @@ -136,7 +136,7 @@ def json_device_tfs_disabled( device_uuid, DEVICE_TFS_TYPE, DEVICE_DISABLED, name=name, endpoints=endpoints, config_rules=config_rules, device_uuid, DEVICE_TFS_TYPE, DEVICE_DISABLED, name=name, endpoints=endpoints, config_rules=config_rules, drivers=drivers) 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 [ return [ json_config_rule_set('_connect/address', address), json_config_rule_set('_connect/address', address), json_config_rule_set('_connect/port', port), json_config_rule_set('_connect/port', port), Loading @@ -144,12 +144,7 @@ def json_device_connect_rules(address : str, port : int, settings : Dict = {}): ] ] def json_device_emulated_connect_rules( def json_device_emulated_connect_rules( endpoint_descriptors : List[Tuple[str, str, List[int]]], address : str = DEVICE_EMU_ADDRESS, endpoint_descriptors : List[Dict], address : str = DEVICE_EMU_ADDRESS, port : int = DEVICE_EMU_PORT port : int = DEVICE_EMU_PORT ) -> List[Dict]: ): settings = {'endpoints': endpoint_descriptors} settings = {'endpoints': [ {'uuid': endpoint_uuid, 'type': endpoint_type, 'sample_types': sample_types} for endpoint_uuid,endpoint_type,sample_types in endpoint_descriptors ]} return json_device_connect_rules(address, port, settings=settings) return json_device_connect_rules(address, port, settings=settings)
src/common/tools/object_factory/EndPoint.py +25 −10 Original line number Original line Diff line number Diff line Loading @@ -13,7 +13,20 @@ # limitations under the License. # limitations under the License. import copy 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): 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}} result = {'device_id': copy.deepcopy(device_id), 'endpoint_uuid': {'uuid': endpoint_uuid}} Loading @@ -21,11 +34,11 @@ def json_endpoint_id(device_id : Dict, endpoint_uuid : str, topology_id : Option return result return result def json_endpoint_ids( 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 [ return [ json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id) json_endpoint_id(device_id, endpoint_data['uuid'], topology_id=topology_id) for endpoint_uuid, _, _ in endpoint_descriptors for endpoint_data in endpoint_descriptors ] ] def json_endpoint( def json_endpoint( Loading @@ -37,16 +50,18 @@ def json_endpoint( 'endpoint_id': json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id), 'endpoint_id': json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id), 'endpoint_type': endpoint_type, 'endpoint_type': endpoint_type, } } if len(kpi_sample_types) > 0: result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types) if kpi_sample_types is not None and len(kpi_sample_types) > 0: if location: result['endpoint_location'] = copy.deepcopy(location) result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types) if location is not None: result['endpoint_location'] = copy.deepcopy(location) return result return result def json_endpoints( 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 [ return [ json_endpoint( json_endpoint( device_id, endpoint_uuid, endpoint_type, topology_id=topology_id, device_id, endpoint_data['uuid'], endpoint_data['type'], topology_id=topology_id, kpi_sample_types=endpoint_sample_types) kpi_sample_types=endpoint_data.get('sample_types'), location=endpoint_data.get('location')) for endpoint_uuid, endpoint_type, endpoint_sample_types in endpoint_descriptors for endpoint_data in endpoint_descriptors ] ]
src/device/tests/Device_Emulated.py +9 −2 Original line number Original line Diff line number Diff line Loading @@ -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.ConfigRule import json_config_rule_delete, json_config_rule_set from common.tools.object_factory.Device import ( from common.tools.object_factory.Device import ( json_device_emulated_connect_rules, json_device_emulated_packet_router_disabled, json_device_id) 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 from device.tests.CommonObjects import PACKET_PORT_SAMPLE_TYPES DEVICE_EMU_UUID = 'R1-EMU' DEVICE_EMU_UUID = 'R1-EMU' DEVICE_EMU_ID = json_device_id(DEVICE_EMU_UUID) DEVICE_EMU_ID = json_device_id(DEVICE_EMU_UUID) DEVICE_EMU = json_device_emulated_packet_router_disabled(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_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) DEVICE_EMU_CONNECT_RULES = json_device_emulated_connect_rules(DEVICE_EMU_EP_DESCS) RSRC_EP = '/endpoints/endpoint[{:s}]' RSRC_EP = '/endpoints/endpoint[{:s}]' Loading @@ -30,7 +34,10 @@ RSRC_SUBIF = RSRC_EP + '/subinterfaces/subinterface[{:d}]' RSRC_ADDRIPV4 = RSRC_SUBIF + '/ipv4/address[{:s}]' RSRC_ADDRIPV4 = RSRC_SUBIF + '/ipv4/address[{:s}]' DEVICE_EMU_ENDPOINTS_COOKED = [] 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)) endpoint_resource_key = RSRC_EP.format(str(endpoint_uuid)) sample_types = {} sample_types = {} for endpoint_sample_type in endpoint_sample_types: for endpoint_sample_type in endpoint_sample_types: Loading
src/dlt/connector/tests/Objects.py +5 −2 Original line number Original line Diff line number Diff line Loading @@ -14,7 +14,7 @@ from common.tools.object_factory.Context import json_context, json_context_id 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.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.Link import compose_link from common.tools.object_factory.Topology import json_topology, json_topology_id from common.tools.object_factory.Topology import json_topology, json_topology_id Loading @@ -22,7 +22,10 @@ def compose_device( device_uuid, endpoint_uuids, endpoint_type='copper', endpoint_topology_id=None, endpoint_sample_types=[] device_uuid, endpoint_uuids, endpoint_type='copper', endpoint_topology_id=None, endpoint_sample_types=[] ): ): device_id = json_device_id(device_uuid) 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) endpoints = json_endpoints(device_id, endpoints, topology_id=endpoint_topology_id) device = json_device_emulated_packet_router_disabled(device_uuid, endpoints=endpoints) device = json_device_emulated_packet_router_disabled(device_uuid, endpoints=endpoints) return device_id, endpoints, device return device_id, endpoints, device Loading