diff --git a/coverage/.coveragerc.template b/coverage/.coveragerc.template index e5e634c2c256103b1796d9309a3433ae9f248e70..8863d4d6ea58b967949a888d85af02d979244420 100644 --- a/coverage/.coveragerc.template +++ b/coverage/.coveragerc.template @@ -1,5 +1,5 @@ [run] -data_file = ~/teraflow/controller/coverage/.coverage +data_file = ~/tfs-ctrl/coverage/.coverage source = . omit = */proto/* @@ -12,7 +12,7 @@ exclude_lines = raise\ NotImplementedError [html] -directory = ~/teraflow/controller/coverage/html_report +directory = ~/tfs-ctrl/coverage/html_report [xml] output = ~/teraflow/controller/coverage/report.xml diff --git a/src/common/Constants.py b/src/common/Constants.py index d606c0d031631ff4e105775b51f189fdcbe063d1..9f015b8c737d4c16c6ceaf72a01afd4a7546823d 100644 --- a/src/common/Constants.py +++ b/src/common/Constants.py @@ -33,9 +33,9 @@ DEFAULT_METRICS_PORT = 9192 DEFAULT_CONTEXT_NAME = 'admin' DEFAULT_TOPOLOGY_NAME = 'admin' # contains the detailed local topology INTERDOMAIN_TOPOLOGY_NAME = 'inter' # contains the abstract inter-domain topology -DEFAULT_CONTEXT_UUID = str(uuid.uuid5(uuid.NAMESPACE_OID, DEFAULT_CONTEXT_NAME )) -DEFAULT_TOPOLOGY_UUID = str(uuid.uuid5(uuid.NAMESPACE_OID, DEFAULT_TOPOLOGY_NAME )) -INTERDOMAIN_TOPOLOGY_UUID = str(uuid.uuid5(uuid.NAMESPACE_OID, INTERDOMAIN_TOPOLOGY_NAME)) +#DEFAULT_CONTEXT_UUID = str(uuid.uuid5(uuid.NAMESPACE_OID, DEFAULT_CONTEXT_NAME )) +#DEFAULT_TOPOLOGY_UUID = str(uuid.uuid5(uuid.NAMESPACE_OID, DEFAULT_TOPOLOGY_NAME )) +#INTERDOMAIN_TOPOLOGY_UUID = str(uuid.uuid5(uuid.NAMESPACE_OID, INTERDOMAIN_TOPOLOGY_NAME)) # Default service names class ServiceNameEnum(Enum): diff --git a/src/common/rpc_method_wrapper/ServiceExceptions.py b/src/common/rpc_method_wrapper/ServiceExceptions.py index e516953c5b1e569ab997288cd1d38e371bf07936..369565cf8d76975426174ba35ec14140526e8a39 100644 --- a/src/common/rpc_method_wrapper/ServiceExceptions.py +++ b/src/common/rpc_method_wrapper/ServiceExceptions.py @@ -13,7 +13,7 @@ # limitations under the License. import grpc -from typing import Iterable, Union +from typing import Iterable, List, Tuple, Union class ServiceException(Exception): def __init__( @@ -21,7 +21,7 @@ class ServiceException(Exception): ) -> None: self.code = code if isinstance(extra_details, str): extra_details = [extra_details] - self.details = '; '.join(map(str, [details] + extra_details)) + self.details = '; '.join([str(item) for item in ([details] + extra_details)]) super().__init__(self.details) class NotFoundException(ServiceException): @@ -45,6 +45,14 @@ class InvalidArgumentException(ServiceException): details = '{:s}({:s}) is invalid'.format(str(argument_name), str(argument_value)) super().__init__(grpc.StatusCode.INVALID_ARGUMENT, details, extra_details=extra_details) +class InvalidArgumentsException(ServiceException): + def __init__( + self, arguments : List[Tuple[str, str]], extra_details : Union[str, Iterable[str]] = None + ) -> None: + str_arguments = ', '.join(['{:s}({:s})'.format(name, value) for name,value in arguments]) + details = 'Arguments {:s} are invalid'.format(str_arguments) + super().__init__(grpc.StatusCode.INVALID_ARGUMENT, details, extra_details=extra_details) + class OperationFailedException(ServiceException): def __init__( self, operation : str, extra_details : Union[str, Iterable[str]] = None diff --git a/src/common/tools/object_factory/Service.py b/src/common/tools/object_factory/Service.py index be8eefe5bc032ad6a45fd54b267db6ab12e3f5b0..66785fbb45ab83663e87c67387a84f20c607a317 100644 --- a/src/common/tools/object_factory/Service.py +++ b/src/common/tools/object_factory/Service.py @@ -14,7 +14,7 @@ import copy from typing import Dict, List, Optional -from common.Constants import DEFAULT_CONTEXT_UUID +from common.Constants import DEFAULT_CONTEXT_NAME from common.proto.context_pb2 import ServiceStatusEnum, ServiceTypeEnum from common.tools.object_factory.Context import json_context_id @@ -44,7 +44,7 @@ def json_service( def json_service_l3nm_planned( service_uuid : str, endpoint_ids : List[Dict] = [], constraints : List[Dict] = [], - config_rules : List[Dict] = [], context_uuid : str = DEFAULT_CONTEXT_UUID + config_rules : List[Dict] = [], context_uuid : str = DEFAULT_CONTEXT_NAME ): return json_service( @@ -54,7 +54,7 @@ def json_service_l3nm_planned( def json_service_tapi_planned( service_uuid : str, endpoint_ids : List[Dict] = [], constraints : List[Dict] = [], - config_rules : List[Dict] = [], context_uuid : str = DEFAULT_CONTEXT_UUID + config_rules : List[Dict] = [], context_uuid : str = DEFAULT_CONTEXT_NAME ): return json_service( @@ -64,7 +64,7 @@ def json_service_tapi_planned( def json_service_p4_planned( service_uuid : str, endpoint_ids : List[Dict] = [], constraints : List[Dict] = [], - config_rules : List[Dict] = [], context_uuid : str = DEFAULT_CONTEXT_UUID + config_rules : List[Dict] = [], context_uuid : str = DEFAULT_CONTEXT_NAME ): return json_service(