Loading src/l3_distributedattackdetector/service/__main__.py +1 −5 Original line number Diff line number Diff line import logging, signal, sys, threading, os from prometheus_client import start_http_server from common.Settings import get_setting from common.orm.Factory import get_database_backend as get_database from l3_distributedattackdetector.service.l3_distributedattackdetectorService import l3_distributedattackdetectorService from l3_distributedattackdetector.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT Loading Loading @@ -33,12 +32,9 @@ def main(): # Start metrics server start_http_server(metrics_port) # Get database instance database = get_database() # Starting l3_distributedattackdetector service grpc_service = l3_distributedattackdetectorService( database, port=service_port, max_workers=max_workers, grace_period=grace_period) port=service_port, max_workers=max_workers, grace_period=grace_period) grpc_service.start() # Wait for Ctrl+C or termination signal Loading src/l3_distributedattackdetector/service/l3_distributedattackdetectorService.py +2 −4 Original line number Diff line number Diff line Loading @@ -23,13 +23,11 @@ LOGGER = logging.getLogger(__name__) class l3_distributedattackdetectorService: def __init__( self, database, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD, ): self.database = database self.address = address self.port = port self.endpoint = None Loading @@ -52,7 +50,7 @@ class l3_distributedattackdetectorService: self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) self.l3_distributedattackdetector_servicer = ( l3_distributedattackdetectorServiceServicerImpl(self.database) l3_distributedattackdetectorServiceServicerImpl() ) add_L3CentralizedattackdetectorServicer_to_server( self.l3_distributedattackdetector_servicer, self.server Loading @@ -73,7 +71,7 @@ class l3_distributedattackdetectorService: ) # pylint: disable=maybe-no-member LOGGER.debug("Service started") self.l3_distributedattackdetector_servicer.setupl3_distributedattackdetector(self.database) self.l3_distributedattackdetector_servicer.setupl3_distributedattackdetector() LOGGER.debug("IMPL started") def stop(self): Loading src/l3_distributedattackdetector/tests/test_unitary.py +4 −12 Original line number Diff line number Diff line Loading @@ -6,8 +6,6 @@ import os import multiprocessing from subprocess import Popen, DEVNULL from time import sleep from l3_distributedattackdetector.proto.monitoring_pb2 import Kpi, KpiList from common.orm.Factory import get_database_backend as get_database, BackendEnum as DatabaseEngineEnum from l3_distributedattackdetector.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD from l3_distributedattackdetector.client.l3_distributedattackdetectorClient import l3_distributedattackdetectorClient from l3_distributedattackdetector.service.l3_distributedattackdetectorService import l3_distributedattackdetectorService Loading @@ -19,15 +17,9 @@ LOGGER.setLevel(logging.DEBUG) @pytest.fixture(scope='session') def database(): _database = get_database(engine=DatabaseEngineEnum.INMEMORY) return _database @pytest.fixture(scope='session') def l3_distributedattackdetector_service(database): def l3_distributedattackdetector_service(): _service = l3_distributedattackdetectorService( database, port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) _service.start() yield _service _service.stop() Loading @@ -44,10 +36,10 @@ def test_demo(): print('Demo Test') pass def test_tstat(database): def test_tstat(): print('Starting DAD') _service = l3_distributedattackdetectorService( database, port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) p1 = multiprocessing.Process(target=_service.start, args=()) p1.start() Loading Loading
src/l3_distributedattackdetector/service/__main__.py +1 −5 Original line number Diff line number Diff line import logging, signal, sys, threading, os from prometheus_client import start_http_server from common.Settings import get_setting from common.orm.Factory import get_database_backend as get_database from l3_distributedattackdetector.service.l3_distributedattackdetectorService import l3_distributedattackdetectorService from l3_distributedattackdetector.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT Loading Loading @@ -33,12 +32,9 @@ def main(): # Start metrics server start_http_server(metrics_port) # Get database instance database = get_database() # Starting l3_distributedattackdetector service grpc_service = l3_distributedattackdetectorService( database, port=service_port, max_workers=max_workers, grace_period=grace_period) port=service_port, max_workers=max_workers, grace_period=grace_period) grpc_service.start() # Wait for Ctrl+C or termination signal Loading
src/l3_distributedattackdetector/service/l3_distributedattackdetectorService.py +2 −4 Original line number Diff line number Diff line Loading @@ -23,13 +23,11 @@ LOGGER = logging.getLogger(__name__) class l3_distributedattackdetectorService: def __init__( self, database, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD, ): self.database = database self.address = address self.port = port self.endpoint = None Loading @@ -52,7 +50,7 @@ class l3_distributedattackdetectorService: self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) self.l3_distributedattackdetector_servicer = ( l3_distributedattackdetectorServiceServicerImpl(self.database) l3_distributedattackdetectorServiceServicerImpl() ) add_L3CentralizedattackdetectorServicer_to_server( self.l3_distributedattackdetector_servicer, self.server Loading @@ -73,7 +71,7 @@ class l3_distributedattackdetectorService: ) # pylint: disable=maybe-no-member LOGGER.debug("Service started") self.l3_distributedattackdetector_servicer.setupl3_distributedattackdetector(self.database) self.l3_distributedattackdetector_servicer.setupl3_distributedattackdetector() LOGGER.debug("IMPL started") def stop(self): Loading
src/l3_distributedattackdetector/tests/test_unitary.py +4 −12 Original line number Diff line number Diff line Loading @@ -6,8 +6,6 @@ import os import multiprocessing from subprocess import Popen, DEVNULL from time import sleep from l3_distributedattackdetector.proto.monitoring_pb2 import Kpi, KpiList from common.orm.Factory import get_database_backend as get_database, BackendEnum as DatabaseEngineEnum from l3_distributedattackdetector.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD from l3_distributedattackdetector.client.l3_distributedattackdetectorClient import l3_distributedattackdetectorClient from l3_distributedattackdetector.service.l3_distributedattackdetectorService import l3_distributedattackdetectorService Loading @@ -19,15 +17,9 @@ LOGGER.setLevel(logging.DEBUG) @pytest.fixture(scope='session') def database(): _database = get_database(engine=DatabaseEngineEnum.INMEMORY) return _database @pytest.fixture(scope='session') def l3_distributedattackdetector_service(database): def l3_distributedattackdetector_service(): _service = l3_distributedattackdetectorService( database, port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) _service.start() yield _service _service.stop() Loading @@ -44,10 +36,10 @@ def test_demo(): print('Demo Test') pass def test_tstat(database): def test_tstat(): print('Starting DAD') _service = l3_distributedattackdetectorService( database, port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) port=port, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD) p1 = multiprocessing.Process(target=_service.start, args=()) p1.start() Loading