Loading src/nbi/service/rest_server/nbi_plugins/camara_qod/Resources.py +18 −12 Original line number Diff line number Diff line Loading @@ -95,6 +95,15 @@ class ProfileDetail(_Resource): LOGGER.error(f"Error while fetching QoSProfile: {e}") return {"error": "Internal Server Error"}, 500 def get(self,QoDConstraintsRequest): qos_profiles = self.qos_profile_client.GetConstraintListFromQoSProfile(QoDConstraintsRequest) qos_profile_list = [] #since it iterates over QoSProfile , create a list to store all QOS profiles for qos_profile in qos_profiles: qos_profile_data = grpc_message_to_qos_table_data(qos_profile) #transform to json qos_profile_list.append(qos_profile_data) # append to the list return jsonify(qos_profile_list) def put(self, qos_profile_id): try: request_data = request.get_json() # get the json to do the update Loading Loading @@ -155,12 +164,14 @@ class qodinfo(_Resource): def post(self): if not request.is_json: return (jsonify({'error': 'Unsupported Media Type', 'message': 'JSON payload is required'}), 415) request_data: Dict = request.get_json() qos_profile_id = request_data.get('qos_profile_id') qos_session_id = request_data.get('qos_session_id') LOGGER.info(f'qos_profile_id:{qos_profile_id}') if not qos_profile_id: return jsonify({'error': 'qos_profile_id is required'}), 400 if qos_session_id: return jsonify({'error': 'qos_session_id is not allowed in creation'}), 400 service = QOD_2_service(self.client, request_data,qos_profile_id) stripped_service = copy.deepcopy(service) stripped_service.ClearField('service_endpoint_ids') Loading @@ -181,10 +192,6 @@ class qodinfo(_Resource): LOGGER.info(f"error related to qod_info: {qod_info}") return qod_info class qodinfoId(_Resource): def get(self, sessionId: str): Loading @@ -199,21 +206,21 @@ class qodinfoId(_Resource): def put(self, sessionId: str): try: request_data: Dict = request.get_json() sessionId= request_data.get('session_id') if not sessionId: session_id = request_data.get('session_id') if not session_id: return jsonify({'error': 'sessionId is required'}), 400 qos_profile_id = request_data.get('qos_profile_id') if not qos_profile_id: return jsonify({'error': 'qos_profile_id is required'}), 400 service = QOD_2_service(self.client, request_data, qos_profile_id) service = self.client.GetService(grpc_service_id(DEFAULT_CONTEXT_NAME, sessionId)) updated_service = self.service_client.UpdateService(service) qod_response = service_2_qod(updated_service) return qod_response, 200 except KeyError as e: LOGGER.error(f"Missing required key: {e}") return {"error": f"Missing required key: {str(e)}"}, 400 except grpc._channel._InactiveRpcError as exc: if exc.code() == grpc.StatusCode.NOT_FOUND: LOGGER.warning(f"Qod Session not found: {sessionId}") Loading @@ -224,7 +231,6 @@ class qodinfoId(_Resource): LOGGER.error(f"Error in PUT /sessions/{sessionId}: {e}") return {"error": "Internal Server Error"}, 500 def delete(self, sessionId: str): self.service_client.DeleteService(grpc_service_id(DEFAULT_CONTEXT_NAME, sessionId)) return{"Session Deleted"} Loading src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py +2 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,8 @@ from common.tools.object_factory.Service import json_service_id from uuid import uuid4 from nbi.service.rest_server.nbi_plugins.ietf_network.bindings.networks import network from qos_profile.client.QoSProfileClient import QoSProfileClient from context.service.database.QoSProfile import grpc_message_to_qos_table_data from common.proto.context_pb2 import QoSProfile, QoSProfileId, Uuid, QoSProfileValueUnitPair,Empty #from context.service.database.QoSProfile import grpc_message_to_qos_table_data from common.proto.context_pb2 import QoSProfile, QoSProfileId, Uuid, QoSProfileValueUnitPair,Empty,ServiceId import logging import grpc from netaddr import IPAddress, IPNetwork Loading Loading
src/nbi/service/rest_server/nbi_plugins/camara_qod/Resources.py +18 −12 Original line number Diff line number Diff line Loading @@ -95,6 +95,15 @@ class ProfileDetail(_Resource): LOGGER.error(f"Error while fetching QoSProfile: {e}") return {"error": "Internal Server Error"}, 500 def get(self,QoDConstraintsRequest): qos_profiles = self.qos_profile_client.GetConstraintListFromQoSProfile(QoDConstraintsRequest) qos_profile_list = [] #since it iterates over QoSProfile , create a list to store all QOS profiles for qos_profile in qos_profiles: qos_profile_data = grpc_message_to_qos_table_data(qos_profile) #transform to json qos_profile_list.append(qos_profile_data) # append to the list return jsonify(qos_profile_list) def put(self, qos_profile_id): try: request_data = request.get_json() # get the json to do the update Loading Loading @@ -155,12 +164,14 @@ class qodinfo(_Resource): def post(self): if not request.is_json: return (jsonify({'error': 'Unsupported Media Type', 'message': 'JSON payload is required'}), 415) request_data: Dict = request.get_json() qos_profile_id = request_data.get('qos_profile_id') qos_session_id = request_data.get('qos_session_id') LOGGER.info(f'qos_profile_id:{qos_profile_id}') if not qos_profile_id: return jsonify({'error': 'qos_profile_id is required'}), 400 if qos_session_id: return jsonify({'error': 'qos_session_id is not allowed in creation'}), 400 service = QOD_2_service(self.client, request_data,qos_profile_id) stripped_service = copy.deepcopy(service) stripped_service.ClearField('service_endpoint_ids') Loading @@ -181,10 +192,6 @@ class qodinfo(_Resource): LOGGER.info(f"error related to qod_info: {qod_info}") return qod_info class qodinfoId(_Resource): def get(self, sessionId: str): Loading @@ -199,21 +206,21 @@ class qodinfoId(_Resource): def put(self, sessionId: str): try: request_data: Dict = request.get_json() sessionId= request_data.get('session_id') if not sessionId: session_id = request_data.get('session_id') if not session_id: return jsonify({'error': 'sessionId is required'}), 400 qos_profile_id = request_data.get('qos_profile_id') if not qos_profile_id: return jsonify({'error': 'qos_profile_id is required'}), 400 service = QOD_2_service(self.client, request_data, qos_profile_id) service = self.client.GetService(grpc_service_id(DEFAULT_CONTEXT_NAME, sessionId)) updated_service = self.service_client.UpdateService(service) qod_response = service_2_qod(updated_service) return qod_response, 200 except KeyError as e: LOGGER.error(f"Missing required key: {e}") return {"error": f"Missing required key: {str(e)}"}, 400 except grpc._channel._InactiveRpcError as exc: if exc.code() == grpc.StatusCode.NOT_FOUND: LOGGER.warning(f"Qod Session not found: {sessionId}") Loading @@ -224,7 +231,6 @@ class qodinfoId(_Resource): LOGGER.error(f"Error in PUT /sessions/{sessionId}: {e}") return {"error": "Internal Server Error"}, 500 def delete(self, sessionId: str): self.service_client.DeleteService(grpc_service_id(DEFAULT_CONTEXT_NAME, sessionId)) return{"Session Deleted"} Loading
src/nbi/service/rest_server/nbi_plugins/camara_qod/Tools.py +2 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,8 @@ from common.tools.object_factory.Service import json_service_id from uuid import uuid4 from nbi.service.rest_server.nbi_plugins.ietf_network.bindings.networks import network from qos_profile.client.QoSProfileClient import QoSProfileClient from context.service.database.QoSProfile import grpc_message_to_qos_table_data from common.proto.context_pb2 import QoSProfile, QoSProfileId, Uuid, QoSProfileValueUnitPair,Empty #from context.service.database.QoSProfile import grpc_message_to_qos_table_data from common.proto.context_pb2 import QoSProfile, QoSProfileId, Uuid, QoSProfileValueUnitPair,Empty,ServiceId import logging import grpc from netaddr import IPAddress, IPNetwork Loading