diff --git a/src/common/DeviceTypes.py b/src/common/DeviceTypes.py index bf871a2d5afa6a73f1c9dd39431c64a7f31bbd7e..4d67ff6615227f0d9e7d82e2f69b39d72011a75c 100644 --- a/src/common/DeviceTypes.py +++ b/src/common/DeviceTypes.py @@ -15,12 +15,14 @@ from enum import Enum class DeviceTypeEnum(Enum): - EMULATED_OPTICAL_LINE_SYSTEM = 'emu-optical-line-system' - EMULATED_PACKET_ROUTER = 'emu-packet-router' - MICROVAWE_RADIO_SYSTEM = 'microwave-radio-system' - OPTICAL_ROADM = 'optical-roadm' - OPTICAL_TRANDPONDER = 'optical-trandponder' - OPTICAL_LINE_SYSTEM = 'optical-line-system' - PACKET_ROUTER = 'packet-router' - PACKET_SWITCH = 'packet-switch' - P4_SWITCH = 'p4-switch' + EMULATED_DATACENTER = 'emu-datacenter' + EMULATED_OPEN_LINE_SYSTEM = 'emu-open-line-system' + EMULATED_PACKET_ROUTER = 'emu-packet-router' + DATACENTER = 'datacenter' + MICROVAWE_RADIO_SYSTEM = 'microwave-radio-system' + OPTICAL_ROADM = 'optical-roadm' + OPTICAL_TRANDPONDER = 'optical-trandponder' + OPEN_LINE_SYSTEM = 'open-line-system' + PACKET_ROUTER = 'packet-router' + PACKET_SWITCH = 'packet-switch' + P4_SWITCH = 'p4-switch' diff --git a/src/common/tools/object_factory/Device.py b/src/common/tools/object_factory/Device.py index d69272346be6b2c1823c33f291a06410c3c9ec33..4a590134dd7b455c92b62fc5e4aa9fece0f874b4 100644 --- a/src/common/tools/object_factory/Device.py +++ b/src/common/tools/object_factory/Device.py @@ -21,7 +21,7 @@ from common.tools.object_factory.ConfigRule import json_config_rule_set DEVICE_DISABLED = DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_DISABLED DEVICE_EMUDC_TYPE = DeviceTypeEnum.EMULATED_DATACENTER.value -DEVICE_EMUOLS_TYPE = DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM.value +DEVICE_EMUOLS_TYPE = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value DEVICE_EMUPR_TYPE = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value DEVICE_EMU_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_UNDEFINED] DEVICE_EMU_ADDRESS = '127.0.0.1' @@ -30,7 +30,7 @@ DEVICE_EMU_PORT = '0' DEVICE_PR_TYPE = DeviceTypeEnum.PACKET_ROUTER.value DEVICE_PR_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG] -DEVICE_TAPI_TYPE = DeviceTypeEnum.OPTICAL_LINE_SYSTEM.value +DEVICE_TAPI_TYPE = DeviceTypeEnum.OPEN_LINE_SYSTEM.value DEVICE_TAPI_DRIVERS = [DeviceDriverEnum.DEVICEDRIVER_TRANSPORT_API] # check which enum type and value assign to microwave device diff --git a/src/context/service/database/ConstraintModel.py b/src/context/service/database/ConstraintModel.py index a35ec250d8a62a8a2534e9f27ddecac801db6eff..17a9b52e980bf0eec44ea58edfb35eac5471d016 100644 --- a/src/context/service/database/ConstraintModel.py +++ b/src/context/service/database/ConstraintModel.py @@ -54,24 +54,13 @@ class ConstraintCustomModel(Model): # pylint: disable=abstract-method def dump(self) -> Dict: # pylint: disable=arguments-differ return {'custom': {'constraint_type': self.constraint_type, 'constraint_value': self.constraint_value}} -Union_ConstraintEndpoint = Union[ - 'ConstraintEndpointLocationGpsPositionModel', 'ConstraintEndpointLocationRegionModel', - 'ConstraintEndpointPriorityModel' -] -def dump_endpoint_id(endpoint_constraint : Union_ConstraintEndpoint): - db_endpoints_pks = list(endpoint_constraint.references(EndPointModel)) - num_endpoints = len(db_endpoints_pks) - if num_endpoints != 1: - raise Exception('Wrong number({:d}) of associated Endpoints with constraint'.format(num_endpoints)) - db_endpoint = EndPointModel(endpoint_constraint.database, db_endpoints_pks[0]) - return db_endpoint.dump_id() - class ConstraintEndpointLocationRegionModel(Model): # pylint: disable=abstract-method endpoint_fk = ForeignKeyField(EndPointModel) region = StringField(required=True, allow_empty=False) def dump(self) -> Dict: # pylint: disable=arguments-differ - return {'endpoint_location': {'endpoint_id': dump_endpoint_id(self), 'region': self.region}} + json_endpoint_id = EndPointModel(self.database, self.endpoint_fk).dump_id() + return {'endpoint_location': {'endpoint_id': json_endpoint_id, 'location': {'region': self.region}}} class ConstraintEndpointLocationGpsPositionModel(Model): # pylint: disable=abstract-method endpoint_fk = ForeignKeyField(EndPointModel) @@ -80,14 +69,16 @@ class ConstraintEndpointLocationGpsPositionModel(Model): # pylint: disable=abstr def dump(self) -> Dict: # pylint: disable=arguments-differ gps_position = {'latitude': self.latitude, 'longitude': self.longitude} - return {'endpoint_location': {'endpoint_id': dump_endpoint_id(self), 'gps_position': gps_position}} + json_endpoint_id = EndPointModel(self.database, self.endpoint_fk).dump_id() + return {'endpoint_location': {'endpoint_id': json_endpoint_id, 'location': {'gps_position': gps_position}}} class ConstraintEndpointPriorityModel(Model): # pylint: disable=abstract-method endpoint_fk = ForeignKeyField(EndPointModel) - priority = FloatField(required=True) + priority = IntegerField(required=True, min_value=0) def dump(self) -> Dict: # pylint: disable=arguments-differ - return {'endpoint_priority': {'endpoint_id': dump_endpoint_id(self), 'priority': self.priority}} + json_endpoint_id = EndPointModel(self.database, self.endpoint_fk).dump_id() + return {'endpoint_priority': {'endpoint_id': json_endpoint_id, 'priority': self.priority}} class ConstraintSlaAvailabilityModel(Model): # pylint: disable=abstract-method num_disjoint_paths = IntegerField(required=True, min_value=1) diff --git a/src/context/service/grpc_server/ContextServiceServicerImpl.py b/src/context/service/grpc_server/ContextServiceServicerImpl.py index 4c8f957ecb70765cbd36032fca7bfacc27f9b5ae..d21868d3d5faaa945c9a4d8c5a8f5b336cdafae7 100644 --- a/src/context/service/grpc_server/ContextServiceServicerImpl.py +++ b/src/context/service/grpc_server/ContextServiceServicerImpl.py @@ -319,7 +319,7 @@ class ContextServiceServicerImpl(ContextServiceServicer): result : Tuple[EndPointModel, bool] = update_or_create_object( self.database, EndPointModel, str_endpoint_key, endpoint_attributes) - db_endpoint, endpoint_updated = result + db_endpoint, endpoint_updated = result # pylint: disable=unused-variable set_kpi_sample_types(self.database, db_endpoint, endpoint.kpi_sample_types) diff --git a/src/context/tests/Objects.py b/src/context/tests/Objects.py index da63ed6ea8329bc77e897c1f88d6ba04e8ffc79b..140cbff686eaf5b430f23ee987a9335ecb04c0f5 100644 --- a/src/context/tests/Objects.py +++ b/src/context/tests/Objects.py @@ -129,8 +129,8 @@ SERVICE_R1_R2_EPIDS = [ json_endpoint_id(DEVICE_R2_ID, 'EP100', topology_id=TOPOLOGY_ID), ] SERVICE_R1_R2_CONST = [ - json_constraint_custom('latency_ms', '15.2'), - json_constraint_custom('jitter_us', '1.2'), + json_constraint_custom('latency[ms]', '15.2'), + json_constraint_custom('jitter[us]', '1.2'), ] SERVICE_R1_R2_RULES = [ json_config_rule_set('svc/rsrc1/value', 'value7'), @@ -149,8 +149,8 @@ SERVICE_R1_R3_EPIDS = [ json_endpoint_id(DEVICE_R3_ID, 'EP100', topology_id=TOPOLOGY_ID), ] SERVICE_R1_R3_CONST = [ - json_constraint_custom('latency_ms', '5.8'), - json_constraint_custom('jitter_us', '0.1'), + json_constraint_custom('latency[ms]', '5.8'), + json_constraint_custom('jitter[us]', '0.1'), ] SERVICE_R1_R3_RULES = [ json_config_rule_set('svc/rsrc1/value', 'value7'), @@ -169,8 +169,8 @@ SERVICE_R2_R3_EPIDS = [ json_endpoint_id(DEVICE_R3_ID, 'EP100', topology_id=TOPOLOGY_ID), ] SERVICE_R2_R3_CONST = [ - json_constraint_custom('latency_ms', '23.1'), - json_constraint_custom('jitter_us', '3.4'), + json_constraint_custom('latency[ms]', '23.1'), + json_constraint_custom('jitter[us]', '3.4'), ] SERVICE_R2_R3_RULES = [ json_config_rule_set('svc/rsrc1/value', 'value7'), diff --git a/src/device/service/database/ContextModel.py b/src/device/service/database/ContextModel.py index 0ca13269c52d02ea663e10be986ab28d12d8f144..a609e1ba9189f5359064e6628cba6c08d353770e 100644 --- a/src/device/service/database/ContextModel.py +++ b/src/device/service/database/ContextModel.py @@ -24,15 +24,15 @@ class ContextModel(Model): pk = PrimaryKeyField() context_uuid = StringField(required=True, allow_empty=False) -# def dump_id(self) -> Dict: -# return {'context_uuid': {'uuid': self.context_uuid}} + def dump_id(self) -> Dict: + return {'context_uuid': {'uuid': self.context_uuid}} -# def dump_topology_ids(self) -> List[Dict]: -# from .TopologyModel import TopologyModel # pylint: disable=import-outside-toplevel -# db_topology_pks = self.references(TopologyModel) -# return [TopologyModel(self.database, pk).dump_id() for pk,_ in db_topology_pks] + def dump_topology_ids(self) -> List[Dict]: + from .TopologyModel import TopologyModel # pylint: disable=import-outside-toplevel + db_topology_pks = self.references(TopologyModel) + return [TopologyModel(self.database, pk).dump_id() for pk,_ in db_topology_pks] -# def dump(self, include_topologies=True) -> Dict: # pylint: disable=arguments-differ -# result = {'context_id': self.dump_id()} -# if include_topologies: result['topology_ids'] = self.dump_topology_ids() -# return result + def dump(self, include_topologies=False) -> Dict: # pylint: disable=arguments-differ + result = {'context_id': self.dump_id()} + if include_topologies: result['topology_ids'] = self.dump_topology_ids() + return result diff --git a/src/device/service/database/TopologyModel.py b/src/device/service/database/TopologyModel.py index a099c8adfd8bb64d94c8326c90094f39d7fe9b6b..f9e9c0b1a26fdf8faca7e1cbe0a64b582bdd4d5d 100644 --- a/src/device/service/database/TopologyModel.py +++ b/src/device/service/database/TopologyModel.py @@ -27,13 +27,13 @@ class TopologyModel(Model): context_fk = ForeignKeyField(ContextModel) topology_uuid = StringField(required=True, allow_empty=False) -# def dump_id(self) -> Dict: -# context_id = ContextModel(self.database, self.context_fk).dump_id() -# return { -# 'context_id': context_id, -# 'topology_uuid': {'uuid': self.topology_uuid}, -# } + def dump_id(self) -> Dict: + context_id = ContextModel(self.database, self.context_fk).dump_id() + return { + 'context_id': context_id, + 'topology_uuid': {'uuid': self.topology_uuid}, + } -# def dump(self) -> Dict: -# result = {'topology_id': self.dump_id()} -# return result + def dump(self) -> Dict: + result = {'topology_id': self.dump_id()} + return result diff --git a/src/device/service/drivers/__init__.py b/src/device/service/drivers/__init__.py index 40912f50b98f1d5fc9555d87a4855a12ab8e0c07..6188a385da391af74272eee3be1e467c15f97702 100644 --- a/src/device/service/drivers/__init__.py +++ b/src/device/service/drivers/__init__.py @@ -29,7 +29,7 @@ DRIVERS = [ { # Emulated OLS/Packet Router, specifying Undefined/OpenConfig/TAPI Driver => use EmulatedDriver FilterFieldEnum.DEVICE_TYPE: [ - DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM, + DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM, DeviceTypeEnum.EMULATED_PACKET_ROUTER, ], FilterFieldEnum.DRIVER : [ @@ -49,7 +49,7 @@ DRIVERS = [ (TransportApiDriver, [ { # Real OLS, specifying TAPI Driver => use TransportApiDriver - FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPTICAL_LINE_SYSTEM, + FilterFieldEnum.DEVICE_TYPE: DeviceTypeEnum.OPEN_LINE_SYSTEM, FilterFieldEnum.DRIVER : ORM_DeviceDriverEnum.TRANSPORT_API, } ]), diff --git a/src/tests/oeccpsc22/tests/test_functional_create_interdomain_slice.py b/src/tests/oeccpsc22/tests/test_functional_create_interdomain_slice.py index e6f6ccbc96152eb7e3a33317293261e28c89d713..b31e868741a7996494d1f7763a3f7e237ca216a1 100644 --- a/src/tests/oeccpsc22/tests/test_functional_create_interdomain_slice.py +++ b/src/tests/oeccpsc22/tests/test_functional_create_interdomain_slice.py @@ -27,7 +27,7 @@ LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value -DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM.value +DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value @pytest.fixture(scope='session') diff --git a/src/tests/oeccpsc22/tests/test_functional_delete_interdomain_slice.py b/src/tests/oeccpsc22/tests/test_functional_delete_interdomain_slice.py index 40a954868620564aef7d60c5ec0023ea0a32337b..45296d107bcdb14472f05c677ba0c75113fd94cc 100644 --- a/src/tests/oeccpsc22/tests/test_functional_delete_interdomain_slice.py +++ b/src/tests/oeccpsc22/tests/test_functional_delete_interdomain_slice.py @@ -27,7 +27,7 @@ LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value -DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM.value +DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value @pytest.fixture(scope='session') diff --git a/src/tests/ofc22/descriptors_emulated.json b/src/tests/ofc22/descriptors_emulated.json index eb22506238e03a161f0e2b8aaeadf5fd31cf547b..6beb1427ebb22f22bcb24b73c173d33d4352cdb4 100644 --- a/src/tests/ofc22/descriptors_emulated.json +++ b/src/tests/ofc22/descriptors_emulated.json @@ -64,7 +64,7 @@ }, { "device_id": {"device_uuid": {"uuid": "O1-OLS"}}, - "device_type": "emu-optical-line-system", + "device_type": "emu-open-line-system", "device_config": {"config_rules": [ {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "127.0.0.1"}}, {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "0"}}, diff --git a/src/tests/ofc22/tests/test_functional_create_service.py b/src/tests/ofc22/tests/test_functional_create_service.py index f3389fdbfce4e9262ffddbad876bb86f9b300551..31572e7ba0854a394607fb705aa52b9caeb08085 100644 --- a/src/tests/ofc22/tests/test_functional_create_service.py +++ b/src/tests/ofc22/tests/test_functional_create_service.py @@ -32,7 +32,7 @@ LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value -DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM.value +DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value @pytest.fixture(scope='session') diff --git a/src/tests/ofc22/tests/test_functional_delete_service.py b/src/tests/ofc22/tests/test_functional_delete_service.py index 51e91a5967e1696fa2fdfe7dd06d2efb46642248..b4bc621d294245a6286e77483e3074f95533fd4e 100644 --- a/src/tests/ofc22/tests/test_functional_delete_service.py +++ b/src/tests/ofc22/tests/test_functional_delete_service.py @@ -33,7 +33,7 @@ LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value -DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPTICAL_LINE_SYSTEM.value +DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value @pytest.fixture(scope='session') diff --git a/src/webui/service/static/topology_icons/Acknowledgements.txt b/src/webui/service/static/topology_icons/Acknowledgements.txt index c646efdec0d79148f9bd066116d6ca3985f6f909..1ddf1e1d03d8dbc8695e1a7850f5c911cae7e28e 100644 --- a/src/webui/service/static/topology_icons/Acknowledgements.txt +++ b/src/webui/service/static/topology_icons/Acknowledgements.txt @@ -8,5 +8,5 @@ https://symbols.getvecta.com/stencil_241/45_atm-switch.6a7362c1df.png => emu-pac https://symbols.getvecta.com/stencil_240/204_router.7b208c1133.png => packet-router.png https://symbols.getvecta.com/stencil_241/224_router.be30fb87e7.png => emu-packet-router.png -https://symbols.getvecta.com/stencil_240/269_virtual-layer-switch.ed10fdede6.png => optical-line-system.png -https://symbols.getvecta.com/stencil_241/281_virtual-layer-switch.29420aff2f.png => emu-optical-line-system.png +https://symbols.getvecta.com/stencil_240/269_virtual-layer-switch.ed10fdede6.png => open-line-system.png +https://symbols.getvecta.com/stencil_241/281_virtual-layer-switch.29420aff2f.png => emu-open-line-system.png diff --git a/src/webui/service/static/topology_icons/emu-optical-line-system.png b/src/webui/service/static/topology_icons/emu-open-line-system.png similarity index 100% rename from src/webui/service/static/topology_icons/emu-optical-line-system.png rename to src/webui/service/static/topology_icons/emu-open-line-system.png diff --git a/src/webui/service/static/topology_icons/optical-line-system.png b/src/webui/service/static/topology_icons/open-line-system.png similarity index 100% rename from src/webui/service/static/topology_icons/optical-line-system.png rename to src/webui/service/static/topology_icons/open-line-system.png