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

Common:

- updated coveragerc template file
- extended and improved rpc wrapper set of declarable exceptions
- updated default context and topology definition constants
parent 22d86182
No related branches found
No related tags found
2 merge requests!54Release 2.0.0,!34Context Scalability extensions using CockroachDB + Removal of Stateful database inside Device + other
[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
......@@ -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):
......
......@@ -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
......
......@@ -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(
......
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