Skip to content
Snippets Groups Projects
Commit d9b1c554 authored by Carlos Natalino Da Silva's avatar Carlos Natalino Da Silva
Browse files

Intermediate changes to the attack manager and attack detector interface. To be continued.

parent 660cb0de
No related branches found
No related tags found
No related merge requests found
...@@ -17,10 +17,16 @@ syntax = "proto3"; ...@@ -17,10 +17,16 @@ syntax = "proto3";
package optical_attack_detector; package optical_attack_detector;
import "context.proto"; import "context.proto";
import "monitoring.proto";
service OpticalAttackDetectorService { service OpticalAttackDetectorService {
// rpc that triggers the attack detection loop // rpc that executes the detection loop for a particular service
rpc DetectAttack (context.ServiceId ) returns (context.Empty) {} rpc DetectAttack (DetectionRequest) returns (context.Empty) {}
} }
message DetectionRequest {
KpiId kpi_id = 1;
context.ServiceId service_id = 7;
}
...@@ -154,9 +154,6 @@ def get_context_updates(service_list: List[ServiceId]): ...@@ -154,9 +154,6 @@ def get_context_updates(service_list: List[ServiceId]):
LOGGER.info("Connected successfully... Waiting for events...") LOGGER.info("Connected successfully... Waiting for events...")
for service in service_list:
kpi_id = create_kpi(monitoring_client, service["service"])
time.sleep(20) time.sleep(20)
while not terminate.wait(timeout=1): while not terminate.wait(timeout=1):
...@@ -190,38 +187,6 @@ def get_context_updates(service_list: List[ServiceId]): ...@@ -190,38 +187,6 @@ def get_context_updates(service_list: List[ServiceId]):
events_collector.stop() events_collector.stop()
# for event in context_client.GetServiceEvents(Empty()):
# LOGGER.info("Event received: {}".format(event))
# if event.event.event_type == EventTypeEnum.EVENTTYPE_CREATE:
# LOGGER.info("Service created: {}".format(event.service_id))
# kpi_id = create_kpi(monitoring_client, event.service_id.service_uuid.uuid)
# service_list.append(
# {
# "context": event.service_id.context_id.context_uuid.uuid,
# "service": event.service_id.service_uuid.uuid,
# "kpi": kpi_id.kpi_id.uuid,
# }
# )
# elif event.event.event_type == EventTypeEnum.EVENTTYPE_REMOVE:
# LOGGER.info("Service removed: {}".format(event.service_id))
# # find service and remove it from the list of currently monitored
# for service in service_list:
# if (
# service["service"] == event.service_id.service_uuid.uuid
# and service["context"]
# == event.service_id.context_id.context_uuid.uuid
# ):
# service_list.remove(service)
# break
# if terminate.is_set(): # if terminate is set
# LOGGER.warning("Stopping execution of the get_context_updates...")
# context_client.close()
# monitoring_client.close()
# break # break the while and stop execution
# LOGGER.debug("Waiting for next event...")
def main(): def main():
global LOGGER # pylint: disable=global-statement global LOGGER # pylint: disable=global-statement
...@@ -230,6 +195,28 @@ def main(): ...@@ -230,6 +195,28 @@ def main():
logging.basicConfig(level=log_level) logging.basicConfig(level=log_level)
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
wait_for_environment_variables(
[
get_env_var_name(
ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_HOST
),
get_env_var_name(
ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_PORT_GRPC
),
]
)
wait_for_environment_variables(
[
get_env_var_name(
ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST
),
get_env_var_name(
ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC
),
]
)
wait_for_environment_variables( wait_for_environment_variables(
[ [
get_env_var_name( get_env_var_name(
...@@ -257,8 +244,10 @@ def main(): ...@@ -257,8 +244,10 @@ def main():
# creating a thread-safe list to be shared among threads # creating a thread-safe list to be shared among threads
service_list = Manager().list() service_list = Manager().list()
service_list.append({"context": "admin", "service": "1213"}) kpi_id = create_kpi(monitoring_client, "1213")
service_list.append({"context": "admin", "service": "1456"}) service_list.append({"context": "admin", "service": "1213", "kpi": kpi_id.kpi_id.uuid})
kpi_id = create_kpi(monitoring_client, "1456")
service_list.append({"context": "admin", "service": "1456", "kpi": kpi_id.kpi_id.uuid})
context_ids: ContextIdList = context_client.ListContextIds(Empty()) context_ids: ContextIdList = context_client.ListContextIds(Empty())
......
grpcio-health-checking
grpcio
prometheus-client
pytest
pytest-benchmark
redis
# from the monitoring component
influxdb
python-json-logger
coverage
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment