diff --git a/src/dbscanserving/client/DbscanServingClient.py b/src/dbscanserving/client/DbscanServingClient.py index be2394c27efc3dc328a92aaa1f4e8554fb5ac40d..4d6614b5dc44c2b916fb298217fef4a8f1b8e72c 100644 --- a/src/dbscanserving/client/DbscanServingClient.py +++ b/src/dbscanserving/client/DbscanServingClient.py @@ -8,8 +8,8 @@ MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) class DbscanServingClient: - def __init__(self, host, port): - self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) + def __init__(self, address, port): + self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) self.channel = None self.stub = None diff --git a/src/opticalattackmitigator/client/OpticalAttackMitigatorClient.py b/src/opticalattackmitigator/client/OpticalAttackMitigatorClient.py index 99d4a8772dae16c7de9fddd8b13f3148735a9a13..f303dcc3fc8593b20b0a0ab1a7f6d46a724edec1 100644 --- a/src/opticalattackmitigator/client/OpticalAttackMitigatorClient.py +++ b/src/opticalattackmitigator/client/OpticalAttackMitigatorClient.py @@ -8,8 +8,8 @@ MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) class OpticalAttackMitigatorClient: - def __init__(self, host, port): - self.endpoint = '{:s}:{:s}'.format(str(host), str(port)) + def __init__(self, address, port): + self.endpoint = '{:s}:{:s}'.format(str(address), str(port)) LOGGER.debug('Creating channel to {:s}...'.format(str(self.endpoint))) self.channel = None self.stub = None diff --git a/src/opticalattackmitigator/service/OpticalAttackMitigatorServiceServicerImpl.py b/src/opticalattackmitigator/service/OpticalAttackMitigatorServiceServicerImpl.py index cb46159700f7dcf5fa0f256c40fe3f107e764f46..d7cbc6b0956f26fb87e7d2567cc1c9065482cfd4 100644 --- a/src/opticalattackmitigator/service/OpticalAttackMitigatorServiceServicerImpl.py +++ b/src/opticalattackmitigator/service/OpticalAttackMitigatorServiceServicerImpl.py @@ -21,6 +21,6 @@ class OpticalAttackMitigatorServiceServicerImpl(AttackMitigatorServicer): @safe_and_metered_rpc_method(METRICS, LOGGER) def NotifyAttack(self, request : AttackDescription, context : grpc.ServicerContext) -> AttackResponse: LOGGER.debug(f"NotifyAttack: {request}") - response: AttackResponse = AttackDescription() + response: AttackResponse = AttackResponse() response.response_strategy_description = 'The AttackMitigator has received the attack description.' return response diff --git a/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py b/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py index fdbfd91e59027d25ef297a075f4feae0559a7bfe..9cba1253e8e84fcc43de24919e9bb77612c39f3e 100644 --- a/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py +++ b/src/opticalcentralizedattackdetector/service/OpticalCentralizedAttackDetectorServiceServicerImpl.py @@ -45,8 +45,8 @@ class OpticalCentralizedAttackDetectorServiceServicerImpl(OpticalCentralizedAtta self.monitoring_client: MonitoringClient = MonitoringClient(server=MONITORING_SERVICE_ADDRESS, port=MONITORING_GRPC_SERVICE_PORT) self.service_client: ServiceClient = ServiceClient(SERVICE_SERVICE_ADDRESS, SERVICE_GRPC_SERVICE_PORT) self.influxdb_client: InfluxDBClient = InfluxDBClient(host=MONITORING_SERVICE_ADDRESS, port=8086, username=INFLUXDB_USER, password=INFLUXDB_PASSWORD, database=INFLUXDB_DATABASE) - self.dbscanserving_client: DbscanServingClient = DbscanServingClient(host=INFERENCE_SERVICE_ADDRESS, port=DBSCANSERVING_GRPC_SERVICE_PORT) - self.attack_mitigator_client: OpticalAttackMitigatorClient = OpticalAttackMitigatorClient(host=ATTACK_MITIGATOR_SERVICE_ADDRESS, port=ATTACK_MITIGATOR_GRPC_SERVICE_PORT) + self.dbscanserving_client: DbscanServingClient = DbscanServingClient(address=INFERENCE_SERVICE_ADDRESS, port=DBSCANSERVING_GRPC_SERVICE_PORT) + self.attack_mitigator_client: OpticalAttackMitigatorClient = OpticalAttackMitigatorClient(address=ATTACK_MITIGATOR_SERVICE_ADDRESS, port=ATTACK_MITIGATOR_GRPC_SERVICE_PORT) LOGGER.debug('Servicer Created') @safe_and_metered_rpc_method(METRICS, LOGGER) @@ -70,7 +70,6 @@ class OpticalCentralizedAttackDetectorServiceServicerImpl(OpticalCentralizedAtta # get monitoring data for each of the current services results = self.influxdb_client.query('select * from samples;') - print(results.raw) for service in services: for endpoint in service.service_endpoint_ids: diff --git a/src/opticalcentralizedattackdetector/service/__main__.py b/src/opticalcentralizedattackdetector/service/__main__.py index 0b750347653e49a0de5e00ad09e863d65eca42c3..37cff6b7dec1554b69d93148307e074240f2dca2 100644 --- a/src/opticalcentralizedattackdetector/service/__main__.py +++ b/src/opticalcentralizedattackdetector/service/__main__.py @@ -22,6 +22,7 @@ def signal_handler(signal, frame): # pylint: disable=redefined-outer-name terminate.set() def detect_attack(monitoring_interval): + time.sleep(10) # wait for the service to start LOGGER.info("Starting the attack detection loop") client = OpticalCentralizedAttackDetectorClient(address='localhost', port=GRPC_SERVICE_PORT) client.connect()