Commit ffa2ce8d authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'develop' of ssh://gifrerenom_labs.etsi.org/tfs/controller into...

Merge branch 'develop' of ssh://gifrerenom_labs.etsi.org/tfs/controller into feat/247-cttc-analytics-module-enhancements
parents cfa1829b 4e7a76d8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui"
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"

# Uncomment to activate Monitoring Framework (new)
export TFS_COMPONENTS="${TFS_COMPONENTS} kpi_manager kpi_value_writer kpi_value_api telemetry analytics automation"
#export TFS_COMPONENTS="${TFS_COMPONENTS} kpi_manager kpi_value_writer kpi_value_api telemetry analytics automation"

# Uncomment to activate QoS Profiles
#export TFS_COMPONENTS="${TFS_COMPONENTS} qos_profile"
+1 −1
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
+16 −16
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
import threading
from typing import Any, Iterator, List, Optional, Tuple, Union

# Special resource names to request to the driver to retrieve the specified
# Special resource names to request to the collector to retrieve the specified
# configuration/structural resources.
# These resource names should be used with GetConfig() method.
RESOURCE_ENDPOINTS = '__endpoints__'
@@ -27,16 +27,16 @@ RESOURCE_ACL = '__acl__'
RESOURCE_INVENTORY = '__inventory__'


class _Driver:
class _Collector:
    def __init__(self, name : str, address: str, port: int, **settings) -> None:
        """ Initialize Driver.
        """ Initialize Collector.
            Parameters:
                address : str
                    The address of the device
                port : int
                    The port of the device
                **settings
                    Extra settings required by the driver.
                    Extra settings required by the collector.
        """
        self._name = name
        self._address = address
@@ -139,7 +139,7 @@ class _Driver:
            List[Union[bool, Exception]]:
        """ Subscribe to state information of entire device or
        selected resources. Subscriptions are incremental.
            Driver should keep track of requested resources.
            Collector should keep track of requested resources.
            Parameters:
                subscriptions : List[Tuple[str, float, float]]
                    List of tuples, each containing a resource_key pointing the
@@ -162,7 +162,7 @@ class _Driver:
            -> List[Union[bool, Exception]]:
        """ Unsubscribe from state information of entire device
        or selected resources. Subscriptions are incremental.
            Driver should keep track of requested resources.
            Collector should keep track of requested resources.
            Parameters:
                subscriptions : List[str]
                    List of tuples, each containing a resource_key pointing the
@@ -188,37 +188,37 @@ class _Driver:
        Operates as a generator, so this method should be called once and will
        block until values are available. When values are available,
        it should yield each of them and block again until new values are
        available. When the driver is destroyed, GetState() can return instead
        available. When the collector is destroyed, GetState() can return instead
        of yield to terminate the loop.
        Terminate enables to request interruption of the generation.
            Examples:
                # keep looping waiting for extra samples (generator loop)
                terminate = threading.Event()
                i = 0
                for timestamp,resource_key,resource_value in my_driver.GetState(blocking=True, terminate=terminate):
                for timestamp,resource_key,resource_value in my_collector.GetState(blocking=True, terminate=terminate):
                    process(timestamp, resource_key, resource_value)
                    i += 1
                    if i == 10: terminate.set()

                # just retrieve accumulated samples
                samples = my_driver.GetState(blocking=False, terminate=terminate)
                samples = my_collector.GetState(blocking=False, terminate=terminate)
                # or (as classical loop)
                i = 0
                for timestamp,resource_key,resource_value in my_driver.GetState(blocking=False, terminate=terminate):
                for timestamp,resource_key,resource_value in my_collector.GetState(blocking=False, terminate=terminate):
                    process(timestamp, resource_key, resource_value)
                    i += 1
                    if i == 10: terminate.set()
            Parameters:
                blocking : bool
                    Select the driver behaviour. In both cases, the driver will
                    Select the collector behaviour. In both cases, the collector will
                    first retrieve the samples accumulated and available in the
                    internal queue. Then, if blocking, the driver does not
                    internal queue. Then, if blocking, the collector does not
                    terminate the loop and waits for additional samples to come,
                    thus behaving as a generator. If non-blocking, the driver
                    thus behaving as a generator. If non-blocking, the collector
                    terminates the loop and returns. Non-blocking behaviour can
                    be used for periodically polling the driver, while blocking
                    be used for periodically polling the collector, while blocking
                    can be used when a separate thread is in charge of
                    collecting the samples produced by the driver.
                    collecting the samples produced by the collector.
                terminate : threading.Event
                    Signals the interruption of the GetState method as soon as
                    possible.
+1 −1
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
+1 −1
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Loading