Loading src/simap_connector/service/__main__.py +16 −2 Original line number Diff line number Diff line Loading @@ -14,15 +14,22 @@ import logging, signal, sys, threading from prometheus_client import start_http_server from common.tools.rest_conf.client.RestConfClient import RestConfClient from common.Constants import ServiceNameEnum from common.Settings import ( ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, wait_for_environment_variables ) from simap_connector.Config import ( SIMAP_SERVER_SCHEME, SIMAP_SERVER_ADDRESS, SIMAP_SERVER_PORT, SIMAP_SERVER_USERNAME, SIMAP_SERVER_PASSWORD, ) from .simap_updater.SimapClient import SimapClient from .simap_updater.SimapUpdater import SimapUpdater from .telemetry.TelemetryPool import TelemetryPool from .SimapConnectorService import SimapConnectorService TERMINATE = threading.Event() LOG_LEVEL = get_log_level() Loading Loading @@ -56,8 +63,15 @@ def main(): grpc_service = SimapConnectorService() grpc_service.start() telemetry_pool = TelemetryPool(terminate=TERMINATE) simap_updater = SimapUpdater(TERMINATE, telemetry_pool) restconf_client = RestConfClient( scheme=SIMAP_SERVER_SCHEME, address=SIMAP_SERVER_ADDRESS, port=SIMAP_SERVER_PORT, username=SIMAP_SERVER_USERNAME, password=SIMAP_SERVER_PASSWORD, ) simap_client = SimapClient(restconf_client) telemetry_pool = TelemetryPool(simap_client, terminate=TERMINATE) simap_updater = SimapUpdater(simap_client, telemetry_pool, TERMINATE) simap_updater.start() LOGGER.info('Running...') Loading src/simap_connector/service/simap_updater/SimapUpdater.py +10 −17 Original line number Diff line number Diff line Loading @@ -23,22 +23,16 @@ from common.proto.context_pb2 import ( from common.tools.grpc.BaseEventCollector import BaseEventCollector from common.tools.grpc.BaseEventDispatcher import BaseEventDispatcher from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.rest_conf.client.RestConfClient import RestConfClient from context.client.ContextClient import ContextClient from simap_connector.Config import ( SIMAP_SERVER_SCHEME, SIMAP_SERVER_ADDRESS, SIMAP_SERVER_PORT, SIMAP_SERVER_USERNAME, SIMAP_SERVER_PASSWORD, ) from simap_connector.service.simap_updater.MockSimaps import delete_mock_simap, set_mock_simap from simap_connector.service.telemetry.Resources import Resources from simap_connector.service.telemetry.TelemetryPool import TelemetryPool from .SimapClient import SimapClient from .ObjectCache import CachedEntities, ObjectCache from .SimapClient import SimapClient from .Tools import get_device_endpoint, get_link_endpoint, get_service_endpoint LOGGER = logging.getLogger(__name__) RESTCONF_LOGGER = logging.getLogger(__name__ + '.RestConfClient') SKIPPED_DEVICE_TYPES = { Loading @@ -52,21 +46,16 @@ SKIPPED_DEVICE_TYPES = { class EventDispatcher(BaseEventDispatcher): def __init__( self, events_queue : queue.PriorityQueue, simap_client : SimapClient, context_client : ContextClient, telemetry_pool : TelemetryPool, terminate : Optional[threading.Event] = None ) -> None: super().__init__(events_queue, terminate) self._simap_client = simap_client self._context_client = context_client self._telemetry_pool = telemetry_pool self._object_cache = ObjectCache(self._context_client) self._restconf_client = RestConfClient( scheme=SIMAP_SERVER_SCHEME, address=SIMAP_SERVER_ADDRESS, port=SIMAP_SERVER_PORT, username=SIMAP_SERVER_USERNAME, password=SIMAP_SERVER_PASSWORD, logger=RESTCONF_LOGGER, ) self._simap_client = SimapClient(self._restconf_client) self._skipped_devices : Set[str] = set() Loading Loading @@ -618,7 +607,11 @@ class EventDispatcher(BaseEventDispatcher): class SimapUpdater: def __init__(self, terminate : threading.Event, telemetry_pool : TelemetryPool) -> None: def __init__( self, simap_client : SimapClient, telemetry_pool : TelemetryPool, terminate : threading.Event ) -> None: self._simap_client = simap_client self._telemetry_pool = telemetry_pool self._context_client = ContextClient() Loading @@ -628,8 +621,8 @@ class SimapUpdater: ) self._event_dispatcher = EventDispatcher( self._event_collector.get_events_queue(), self._context_client, self._telemetry_pool, terminate=terminate self._event_collector.get_events_queue(), self._simap_client, self._context_client, self._telemetry_pool, terminate=terminate ) def start(self) -> None: Loading Loading
src/simap_connector/service/__main__.py +16 −2 Original line number Diff line number Diff line Loading @@ -14,15 +14,22 @@ import logging, signal, sys, threading from prometheus_client import start_http_server from common.tools.rest_conf.client.RestConfClient import RestConfClient from common.Constants import ServiceNameEnum from common.Settings import ( ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port, wait_for_environment_variables ) from simap_connector.Config import ( SIMAP_SERVER_SCHEME, SIMAP_SERVER_ADDRESS, SIMAP_SERVER_PORT, SIMAP_SERVER_USERNAME, SIMAP_SERVER_PASSWORD, ) from .simap_updater.SimapClient import SimapClient from .simap_updater.SimapUpdater import SimapUpdater from .telemetry.TelemetryPool import TelemetryPool from .SimapConnectorService import SimapConnectorService TERMINATE = threading.Event() LOG_LEVEL = get_log_level() Loading Loading @@ -56,8 +63,15 @@ def main(): grpc_service = SimapConnectorService() grpc_service.start() telemetry_pool = TelemetryPool(terminate=TERMINATE) simap_updater = SimapUpdater(TERMINATE, telemetry_pool) restconf_client = RestConfClient( scheme=SIMAP_SERVER_SCHEME, address=SIMAP_SERVER_ADDRESS, port=SIMAP_SERVER_PORT, username=SIMAP_SERVER_USERNAME, password=SIMAP_SERVER_PASSWORD, ) simap_client = SimapClient(restconf_client) telemetry_pool = TelemetryPool(simap_client, terminate=TERMINATE) simap_updater = SimapUpdater(simap_client, telemetry_pool, TERMINATE) simap_updater.start() LOGGER.info('Running...') Loading
src/simap_connector/service/simap_updater/SimapUpdater.py +10 −17 Original line number Diff line number Diff line Loading @@ -23,22 +23,16 @@ from common.proto.context_pb2 import ( from common.tools.grpc.BaseEventCollector import BaseEventCollector from common.tools.grpc.BaseEventDispatcher import BaseEventDispatcher from common.tools.grpc.Tools import grpc_message_to_json_string from common.tools.rest_conf.client.RestConfClient import RestConfClient from context.client.ContextClient import ContextClient from simap_connector.Config import ( SIMAP_SERVER_SCHEME, SIMAP_SERVER_ADDRESS, SIMAP_SERVER_PORT, SIMAP_SERVER_USERNAME, SIMAP_SERVER_PASSWORD, ) from simap_connector.service.simap_updater.MockSimaps import delete_mock_simap, set_mock_simap from simap_connector.service.telemetry.Resources import Resources from simap_connector.service.telemetry.TelemetryPool import TelemetryPool from .SimapClient import SimapClient from .ObjectCache import CachedEntities, ObjectCache from .SimapClient import SimapClient from .Tools import get_device_endpoint, get_link_endpoint, get_service_endpoint LOGGER = logging.getLogger(__name__) RESTCONF_LOGGER = logging.getLogger(__name__ + '.RestConfClient') SKIPPED_DEVICE_TYPES = { Loading @@ -52,21 +46,16 @@ SKIPPED_DEVICE_TYPES = { class EventDispatcher(BaseEventDispatcher): def __init__( self, events_queue : queue.PriorityQueue, simap_client : SimapClient, context_client : ContextClient, telemetry_pool : TelemetryPool, terminate : Optional[threading.Event] = None ) -> None: super().__init__(events_queue, terminate) self._simap_client = simap_client self._context_client = context_client self._telemetry_pool = telemetry_pool self._object_cache = ObjectCache(self._context_client) self._restconf_client = RestConfClient( scheme=SIMAP_SERVER_SCHEME, address=SIMAP_SERVER_ADDRESS, port=SIMAP_SERVER_PORT, username=SIMAP_SERVER_USERNAME, password=SIMAP_SERVER_PASSWORD, logger=RESTCONF_LOGGER, ) self._simap_client = SimapClient(self._restconf_client) self._skipped_devices : Set[str] = set() Loading Loading @@ -618,7 +607,11 @@ class EventDispatcher(BaseEventDispatcher): class SimapUpdater: def __init__(self, terminate : threading.Event, telemetry_pool : TelemetryPool) -> None: def __init__( self, simap_client : SimapClient, telemetry_pool : TelemetryPool, terminate : threading.Event ) -> None: self._simap_client = simap_client self._telemetry_pool = telemetry_pool self._context_client = ContextClient() Loading @@ -628,8 +621,8 @@ class SimapUpdater: ) self._event_dispatcher = EventDispatcher( self._event_collector.get_events_queue(), self._context_client, self._telemetry_pool, terminate=terminate self._event_collector.get_events_queue(), self._simap_client, self._context_client, self._telemetry_pool, terminate=terminate ) def start(self) -> None: Loading