Commit 77e40265 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

First functional version of Service with Service Handler for L3NM-Emulated...

First functional version of Service with Service Handler for L3NM-Emulated services using Emulated Devices
parent 5cc92a6f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
# Internal manifest used for local testings.

# CTTC section:
cttc-ols.yaml
cttc-ols/
+0 −4
Original line number Diff line number Diff line
@@ -19,10 +19,6 @@ spec:
        ports:
        - containerPort: 3030
        env:
        - name: DB_ENGINE
          value: "redis"
        - name: REDIS_DATABASE_ID
          value: "0"
        - name: LOG_LEVEL
          value: "DEBUG"
        readinessProbe:
+7 −5
Original line number Diff line number Diff line
@@ -73,13 +73,15 @@ class DeviceServiceServicerImpl(DeviceServiceServicer):
                              'with "_connect/" tag. Others should be configured after adding the device.')

        if len(request.device_endpoints) > 0:
            unexpected_endpoints = MessageToDict(
                request.device_endpoints, including_default_value_fields=True, preserving_proto_field_name=True,
                use_integers_for_enums=True)
            unexpected_endpoints = []
            for device_endpoint in request.device_endpoints:
                unexpected_endpoints.append(MessageToDict(
                    device_endpoint, including_default_value_fields=True, preserving_proto_field_name=True,
                    use_integers_for_enums=True))
            str_unexpected_endpoints = json.dumps(unexpected_endpoints, sort_keys=True)
            raise InvalidArgumentException(
                'device.device_endpoints', str_unexpected_endpoints,
                extra_details='RPC method AddDevice does not accept endpoints. Endpoints are discovered through '\
                extra_details='RPC method AddDevice does not accept Endpoints. Endpoints are discovered through '\
                              'interrogation of the physical device.')

        # Remove device configuration
@@ -204,7 +206,7 @@ class DeviceServiceServicerImpl(DeviceServiceServicer):
            for config_rule in running_config_rules
        ]
        #for running_config_rule in running_config_rules:
        #    LOGGER.info('[AddDevice] running_config_rule: {:s}'.format(str(running_config_rule)))
        #    LOGGER.info('[ConfigureDevice] running_config_rule: {:s}'.format(str(running_config_rule)))
        update_config(self.database, device_uuid, 'running', running_config_rules)

        sync_device_to_context(db_device, self.context_client)
+0 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ from device.Config import (
    METRICS_PORT, MONITORING_SERVICE_HOST, MONITORING_SERVICE_PORT)
from monitoring.client.monitoring_client import MonitoringClient
from .DeviceService import DeviceService
from .MonitoringLoops import MonitoringLoops
from .driver_api.DriverFactory import DriverFactory
from .driver_api.DriverInstanceCache import DriverInstanceCache
from .drivers import DRIVERS
+10 −6
Original line number Diff line number Diff line
import anytree
from typing import Any, List, Optional
from typing import Any, List, Optional, Union
from apscheduler.job import Job

class TreeNode(anytree.node.Node):
@@ -28,20 +28,24 @@ class RawStyle(anytree.render.AbstractStyle):
        Node('/root/sub0/sub0A')
        Node('/root/sub1')
        """
        super(RawStyle, self).__init__(u'', u'', u'')
        super(RawStyle, self).__init__('', '', '')

def get_subnode(resolver : anytree.Resolver, root : TreeNode, path : List[str], default : Optional[Any] = None):
def get_subnode(
    resolver : anytree.Resolver, root : TreeNode, key_or_path : Union[str, List[str]], default : Optional[Any] = None):

    if isinstance(key_or_path, str): key_or_path = key_or_path.split('/')
    node = root
    for path_item in path:
    for path_item in key_or_path:
        try:
            node = resolver.get(node, path_item)
        except anytree.ChildResolverError:
            return default
    return node

def set_subnode_value(resolver : anytree.Resolver, root : TreeNode, path : List[str], value : Any):
def set_subnode_value(resolver : anytree.Resolver, root : TreeNode, key_or_path : Union[str, List[str]], value : Any):
    if isinstance(key_or_path, str): key_or_path = key_or_path.split('/')
    node = root
    for path_item in path:
    for path_item in key_or_path:
        try:
            node = resolver.get(node, path_item)
        except anytree.ChildResolverError:
Loading