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

Pre-merge cosmetic cleanup

parent 16d9b2f3
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!213Resolve "(CTTC) Implement NBI connector to manage Network Access Control Lists (ACLs)"
...@@ -13,12 +13,15 @@ ...@@ -13,12 +13,15 @@
# limitations under the License. # limitations under the License.
import copy, deepmerge, json, logging import copy, deepmerge, json, logging
from typing import Dict
from flask_restful import Resource, request
from werkzeug.exceptions import UnsupportedMediaType
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 flask_restful import Resource, request
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, bwInfo_2_service, service_2_bwInfo) format_grpc_to_json, grpc_context_id, grpc_service_id, bwInfo_2_service, service_2_bwInfo
)
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
...@@ -37,15 +40,20 @@ class BwInfo(_Resource): ...@@ -37,15 +40,20 @@ class BwInfo(_Resource):
return bw_allocations return bw_allocations
def post(self): def post(self):
bwinfo = request.get_json() if not request.is_json:
service = bwInfo_2_service(self.client, bwinfo) raise UnsupportedMediaType('JSON payload is required')
request_data: Dict = request.get_json()
service = bwInfo_2_service(self.client, request_data)
stripped_service = copy.deepcopy(service) stripped_service = copy.deepcopy(service)
stripped_service.ClearField('service_endpoint_ids') stripped_service.ClearField('service_endpoint_ids')
stripped_service.ClearField('service_constraints') stripped_service.ClearField('service_constraints')
stripped_service.ClearField('service_config') stripped_service.ClearField('service_config')
response = format_grpc_to_json(self.service_client.CreateService(stripped_service)) try:
response = format_grpc_to_json(self.service_client.UpdateService(service)) response = format_grpc_to_json(self.service_client.CreateService(stripped_service))
response = format_grpc_to_json(self.service_client.UpdateService(service))
except Exception as e: # pylint: disable=broad-except
return e
return response return response
......
...@@ -20,10 +20,10 @@ from common.proto.context_pb2 import ( ...@@ -20,10 +20,10 @@ from common.proto.context_pb2 import (
Service, Constraint, Constraint_SLA_Capacity, ConfigRule, ConfigRule_Custom, Service, Constraint, Constraint_SLA_Capacity, ConfigRule, ConfigRule_Custom,
ConfigActionEnum ConfigActionEnum
) )
from common.tools.grpc.ConfigRules import update_config_rule_custom
from common.tools.grpc.Tools import grpc_message_to_json from common.tools.grpc.Tools import grpc_message_to_json
from common.tools.object_factory.Context import json_context_id from common.tools.object_factory.Context import json_context_id
from common.tools.object_factory.Service import json_service_id from common.tools.object_factory.Service import json_service_id
from common.tools.grpc.ConfigRules import update_config_rule_custom
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
......
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