Loading src/compute/service/__main__.py +3 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from .ComputeService import ComputeService from .rest_server.RestServer import RestServer from .rest_server.nbi_plugins.debug_api import register_debug_api from .rest_server.nbi_plugins.ietf_l2vpn import register_ietf_l2vpn from .rest_server.nbi_plugins.ietf_network_slice import register_ietf_nss terminate = threading.Event() LOGGER = None Loading Loading @@ -58,8 +59,9 @@ def main(): grpc_service.start() rest_server = RestServer() register_ietf_l2vpn(rest_server) # Registering L2VPN entrypoint register_ietf_nss(rest_server) # Registering NSS entrypoint register_debug_api(rest_server) register_ietf_l2vpn(rest_server) rest_server.start() # Wait for Ctrl+C or termination signal Loading src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Service.py +2 −2 Original line number Diff line number Diff line Loading @@ -20,8 +20,8 @@ from common.proto.context_pb2 import SliceStatusEnum from common.tools.context_queries.Slice import get_slice from context.client.ContextClient import ContextClient from slice.client.SliceClient import SliceClient from .tools.Authentication import HTTP_AUTH from .tools.HttpStatusCodes import HTTP_GATEWAYTIMEOUT, HTTP_NOCONTENT, HTTP_OK, HTTP_SERVERERROR from ..tools.Authentication import HTTP_AUTH from ..tools.HttpStatusCodes import HTTP_GATEWAYTIMEOUT, HTTP_NOCONTENT, HTTP_OK, HTTP_SERVERERROR LOGGER = logging.getLogger(__name__) Loading src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Services.py +3 −3 Original line number Diff line number Diff line Loading @@ -22,9 +22,9 @@ from common.Constants import DEFAULT_CONTEXT_NAME from common.proto.context_pb2 import SliceStatusEnum, Slice from slice.client.SliceClient import SliceClient from .schemas.vpn_service import SCHEMA_VPN_SERVICE from .tools.Authentication import HTTP_AUTH from .tools.HttpStatusCodes import HTTP_CREATED, HTTP_SERVERERROR from .tools.Validator import validate_message from compute.service.rest_server.nbi_plugins.tools.HttpStatusCodes import HTTP_CREATED, HTTP_SERVERERROR from compute.service.rest_server.nbi_plugins.tools.Validator import validate_message from compute.service.rest_server.nbi_plugins.tools.Authentication import HTTP_AUTH LOGGER = logging.getLogger(__name__) Loading src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py +4 −5 Original line number Diff line number Diff line Loading @@ -30,11 +30,10 @@ from common.tools.grpc.Tools import grpc_message_to_json_string from context.client.ContextClient import ContextClient from slice.client.SliceClient import SliceClient from .schemas.site_network_access import SCHEMA_SITE_NETWORK_ACCESS from .tools.Authentication import HTTP_AUTH from .tools.HttpStatusCodes import HTTP_NOCONTENT, HTTP_SERVERERROR from .tools.Validator import validate_message from .Constants import ( BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_BGP_AS, DEFAULT_BGP_ROUTE_TARGET, DEFAULT_MTU) from compute.service.rest_server.nbi_plugins.tools.Authentication import HTTP_AUTH from compute.service.rest_server.nbi_plugins.tools.HttpStatusCodes import HTTP_NOCONTENT, HTTP_SERVERERROR from compute.service.rest_server.nbi_plugins.tools.Validator import validate_message from .Constants import BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_BGP_AS, DEFAULT_BGP_ROUTE_TARGET, DEFAULT_MTU LOGGER = logging.getLogger(__name__) Loading src/compute/service/rest_server/nbi_plugins/ietf_network_slice/NSS_Service.py 0 → 100644 +78 −0 Original line number Diff line number Diff line # 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 flask.json import jsonify from flask_restful import Resource from common.proto.context_pb2 import SliceStatusEnum from common.tools.context_queries.Slice import get_slice from common.tools.grpc.Tools import grpc_message_to_json from context.client.ContextClient import ContextClient from slice.client.SliceClient import SliceClient from ..tools.Authentication import HTTP_AUTH from ..tools.HttpStatusCodes import HTTP_GATEWAYTIMEOUT, HTTP_NOCONTENT, HTTP_OK, HTTP_SERVERERROR LOGGER = logging.getLogger(__name__) class NSS_Service(Resource): @HTTP_AUTH.login_required def get(self, slice_id : str): LOGGER.debug('GET Slice ID: {:s}'.format(str(slice_id))) try: context_client = ContextClient() target = get_slice(context_client, slice_id, rw_copy=True) if target is None: raise Exception('Slice({:s}) not found in database'.format(str(slice_id))) if target.slice_id.slice_uuid.uuid != slice_id: # pylint: disable=no-member raise Exception('Slice retrieval failed. Wrong Slice Id was returned') slice_ready_status = SliceStatusEnum.SLICESTATUS_ACTIVE slice_status = target.slice_status.slice_status # pylint: disable=no-member response = jsonify(grpc_message_to_json(target)) response.status_code = HTTP_OK if slice_status == slice_ready_status else HTTP_GATEWAYTIMEOUT except Exception as e: # pylint: disable=broad-except LOGGER.exception('Something went wrong Retrieving Slice({:s})'.format(str(slice_id))) response = jsonify({'error': str(e)}) response.status_code = HTTP_SERVERERROR return response @HTTP_AUTH.login_required def delete(self, slice_id : str): LOGGER.debug('DELETE Slice ID: {:s}'.format(str(slice_id))) try: context_client = ContextClient() target = get_slice(context_client, slice_id) response = jsonify({}) response.status_code = HTTP_OK if target is None: LOGGER.warning('Slice({:s}) not found in database. Nothing done.'.format(str(slice_id))) response.status_code = HTTP_NOCONTENT else: if target.slice_id.slice_uuid.uuid != slice_id: # pylint: disable=no-member raise Exception('Slice retrieval failed. Wrong Slice Id was returned') slice_client = SliceClient() slice_client.DeleteSlice(target.slice_id) LOGGER.debug(f"Slice({slice_id}) successfully deleted") except Exception as e: # pylint: disable=broad-except LOGGER.exception('Something went wrong Deleting Slice({:s})'.format(str(slice_id))) response = jsonify({'error': str(e)}) response.status_code = HTTP_SERVERERROR return response No newline at end of file Loading
src/compute/service/__main__.py +3 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ from .ComputeService import ComputeService from .rest_server.RestServer import RestServer from .rest_server.nbi_plugins.debug_api import register_debug_api from .rest_server.nbi_plugins.ietf_l2vpn import register_ietf_l2vpn from .rest_server.nbi_plugins.ietf_network_slice import register_ietf_nss terminate = threading.Event() LOGGER = None Loading Loading @@ -58,8 +59,9 @@ def main(): grpc_service.start() rest_server = RestServer() register_ietf_l2vpn(rest_server) # Registering L2VPN entrypoint register_ietf_nss(rest_server) # Registering NSS entrypoint register_debug_api(rest_server) register_ietf_l2vpn(rest_server) rest_server.start() # Wait for Ctrl+C or termination signal Loading
src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Service.py +2 −2 Original line number Diff line number Diff line Loading @@ -20,8 +20,8 @@ from common.proto.context_pb2 import SliceStatusEnum from common.tools.context_queries.Slice import get_slice from context.client.ContextClient import ContextClient from slice.client.SliceClient import SliceClient from .tools.Authentication import HTTP_AUTH from .tools.HttpStatusCodes import HTTP_GATEWAYTIMEOUT, HTTP_NOCONTENT, HTTP_OK, HTTP_SERVERERROR from ..tools.Authentication import HTTP_AUTH from ..tools.HttpStatusCodes import HTTP_GATEWAYTIMEOUT, HTTP_NOCONTENT, HTTP_OK, HTTP_SERVERERROR LOGGER = logging.getLogger(__name__) Loading
src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_Services.py +3 −3 Original line number Diff line number Diff line Loading @@ -22,9 +22,9 @@ from common.Constants import DEFAULT_CONTEXT_NAME from common.proto.context_pb2 import SliceStatusEnum, Slice from slice.client.SliceClient import SliceClient from .schemas.vpn_service import SCHEMA_VPN_SERVICE from .tools.Authentication import HTTP_AUTH from .tools.HttpStatusCodes import HTTP_CREATED, HTTP_SERVERERROR from .tools.Validator import validate_message from compute.service.rest_server.nbi_plugins.tools.HttpStatusCodes import HTTP_CREATED, HTTP_SERVERERROR from compute.service.rest_server.nbi_plugins.tools.Validator import validate_message from compute.service.rest_server.nbi_plugins.tools.Authentication import HTTP_AUTH LOGGER = logging.getLogger(__name__) Loading
src/compute/service/rest_server/nbi_plugins/ietf_l2vpn/L2VPN_SiteNetworkAccesses.py +4 −5 Original line number Diff line number Diff line Loading @@ -30,11 +30,10 @@ from common.tools.grpc.Tools import grpc_message_to_json_string from context.client.ContextClient import ContextClient from slice.client.SliceClient import SliceClient from .schemas.site_network_access import SCHEMA_SITE_NETWORK_ACCESS from .tools.Authentication import HTTP_AUTH from .tools.HttpStatusCodes import HTTP_NOCONTENT, HTTP_SERVERERROR from .tools.Validator import validate_message from .Constants import ( BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_BGP_AS, DEFAULT_BGP_ROUTE_TARGET, DEFAULT_MTU) from compute.service.rest_server.nbi_plugins.tools.Authentication import HTTP_AUTH from compute.service.rest_server.nbi_plugins.tools.HttpStatusCodes import HTTP_NOCONTENT, HTTP_SERVERERROR from compute.service.rest_server.nbi_plugins.tools.Validator import validate_message from .Constants import BEARER_MAPPINGS, DEFAULT_ADDRESS_FAMILIES, DEFAULT_BGP_AS, DEFAULT_BGP_ROUTE_TARGET, DEFAULT_MTU LOGGER = logging.getLogger(__name__) Loading
src/compute/service/rest_server/nbi_plugins/ietf_network_slice/NSS_Service.py 0 → 100644 +78 −0 Original line number Diff line number Diff line # 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 flask.json import jsonify from flask_restful import Resource from common.proto.context_pb2 import SliceStatusEnum from common.tools.context_queries.Slice import get_slice from common.tools.grpc.Tools import grpc_message_to_json from context.client.ContextClient import ContextClient from slice.client.SliceClient import SliceClient from ..tools.Authentication import HTTP_AUTH from ..tools.HttpStatusCodes import HTTP_GATEWAYTIMEOUT, HTTP_NOCONTENT, HTTP_OK, HTTP_SERVERERROR LOGGER = logging.getLogger(__name__) class NSS_Service(Resource): @HTTP_AUTH.login_required def get(self, slice_id : str): LOGGER.debug('GET Slice ID: {:s}'.format(str(slice_id))) try: context_client = ContextClient() target = get_slice(context_client, slice_id, rw_copy=True) if target is None: raise Exception('Slice({:s}) not found in database'.format(str(slice_id))) if target.slice_id.slice_uuid.uuid != slice_id: # pylint: disable=no-member raise Exception('Slice retrieval failed. Wrong Slice Id was returned') slice_ready_status = SliceStatusEnum.SLICESTATUS_ACTIVE slice_status = target.slice_status.slice_status # pylint: disable=no-member response = jsonify(grpc_message_to_json(target)) response.status_code = HTTP_OK if slice_status == slice_ready_status else HTTP_GATEWAYTIMEOUT except Exception as e: # pylint: disable=broad-except LOGGER.exception('Something went wrong Retrieving Slice({:s})'.format(str(slice_id))) response = jsonify({'error': str(e)}) response.status_code = HTTP_SERVERERROR return response @HTTP_AUTH.login_required def delete(self, slice_id : str): LOGGER.debug('DELETE Slice ID: {:s}'.format(str(slice_id))) try: context_client = ContextClient() target = get_slice(context_client, slice_id) response = jsonify({}) response.status_code = HTTP_OK if target is None: LOGGER.warning('Slice({:s}) not found in database. Nothing done.'.format(str(slice_id))) response.status_code = HTTP_NOCONTENT else: if target.slice_id.slice_uuid.uuid != slice_id: # pylint: disable=no-member raise Exception('Slice retrieval failed. Wrong Slice Id was returned') slice_client = SliceClient() slice_client.DeleteSlice(target.slice_id) LOGGER.debug(f"Slice({slice_id}) successfully deleted") except Exception as e: # pylint: disable=broad-except LOGGER.exception('Something went wrong Deleting Slice({:s})'.format(str(slice_id))) response = jsonify({'error': str(e)}) response.status_code = HTTP_SERVERERROR return response No newline at end of file