diff --git a/src/context/service/database/models/enums/LinkType.py b/src/context/service/database/models/enums/LinkType.py deleted file mode 100644 index 1ac1a547fe085c722a97bbdabeae663fdcffdc37..0000000000000000000000000000000000000000 --- a/src/context/service/database/models/enums/LinkType.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (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 enum, functools -from common.proto.context_pb2 import LinkTypeEnum -from ._GrpcToEnum import grpc_to_enum - -# IMPORTANT: Entries of enum class ORM_DeviceDriverEnum should be named as in -# the proto files removing the prefixes. For example, proto item -# DeviceDriverEnum.DEVICEDRIVER_OPENCONFIG should be included as -# OPENCONFIG. If item name does not match, automatic mapping of -# proto enums to database enums will fail. -class ORM_LinkTypeEnum(enum.Enum): - UNKNOWN = LinkTypeEnum.LINKTYPE_UNKNOWN - COPPER = LinkTypeEnum.LINKTYPE_COPPER - VIRTUAL_COPPER = LinkTypeEnum.LINKTYPE_VIRTUAL_COPPER - OPTICAL = LinkTypeEnum.LINKTYPE_OPTICAL - VIRTUAL_OPTICAL = LinkTypeEnum.LINKTYPE_VIRTUAL_OPTICAL - -grpc_to_enum__link_type_enum = functools.partial( - grpc_to_enum, LinkTypeEnum, ORM_LinkTypeEnum) diff --git a/src/nbi/service/rest_server/nbi_plugins/tfs_api/Resources.py b/src/nbi/service/rest_server/nbi_plugins/tfs_api/Resources.py index 0b99fba5042aea6d45f38b43ea9d74165425f113..eaa21352527a95591829e6bad87de8ecef1df521 100644 --- a/src/nbi/service/rest_server/nbi_plugins/tfs_api/Resources.py +++ b/src/nbi/service/rest_server/nbi_plugins/tfs_api/Resources.py @@ -177,11 +177,6 @@ class Topology(_Resource): def delete(self, context_uuid : str, topology_uuid : str): return format_grpc_to_json(self.context_client.RemoveTopology(grpc_topology_id(context_uuid, topology_uuid))) -class TopologyDetails(_Resource): - def get(self, context_uuid : str, topology_uuid : str): - return format_grpc_to_json(self.context_client.GetTopologyDetails(grpc_topology_id( - context_uuid, topology_uuid))) - class ServiceIds(_Resource): def get(self, context_uuid : str): return format_grpc_to_json(self.context_client.ListServiceIds(grpc_context_id(context_uuid))) @@ -300,31 +295,21 @@ class Links(_Resource): ] class Link(_Resource): - @staticmethod - def _virtual_link(link): - virtual_types = {LinkTypeEnum.LINKTYPE_VIRTUAL_COPPER, LinkTypeEnum.LINKTYPE_VIRTUAL_OPTICAL} - if link.link_type in virtual_types: - return True - return False - - def get(self, link_uuid : str): return format_grpc_to_json(self.context_client.GetLink(grpc_link_id(link_uuid))) def put(self, link_uuid : str): link_json = request.get_json() link = grpc_link(link_json) + virtual_types = {LinkTypeEnum.LINKTYPE_VIRTUAL_COPPER, LinkTypeEnum.LINKTYPE_VIRTUAL_OPTICAL} if link_uuid != link.link_id.link_uuid.uuid: raise BadRequest('Mismatching link_uuid') - elif self._virtual_link(link): + elif link.link_type in virtual_types: link = grpc_link(link_json) return format_grpc_to_json(self.vntmanager_client.SetVirtualLink(link)) - return format_grpc_to_json(self.context_client.SetLink(link)) + return format_grpc_to_json(self.context_client.SetLink(grpc_link(link))) def delete(self, link_uuid : str): - link = self.context_client.GetLink(grpc_link_id(link_uuid)) - if self._virtual_link(link): - format_grpc_to_json(self.vntmanager_client.RemoveVirtualLink(grpc_link_id(link_uuid))) return format_grpc_to_json(self.context_client.RemoveLink(grpc_link_id(link_uuid))) class ConnectionIds(_Resource): diff --git a/src/nbi/service/rest_server/nbi_plugins/tfs_api/__init__.py b/src/nbi/service/rest_server/nbi_plugins/tfs_api/__init__.py index 944644d5746be099f365b0d1c15d1486bbab9dbb..304a326481f4713f4b2e4f860fd2d42c25ae656b 100644 --- a/src/nbi/service/rest_server/nbi_plugins/tfs_api/__init__.py +++ b/src/nbi/service/rest_server/nbi_plugins/tfs_api/__init__.py @@ -22,7 +22,7 @@ from .Resources import ( PolicyRule, PolicyRuleIds, PolicyRules, Service, ServiceIds, Services, Slice, SliceIds, Slices, - Topologies, Topology, TopologyIds, TopologyDetails + Topologies, Topology, TopologyIds ) URL_PREFIX = '/tfs-api' @@ -30,39 +30,38 @@ URL_PREFIX = '/tfs-api' # Use 'path' type since some identifiers might contain char '/' and Flask is unable to recognize them in 'string' type. RESOURCES = [ # (endpoint_name, resource_class, resource_url) - ('api.context_ids', ContextIds, '/context_ids'), - ('api.contexts', Contexts, '/contexts'), - ('api.dummy_contexts', DummyContexts, '/dummy_contexts'), - ('api.context', Context, '/context/<path:context_uuid>'), + ('api.context_ids', ContextIds, '/context_ids'), + ('api.contexts', Contexts, '/contexts'), + ('api.dummy_contexts', DummyContexts, '/dummy_contexts'), + ('api.context', Context, '/context/<path:context_uuid>'), - ('api.topology_ids', TopologyIds, '/context/<path:context_uuid>/topology_ids'), - ('api.topologies', Topologies, '/context/<path:context_uuid>/topologies'), - ('api.topology', Topology, '/context/<path:context_uuid>/topology/<path:topology_uuid>'), - ('api.topology_details', TopologyDetails, '/context/<path:context_uuid>/topology_details/<path:topology_uuid>'), + ('api.topology_ids', TopologyIds, '/context/<path:context_uuid>/topology_ids'), + ('api.topologies', Topologies, '/context/<path:context_uuid>/topologies'), + ('api.topology', Topology, '/context/<path:context_uuid>/topology/<path:topology_uuid>'), - ('api.service_ids', ServiceIds, '/context/<path:context_uuid>/service_ids'), - ('api.services', Services, '/context/<path:context_uuid>/services'), - ('api.service', Service, '/context/<path:context_uuid>/service/<path:service_uuid>'), + ('api.service_ids', ServiceIds, '/context/<path:context_uuid>/service_ids'), + ('api.services', Services, '/context/<path:context_uuid>/services'), + ('api.service', Service, '/context/<path:context_uuid>/service/<path:service_uuid>'), - ('api.slice_ids', SliceIds, '/context/<path:context_uuid>/slice_ids'), - ('api.slices', Slices, '/context/<path:context_uuid>/slices'), - ('api.slice', Slice, '/context/<path:context_uuid>/slice/<path:slice_uuid>'), + ('api.slice_ids', SliceIds, '/context/<path:context_uuid>/slice_ids'), + ('api.slices', Slices, '/context/<path:context_uuid>/slices'), + ('api.slice', Slice, '/context/<path:context_uuid>/slice/<path:slice_uuid>'), - ('api.device_ids', DeviceIds, '/device_ids'), - ('api.devices', Devices, '/devices'), - ('api.device', Device, '/device/<path:device_uuid>'), + ('api.device_ids', DeviceIds, '/device_ids'), + ('api.devices', Devices, '/devices'), + ('api.device', Device, '/device/<path:device_uuid>'), - ('api.link_ids', LinkIds, '/link_ids'), - ('api.links', Links, '/links'), - ('api.link', Link, '/link/<path:link_uuid>'), + ('api.link_ids', LinkIds, '/link_ids'), + ('api.links', Links, '/links'), + ('api.link', Link, '/link/<path:link_uuid>'), - ('api.connection_ids', ConnectionIds, '/context/<path:context_uuid>/service/<path:service_uuid>/connection_ids'), - ('api.connections', Connections, '/context/<path:context_uuid>/service/<path:service_uuid>/connections'), - ('api.connection', Connection, '/connection/<path:connection_uuid>'), + ('api.connection_ids', ConnectionIds, '/context/<path:context_uuid>/service/<path:service_uuid>/connection_ids'), + ('api.connections', Connections, '/context/<path:context_uuid>/service/<path:service_uuid>/connections'), + ('api.connection', Connection, '/connection/<path:connection_uuid>'), - ('api.policyrule_ids', PolicyRuleIds, '/policyrule_ids'), - ('api.policyrules', PolicyRules, '/policyrules'), - ('api.policyrule', PolicyRule, '/policyrule/<path:policyrule_uuid>'), + ('api.policyrule_ids', PolicyRuleIds, '/policyrule_ids'), + ('api.policyrules', PolicyRules, '/policyrules'), + ('api.policyrule', PolicyRule, '/policyrule/<path:policyrule_uuid>'), ] def register_tfs_api(rest_server : RestServer):