Skip to content

Commit

Permalink
buggs fixed, first test function derived, rest remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
nforsg committed Aug 3, 2023
1 parent 64e2441 commit b56af48
Show file tree
Hide file tree
Showing 12 changed files with 319 additions and 833 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import csle_cluster.cluster_manager.cluster_manager_pb2
import csle_cluster.cluster_manager.query_cluster_manager
from csle_cluster.cluster_manager.cluster_manager_util import ClusterManagerUtil

from csle_common.dao.emulation_config.emulation_execution_info import (
EmulationExecutionInfo,
)

class ClusterController:
"""
Expand Down Expand Up @@ -3486,7 +3488,7 @@ def list_ryu_tunnels(ip: str, port: int) -> csle_cluster.cluster_manager.cluster

@staticmethod
def get_merged_execution_info(execution: EmulationExecution) \
-> csle_cluster.cluster_manager.cluster_manager_pb2.ExecutionInfoDTO:
-> EmulationExecutionInfo:
"""
Gets the runtime info of a specific execution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from csle_collector.docker_stats_manager.docker_stats import DockerStats
from csle_collector.docker_stats_manager.docker_stats_manager_pb2 import DockerStatsMonitorDTO


class DockerStatsUtil:
"""
Utility class for managing docker container statistics
Expand Down Expand Up @@ -184,8 +183,8 @@ def docker_stats_monitor_dto_from_dict(d: Dict[str, Any]) -> DockerStatsMonitorD
"""
docker_stats_monitor_dto = DockerStatsMonitorDTO()
docker_stats_monitor_dto.num_monitors = d["num_monitors"]
docker_stats_monitor_dto.emulations = d["emulations"]
docker_stats_monitor_dto.emulation_executions = d["emulation_executions"]
docker_stats_monitor_dto.emulations.extend(d["emulations"])
docker_stats_monitor_dto.emulation_executions.extend(d["emulation_executions"])
return docker_stats_monitor_dto

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Dict, Any
import csle_collector.elk_manager.elk_manager_pb2

import logging
logger = logging.getLogger()

class ElkManagerUtil:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def from_dict(d: Dict[str, Any]) -> "DockerStatsManagersInfo":
emulation_name=d["emulation_name"], execution_id=d["execution_id"],
docker_stats_managers_statuses=list(map(
lambda x: docker_stats_util.DockerStatsUtil.docker_stats_monitor_dto_from_dict(x),
d["host_managers_statuses"])))
d["docker_stats_managers_statuses"])))
return dto

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import csle_collector.elk_manager.elk_manager_util as elk_manager_util
from csle_base.json_serializable import JSONSerializable


class ELKManagersInfo(JSONSerializable):
"""
DTO containing the status of the ELK managers for a given emulation execution
Expand Down Expand Up @@ -75,7 +74,7 @@ def from_dict(d: Dict[str, Any]) -> "ELKManagersInfo":
dto = ELKManagersInfo(elk_managers_running=d["elk_managers_running"], ips=d["ips"], ports=d["ports"],
emulation_name=d["emulation_name"], execution_id=d["execution_id"],
elk_managers_statuses=list(map(
lambda x: elk_manager_util.ElkManagerUtil.elk_dto_to_dict(x),
lambda x: elk_manager_util.ElkManagerUtil.elk_dto_from_dict(x),
d["elk_managers_statuses"])), local_kibana_port=d["local_kibana_port"],
physical_server_ip=d["physical_server_ip"])
return dto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from csle_common.dao.emulation_config.node_container_config import NodeContainerConfig
from csle_common.dao.emulation_config.container_network import ContainerNetwork
from csle_base.json_serializable import JSONSerializable

import logging
logger = logging.getLogger()

class EmulationExecutionInfo(JSONSerializable):
"""
Expand Down Expand Up @@ -112,6 +113,7 @@ def from_dict(d: Dict[str, Any]) -> "EmulationExecutionInfo":
:return: a dto representation of the object
"""

dto = EmulationExecutionInfo(
emulation_name=d["emulation_name"], execution_id=d["execution_id"],
snort_ids_managers_info=SnortIdsManagersInfo.from_dict(d["snort_ids_managers_info"]),
Expand All @@ -122,11 +124,11 @@ def from_dict(d: Dict[str, Any]) -> "EmulationExecutionInfo":
host_managers_info=HostManagersInfo.from_dict(d["host_managers_info"]),
client_managers_info=ClientManagersInfo.from_dict(d["client_managers_info"]),
docker_stats_managers_info=DockerStatsManagersInfo.from_dict(d["docker_stats_managers_info"]),
running_containers=list(map(lambda x: x.from_dict(), d["running_containers"])),
stopped_containers=list(map(lambda x: x.from_dict(), d["stopped_containers"])),
active_networks=list(map(lambda x: x.from_dict(), d["active_networks"])),
inactive_networks=list(map(lambda x: x.from_dict(), d["inactive_networks"])),
ryu_managers_info=d["ryu_managers_info"])
running_containers=list(map(lambda x: NodeContainerConfig.from_dict(x), d["running_containers"])),
stopped_containers=list(map(lambda x: NodeContainerConfig.from_dict(x), d["stopped_containers"])),
active_networks=list(map(lambda x: ContainerNetwork.from_dict(x), d["active_networks"])),
inactive_networks=list(map(lambda x: ContainerNetwork.from_dict(x), d["inactive_networks"])),
ryu_managers_info=RyuManagersInfo.from_dict(d["ryu_managers_info"]))
return dto

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def from_dict(d: Dict[str, Any]) -> "OSSECIDSManagersInfo":
ossec_ids_managers_running=d["ossec_ids_managers_running"], ips=d["ips"],
emulation_name=d["emulation_name"], ports=d["ports"], execution_id=d["execution_id"],
ossec_ids_managers_statuses=list(
map(lambda x: csle_collector.ossec_ids_manager.ossec_ids_manager_pb2.OSSECIdsMonitorDTO.from_dict(x),
map(lambda x: ossec_ids_manager_util.OSSecManagerUtil.ossec_ids_monitor_dto_from_dict(x),
d["ossec_ids_managers_statuses"])))
return dto

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def from_dict(d: Dict[str, Any]) -> "RyuManagersInfo":
dto = RyuManagersInfo(ryu_managers_running=d["ryu_managers_running"], ips=d["ips"], ports=d["ports"],
emulation_name=d["emulation_name"], execution_id=d["execution_id"],
ryu_managers_statuses=list(map(
lambda x: ryu_manager_util.RyuManagerUtil.ryu_dto_to_dict(x),
lambda x: ryu_manager_util.RyuManagerUtil.ryu_dto_from_dict(x),
d["ryu_managers_statuses"])),
local_controller_web_port=d["local_controller_web_port"],
physical_server_ip=d["physical_server_ip"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def from_dict(d: Dict[str, Any]) -> "TrafficManagersInfo":
dto = TrafficManagersInfo(
traffic_managers_running=d["traffic_managers_running"], ips=d["ips"], ports=d["ports"],
emulation_name=d["emulation_name"], execution_id=d["execution_id"],
traffic_managers_statuses=list(map(lambda x: traffic_manager_util.TrafficManagerUtil.traffic_dto_to_dict(x),
traffic_managers_statuses=list(map(lambda x: traffic_manager_util.TrafficManagerUtil.traffic_dto_from_dict(x),
d["traffic_managers_statuses"])))
return dto

Expand Down
Loading

0 comments on commit b56af48

Please sign in to comment.