Skip to content
Snippets Groups Projects
Commit 0f3fc78c authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Pre-merge code cleanup

parent 429be319
No related branches found
No related tags found
3 merge requests!359Release TeraFlowSDN 5.0,!325Polish "Implement CAMARA-based NBI connector",!249Resolve "Implement CAMARA-based NBI connector"
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
...@@ -11,31 +11,26 @@ ...@@ -11,31 +11,26 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from flask.json import jsonify
from flask_restful import Resource, request
from enum import Enum import copy, grpc, grpc._channel, logging
import grpc._channel
from qos_profile.client.QoSProfileClient import QoSProfileClient
from werkzeug.exceptions import UnsupportedMediaType
from common.proto.context_pb2 import QoSProfileId, Uuid,Empty
from common.proto.qos_profile_pb2 import QoDConstraintsRequest
from typing import Dict from typing import Dict
from uuid import uuid4 from uuid import uuid4
import grpc, logging from flask.json import jsonify
import copy, deepmerge, json, logging
from typing import Dict
from flask_restful import Resource, request from flask_restful import Resource, request
from werkzeug.exceptions import UnsupportedMediaType from common.proto.context_pb2 import QoSProfileId, Uuid,Empty
from common.Constants import DEFAULT_CONTEXT_NAME from common.Constants import DEFAULT_CONTEXT_NAME
from context.client.ContextClient import ContextClient from context.client.ContextClient import ContextClient
from qos_profile.client.QoSProfileClient import QoSProfileClient
from service.client.ServiceClient import ServiceClient from service.client.ServiceClient import ServiceClient
from .Tools import ( from .Tools import (
format_grpc_to_json, grpc_context_id, grpc_service_id, QOD_2_service, service_2_qod,grpc_message_to_qos_table_data,create_qos_profile_from_json format_grpc_to_json, grpc_context_id, grpc_service_id,
QOD_2_service, service_2_qod, grpc_message_to_qos_table_data,
create_qos_profile_from_json
) )
LOGGER = logging.getLogger(__name__)
LOGGER = logging.getLogger(__name__)
#Initiate the QoSProfileClient
class _Resource(Resource): class _Resource(Resource):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
...@@ -43,7 +38,7 @@ class _Resource(Resource): ...@@ -43,7 +38,7 @@ class _Resource(Resource):
self.client = ContextClient() self.client = ContextClient()
self.service_client = ServiceClient() self.service_client = ServiceClient()
#ProfileList Endpoint for posting #ProfileList Endpoint for posting
class ProfileList(_Resource): class ProfileList(_Resource):
def post(self): def post(self):
if not request.is_json: if not request.is_json:
......
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
......
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) # Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
...@@ -13,18 +13,17 @@ ...@@ -13,18 +13,17 @@
# limitations under the License. # limitations under the License.
from nbi.service.rest_server.RestServer import RestServer from nbi.service.rest_server.RestServer import RestServer
from .Resources import ProfileList, ProfileDetail, qodinfo, qodinfoId from .Resources import ProfileList, ProfileDetail, QodInfo, QodInfoID
URL_PREFIX = '/camara/qod/v0' URL_PREFIX = '/camara/qod/v0'
# Use 'path' type since some identifiers might contain char '/' and Flask is unable to recognize them in 'string' type. # Use 'path' type since some identifiers might contain char '/' and Flask is unable to recognize them in 'string' type.
RESOURCES = [ RESOURCES = [
# (endpoint_name, resource_class, resource_url) # (endpoint_name, resource_class, resource_url)
# TODO: Add appropriate endpoints ('camara.qod_session_info', QodInfo, '/sessions'),
('camara.qod_session_info', qodinfo, '/sessions'), ('camara.qod_info_session_id', QodInfoID, '/sessions/<sessionId>'),
('camara.qod_info_session_id', qodinfoId, '/sessions/<sessionId>'), ('camara.qod.profile_list', ProfileList, '/profiles'),
('camara.qod.profile_list',ProfileList,'/profiles'), ('camara.qod.profile_detail', ProfileDetail, '/profiles/<string:qos_profile_id>'),
('camara.qod.profile_detail',ProfileDetail,'/profiles/<string:qos_profile_id>'),
] ]
def register_camara_qod(rest_server : RestServer): def register_camara_qod(rest_server : RestServer):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment