Commit 289dca4e authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Service component - L3NM IETF Slice:

- Removed unused Settings Handler
- Added log messages
parent 4d733960
Loading
Loading
Loading
Loading
+16 −25
Original line number Diff line number Diff line
@@ -13,15 +13,15 @@
# limitations under the License.


import ipaddress, json, logging
import ipaddress, logging
from typing import Any, List, Optional, Tuple, Union
from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method
from common.proto.context_pb2 import ConfigRule, DeviceId, Service
from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set
from common.tools.object_factory.Device import json_device_id
from common.type_checkers.Checkers import chk_type
from service.service.service_handler_api._ServiceHandler import _ServiceHandler
from service.service.service_handler_api.SettingsHandler import SettingsHandler
from service.service.service_handler_api.Tools import get_device_endpoint_uuids
from service.service.task_scheduler.TaskExecutor import TaskExecutor
from .DataStoreDelta import DataStoreDelta
@@ -40,7 +40,6 @@ class L3NM_IETFSlice_ServiceHandler(_ServiceHandler):
    ) -> None:
        self.__service = service
        self.__task_executor = task_executor
        self.__settings_handler = SettingsHandler(service.service_config, **settings)

    @metered_subclass_method(METRICS_POOL)
    def SetEndpoint(
@@ -48,6 +47,10 @@ class L3NM_IETFSlice_ServiceHandler(_ServiceHandler):
        endpoints: List[Tuple[str, str, Optional[str]]],
        connection_uuid: Optional[str] = None,
    ) -> List[Union[bool, Exception]]:
        LOGGER.debug('[SetEndpoint] service={:s}'.format(grpc_message_to_json_string(self.__service)))
        LOGGER.debug('[SetEndpoint] endpoints={:s}'.format(str(endpoints)))
        LOGGER.debug('[SetEndpoint] connection_uuid={:s}'.format(str(connection_uuid)))

        chk_type('endpoints', endpoints, list)
        if len(endpoints) == 0: return []

@@ -197,10 +200,9 @@ class L3NM_IETFSlice_ServiceHandler(_ServiceHandler):
    ) -> List[Union[bool, Exception]]:
        chk_type('constraints', constraints, list)
        if len(constraints) == 0: return []

        MSG = '[SetConstraint] Method not implemented. Constraints({:s}) are being ignored.'
        LOGGER.warning(MSG.format(str(constraints)))
        return [True for _ in range(len(constraints))]
        return [True for _ in constraints]

    @metered_subclass_method(METRICS_POOL)
    def DeleteConstraint(
@@ -208,37 +210,26 @@ class L3NM_IETFSlice_ServiceHandler(_ServiceHandler):
    ) -> List[Union[bool, Exception]]:
        chk_type('constraints', constraints, list)
        if len(constraints) == 0: return []

        MSG = '[DeleteConstraint] Method not implemented. Constraints({:s}) are being ignored.'
        LOGGER.warning(MSG.format(str(constraints)))
        return [True for _ in range(len(constraints))]
        return [True for _ in constraints]

    @metered_subclass_method(METRICS_POOL)
    def SetConfig(
        self, resources: List[Tuple[str, Any]]
    ) -> List[Union[bool, Exception]]:
        chk_type('resources', resources, list)
        results = []
        for resource in resources:
            try:
                resource_value = json.loads(resource[1])
                self.__settings_handler.set(resource[0], resource_value)
                results.append(True)
            except Exception as e:
                LOGGER.exception('Unable to SetConfig({:s})'.format(str(resource)))
                results.append(e)
        return results
        if len(resources) == 0: return []
        MSG = '[SetConfig] Method not implemented. Resources({:s}) are being ignored.'
        LOGGER.warning(MSG.format(str(resources)))
        return [True for _ in resources]

    @metered_subclass_method(METRICS_POOL)
    def DeleteConfig(
        self, resources: List[Tuple[str, Any]]
    ) -> List[Union[bool, Exception]]:
        chk_type('resources', resources, list)
        results = []
        for resource in resources:
            try:
                self.__settings_handler.delete(resource[0])
            except Exception as e:
                LOGGER.exception('Unable to DeleteConfig({:s})'.format(str(resource)))
                results.append(e)
        return results
        if len(resources) == 0: return []
        MSG = '[DeleteConfig] Method not implemented. Resources({:s}) are being ignored.'
        LOGGER.warning(MSG.format(str(resources)))
        return [True for _ in resources]