csle_common.controllers package

Submodules

csle_common.controllers.container_controller module

class csle_common.controllers.container_controller.ContainerController[source]

Bases: object

A class for managing Docker containers and virtual networks

static connect_container_to_network(container: csle_common.dao.emulation_config.node_container_config.NodeContainerConfig, logger: logging.Logger) None[source]

Connect a running container to networks

Parameters
  • container – the container to connect

  • logger – the logger to use for logging

Returns

None

static connect_containers_to_networks(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Connects running containers to networks

Parameters
  • emulation_env_config – the emulation config

  • physical_server_ip – the ip of the physical server where the operation is executed

  • logger – the logger to use for logging

Returns

None

static create_network(name: str, subnetmask: str, logger: logging.Logger, driver: str = 'bridge', existing_network_names: Union[None, List[str]] = None) None[source]

Creates a network

Parameters
  • name – the name of the network to create

  • subnetmask – the subnetmask of the network to create

  • logger – the logger to use for logging

  • driver – the driver of the network to create

  • existing_network_names – list of network names, if not None, check if network exists befeore creating

Returns

None

static create_network_from_dto(network_dto: csle_common.dao.emulation_config.container_network.ContainerNetwork, logger: logging.Logger, existing_network_names=None) None[source]

Creates a network from a given DTO representing the network

Parameters
  • network_dto – details of the network to create

  • existing_network_names – list of network names, if not None, check if network exists befeore creating

  • logger – the logger to use for logging

Returns

None

static create_networks(containers_config: csle_common.dao.emulation_config.containers_config.ContainersConfig, logger: logging.Logger) None[source]

Creates docker networks for a given containers configuration

Parameters
  • logger – the logger to use for logging

  • containers_config – the containers configuration

Returns

None

static get_docker_stats_manager_status(docker_stats_manager_config: csle_common.dao.emulation_config.docker_stats_manager_config.DockerStatsManagerConfig) docker_stats_manager_pb2.DockerStatsMonitorDTO[source]

Sends a request to get the status of the docker stats manager

Parameters

docker_stats_manager_config – the docker stats manager configuration

Returns

None

static get_docker_stats_manager_status_by_ip_and_port(ip: str, port: int) docker_stats_manager_pb2.DockerStatsMonitorDTO[source]

Sends a request to get the status of the docker stats manager

Parameters
  • ip – ip of the host where the stats manager is running

  • port – port that the host manager is listening to

Returns

None

static get_docker_stats_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], physical_host_ip: str, logger: logging.Logger) csle_common.dao.emulation_config.docker_stats_managers_info.DockerStatsManagersInfo[source]

Extracts the information of the Docker stats managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • active_ips – list of active IPs

  • physical_host_ip – the ip of the physical host

  • logger – the logger to use for logging

Returns

a DTO with the status of the Docker stats managers

static get_docker_stats_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the IPS of the Docker stats managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_docker_stats_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the ports of the Docker stats managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of ports

static get_network_references()[source]
Returns

a list of Docker network references

static is_emulation_running(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) bool[source]

Checks if a given emulation config is running or not

Parameters

emulation_env_config – the emulation environment configuration

Returns

True if running otherwise False

static list_all_active_networks_for_emulation(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) Tuple[List[csle_common.dao.emulation_config.container_network.ContainerNetwork], List[csle_common.dao.emulation_config.container_network.ContainerNetwork]][source]

Extracts the active networks of a given emulation

Parameters

emulation_env_config – the emulation configuration

Returns

the list of active networks and inactive networks of an emulation

static list_all_images() List[Tuple[str, str, str, str, int]][source]

A utility function for listing all csle images

Returns

a list of the csle images

static list_all_networks() List[str][source]

A utility function for listing all csle networks

Returns

a list of the networks

static list_all_running_containers() List[Tuple[str, str, str]][source]

Lists all running csle containers

Returns

a list of the names of the running containers

static list_all_running_containers_in_emulation(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) Tuple[List[csle_common.dao.emulation_config.node_container_config.NodeContainerConfig], List[csle_common.dao.emulation_config.node_container_config.NodeContainerConfig]][source]

Extracts the running containers and the stopped containers of a given emulation

Parameters

emulation_env_config – the emulation configuration

Returns

the list of running containers and the list of stopped containers

static list_all_stopped_containers() List[Tuple[str, str, str]][source]

Lists all stopped csle containers

Returns

a list of the stopped containers

static list_docker_networks() Tuple[List[str], List[int]][source]

Lists the csle docker networks

Returns

(network names, network ids)

static list_running_emulations() List[str][source]
Returns

A list of names of running emulations

static remove_network(name: str, logger: logging.Logger) None[source]

Removes a network

Parameters
  • name – the name of the network to remove

  • logger – the logger to use for logging

Returns

None

static remove_networks(names: List[str], logger: logging.Logger) bool[source]

Removes a network

Parameters
  • name – the name of the network to remove

  • logger – the logger to use for logging

Returns

True if at least one of the networks were successfully removed

static rm_all_images() None[source]

A utility function for removing all csle images

Returns

None

static rm_all_networks(logger: logging.Logger) None[source]

A utility function for removing all csle networks

Parameters

logger – the logger to use for logging

Returns

None

static rm_all_stopped_containers() None[source]

A utility function for removing all stopped containers

Returns

None

static rm_container(container_name: str) bool[source]

Remove a specific container

Parameters

container_name – the container to remove

Returns

True if the container was removed and False otherwise

static rm_image(name) bool[source]

A utility function for removing a specific image

Parameters

name – the name of the image to remove

Returns

True if the image was removed and False otherwise

static rm_network(name, logger: logging.Logger) bool[source]

A utility function for removing a network with a specific name

Parameters
  • name – the name of the network to remove

  • logger – the logger to use for logging

Returns

True if it was removed or False otherwise

static run_command(cmd: str) None[source]

Runs a container management command

Parameters

cmd – the command to run

Returns

None

static start_all_stopped_containers() None[source]

Starts all stopped csle containers

Returns

None

static start_container(name: str) bool[source]

Starts a stopped container with a specific name

Parameters

name – the name of the stopped container to start

Returns

True if started, False otherrwise

static start_docker_stats_thread(execution: csle_common.dao.emulation_config.emulation_execution.EmulationExecution, physical_server_ip: str, logger: logging.Logger) None[source]

Sends a request to the docker stats manager on the docker host for starting a docker stats monitor thread

Parameters
  • execution – the emulation execution

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_all_running_containers() None[source]

Utility function for stopping all running containers

Returns

None

static stop_container(name: str) bool[source]

Utility function for stopping a specific container

Parameters

name – the name of the container to stop

Returns

True if stopped, False otherwise

static stop_docker_stats_thread(execution: csle_common.dao.emulation_config.emulation_execution.EmulationExecution, physical_server_ip: str, logger: logging.Logger) None[source]

Sends a request to the docker stats manager on the docker host for stopping a docker stats monitor thread

Parameters
  • logger – the logger to use for logging

  • execution – the execution of the emulation for which the monitor should be stopped

  • physical_server_ip – the ip of the physical server

Returns

None

csle_common.controllers.elk_controller module

class csle_common.controllers.elk_controller.ELKController[source]

Bases: object

Controller managing API calls to ELK-stacks running inside emulations

static get_elk_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], logger: logging.Logger, physical_host_ip: str) csle_common.dao.emulation_config.elk_managers_info.ELKManagersInfo[source]

Extracts the information of the ELK managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • active_ips – list of active IPs

  • physical_host_ip – the physical host ip

  • logger – the logger to use for logging

Returns

a DTO with the status of the ELK managers

static get_elk_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the IPS of the ELK managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_elk_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the ports of the Elk managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_elk_status(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for querying the ELKManager about the status of the ELK stack

Parameters

emulation_env_config – the emulation config

Returns

an ELKDTO with the status of the server

static get_elk_status_by_port_and_ip(ip: str, port: int) elk_manager_pb2.ElkDTO[source]

Method for querying the ElkManager about the status of the ELK stack

Parameters
  • ip – the ip where the ElkManager is running

  • port – the port the ELkManager is listening to

Returns

an ELKDTO with the status of the server

static start_elastic(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for requesting the ELKManager to start elasticsearch

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

an ELKDTO with the status of the server

static start_elk_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

Utility method for starting the ELK manager

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

None

static start_elk_stack(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for requesting the ELKManager to start the ELK server

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

an ELKDTO with the status of the server

static start_kibana(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for requesting the ELKManager to start kibana

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

an ELKDTO with the status of the server

static start_logstash(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for requesting the ELKManager to start Logstash

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

an ELKDTO with the status of the server

static stop_elastic(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for requesting the ELKManager to start elasticsearch

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

an ELKDTO with the status of the server

static stop_elk_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

Utility method for stopping the ELK manager

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

None

static stop_elk_stack(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for requesting the ELKManager to stop the ELK server

Parameters

emulation_env_config – the emulation env config

Returns

a ELKDTO with the status of the server

static stop_kibana(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for requesting the ELKManager to start kibana

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

an ELKDTO with the status of the server

static stop_logstash(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) elk_manager_pb2.ElkDTO[source]

Method for requesting the ELKManager to start Logstash

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

an ELKDTO with the status of the server

csle_common.controllers.emulation_env_controller module

class csle_common.controllers.emulation_env_controller.EmulationEnvController[source]

Bases: object

Class managing emulation environments

static apply_kafka_config(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Applies the kafka config

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

static clean_all_emulation_executions(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger, leader: bool = False) None[source]

Cleans an emulation

Parameters
  • emulation_env_config – the config of the emulation to clean

  • physical_server_ip – the ip of the physical server to clean the emulation executions

  • leader – boolean flag indicating whether this node is the leader in the Swarm cluster or not

  • logger – the logger to use for logging

Returns

None

static clean_all_executions(physical_server_ip: str, logger: logging.Logger, leader: bool = False) None[source]

Cleans all executions of a given emulation on a given physical server

Parameters
  • physical_server_ip – the ip of the physical server to clean the executions

  • logger – the logger to use for logging

  • leader – boolean flag indicating whether this node is the leader or not

Returns

None

static clean_emulation_execution(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, execution_id: int, physical_server_ip: str, logger: logging.Logger, leader: bool = False) None[source]

Cleans an emulation execution

Parameters
  • execution_id – the id of the execution to clean

  • emulation_env_config – the config of the emulation to clean

  • physical_server_ip – the ip of the physical server to clean the execution

  • leader – boolean flag indicating whether this node is the leader or not

  • logger – the logger to use for logging

Returns

None

static create_execution(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_servers: List[str], logger: logging.Logger, id: int = - 1) csle_common.dao.emulation_config.emulation_execution.EmulationExecution[source]

Creates a new emulation execution

Parameters
  • emulation_env_config – the emulation configuration

  • physical_servers – the physical servers to deploy the containers on

  • id – the id of the execution (if not specified the next available id will be used)

  • logger – the logger to use for logging

Returns

a DTO representing the execution

static create_ssh_tunnel(tunnels_dict: Dict[str, Any], local_port: int, remote_port: int, remote_ip: str, emulation: str, execution_id: int) None[source]

Creates an SSH tunnel to forward the port of a container

Parameters
  • execution – the emulation execution

  • tunnels_dict – a dict with existing tunnels

  • local_port – the local port to forward

  • remote_port – the remote port to forward

  • remote_ip – the remote ip to forward

  • emulation – the name of the emulation

  • execution_id – the id of the execution

Returns

None

static delete_networks_of_emulation_env_config(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger, leader: bool = False) None[source]

Deletes the docker networks

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server to remove the networks

  • leader – boolean flag indicating whether this node is the leader in the Swarm cluster

  • logger – the logger to use for logging

Returns

None

static get_execution_info(execution: csle_common.dao.emulation_config.emulation_execution.EmulationExecution, logger: logging.Logger, physical_server_ip: str) csle_common.dao.emulation_config.emulation_execution_info.EmulationExecutionInfo[source]

Gets runtime information about an execution

Parameters
  • execution – the emulation execution to get the information for

  • logger – the logger to use for logging

  • physical_server_ip – the IP of the physical server

Returns

execution information

static install_csle_collector_and_ryu_libraries(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Installs the latest csle-collector and csle-ryu libraries on all nodes of a given emulation

Parameters
  • emulation_env_config – the emulation configuration

  • physical_server_ip – the IP of the physical servers where the containers are

  • logger – the logger to use for logging

Returns

None

static install_emulation(config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) None[source]

Installs the emulation configuration in the metastore

Parameters

config – the config to install

Returns

None

static ping_all(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Tests the connections between all the containers using ping

Parameters
  • emulation_env_config – the emulation config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static rm_containers(execution: csle_common.dao.emulation_config.emulation_execution.EmulationExecution, physical_server_ip: str, logger: logging.Logger) None[source]

Remove containers in the emulation env config for a given execution

Parameters
  • execution – the execution to remove

  • physical_server_ip – the ip of the physical server to remove the containers

  • logger – the logger to use for logging

Returns

None

static run_container(image: str, name: str, logger: logging.Logger, memory: int = 4, num_cpus: int = 1, create_network: bool = True, version: str = '0.0.1') None[source]

Runs a given container

Parameters
  • image – image of the container

  • name – name of the container

  • memory – memory in GB

  • num_cpus – number of CPUs to allocate

  • create_network – whether to create a virtual network or not

  • version – the version tag

  • logger – the logger to use for logging

Returns

None

static run_containers(emulation_execution: csle_common.dao.emulation_config.emulation_execution.EmulationExecution, physical_host_ip: str, logger: logging.Logger) None[source]

Run containers in the emulation env config

Parameters
  • emulation_execution – the execution DTO

  • physical_host_ip – the ip of the physical host where the containers should be started

  • logger – the logger to use for logging

Returns

None

static save_emulation_image(img: bytes, emulation_name: str) None[source]

Saves the emulation image

Parameters
  • image – the image data

  • emulation_name – the name of the emulation

Returns

None

static start_containers_of_execution(emulation_execution: csle_common.dao.emulation_config.emulation_execution.EmulationExecution, physical_host_ip: str) None[source]

Starts stopped containers in a given emulation execution

Parameters
  • emulation_execution – the execution DTO

  • physical_host_ip – the ip of the physical host

Returns

None

static start_custom_traffic(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, no_traffic: bool = True) None[source]

Utility function for starting traffic generators and client population on a given emulation

Parameters

emulation_env_config – the configuration of the emulation

:param no_traffic boolean flag whether the internal traffic generators should be skipped. :param physical_server_ip: ip of the physical servern :return: None

static stop_all_executions(physical_server_ip: str, logger: logging.Logger) None[source]

Stops all emulation executions

Parameters
  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_all_executions_of_emulation(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Stops all executions of a given emulation

Parameters
  • emulation_env_config – the emulation for which executions should be stopped

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_containers(execution: csle_common.dao.emulation_config.emulation_execution.EmulationExecution, physical_server_ip: str, logger: logging.Logger) None[source]

Stop containers in the emulation env config

Parameters
  • execution – the execution to stop

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_execution_of_emulation(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, execution_id: int, physical_server_ip: str, logger: logging.Logger) None[source]

Stops an execution of a given emulation

Parameters
  • emulation_env_config – the emulation for which executions should be stopped

  • execution_id – the id of the execution to stop

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

static uninstall_emulation(config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) None[source]

Uninstalls the emulation configuration in the metastore

Parameters

config – the config to uninstall

Returns

None

static update_execution_config_w_docker_gw_bridge_ip(execution: csle_common.dao.emulation_config.emulation_execution.EmulationExecution) csle_common.dao.emulation_config.emulation_execution.EmulationExecution[source]

Updates the execution configuration with the IP of the docker gw of the docker swarm

Parameters

execution – the execution to update

Returns

the updated execution

csle_common.controllers.flags_controller module

class csle_common.controllers.flags_controller.FlagsController[source]

Bases: object

Class managing flags in the emulation environments

static create_flags(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Connects to a node in the emulation and creates the flags according to a given flags config

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

csle_common.controllers.host_controller module

class csle_common.controllers.host_controller.HostController[source]

Bases: object

Class controlling host managers and host specific configurations

static config_filebeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, container: csle_common.dao.emulation_config.node_container_config.NodeContainerConfig, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to setup the filebeat configuration

Parameters
  • emulation_env_config – the emulation env config

  • container – the container

  • logger – the logger to use for logging

Returns

None

static config_filebeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and to setup the configuration of filebeat

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static config_heartbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, container: csle_common.dao.emulation_config.node_container_config.NodeContainerConfig, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to setup the heartbeat configuration

Parameters
  • emulation_env_config – the emulation env config

  • container – the container

  • logger – the logger to use for logging

Returns

None

static config_heartbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and to setup the configuration of heartbeat

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static config_metricbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, container: csle_common.dao.emulation_config.node_container_config.NodeContainerConfig, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to setup the metricbeat configuration

Parameters
  • emulation_env_config – the emulation env config

  • container – the container

  • logger – the logger to use for logging

Returns

None

static config_metricbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and to setup the configuration of metricbeat

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static config_packetbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, container: csle_common.dao.emulation_config.node_container_config.NodeContainerConfig, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to setup the packetbeat configuration

Parameters
  • emulation_env_config – the emulation env config

  • container – the container

  • logger – the logger to use for logging

Returns

None

static config_packetbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and to setup the configuration of packetbeat

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static get_host_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], logger: logging.Logger, physical_host_ip: str) csle_common.dao.emulation_config.host_managers_info.HostManagersInfo[source]

Extracts the information of the Host managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • active_ips – list of active IPs

  • logger – the logger to use for logging

  • physical_host_ip – the ip of the physical host

Returns

a DTO with the status of the Host managers

static get_host_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the ips of the Host managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_host_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the ports of the Host managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of ports

static get_host_monitor_thread_status_by_port_and_ip(ip: str, port: int) host_manager_pb2.HostStatusDTO[source]

A method that sends a request to the HostManager on a specific container to get the status of the Host monitor thread

Parameters
  • ip – the ip of the container

  • port – the port of the host manager

Returns

the status of the host manager

static get_host_monitor_threads_statuses(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) List[Tuple[host_manager_pb2.HostStatusDTO, str]][source]

A method that sends a request to the HostManager on every container to get the status of the Host monitor thread

Parameters
  • emulation_env_config – the emulation config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

List of monitor thread statuses

static start_filebeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ips: List[str], logger: logging.Logger, initial_start: bool = False) None[source]

A method that sends a request to the HostManager on a specific IP to start the Host manager and filebeat

Parameters
  • emulation_env_config – the emulation env config

  • ips – IP of the container

  • initial_start – boolean indicating whether this method is called on emulation initialization or not

  • logger – the logger to use for logging

Returns

None

static start_filebeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger, initial_start: bool = False) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and filebeat

Parameters
  • emulation_env_config – the emulation env config

  • initial_start – boolean indicating whether this method is called on emulation initialziation or not

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_heartbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ips: List[str], logger: logging.Logger, initial_start: bool = False) None[source]

A method that sends a request to the HostManager on a specific IP to start the Host manager and heartbeat

Parameters
  • emulation_env_config – the emulation env config

  • ips – IPs of the container

  • initial_start – boolean indicating whether this method is called on emulation initialization or not

  • logger – the logger to use for logging

Returns

None

static start_heartbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger, initial_start: bool = False) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and heartbeat

Parameters
  • emulation_env_config – the emulation env config

  • initial_start – boolean indicating whether this method is called on emulation initialization or not

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_host_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

Utility method for starting the host manager on a specific container

Parameters
  • emulation_env_config – the emulation env config

  • ip – the ip of the container

  • logger – the logger to use for logging

Returns

None

static start_host_managers(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

Utility method for checking if the host manager is running and starting it if it is not running

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

None

static start_host_monitor_thread(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific IP to start the Host manager and the monitor thread

Parameters
  • emulation_env_config – the emulation env config

  • ip – IP of the container

  • logger – the logger to use for logging

Returns

None

static start_host_monitor_threads(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and the monitor thread

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_metricbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ips: List[str], logger: logging.Logger, initial_start: bool = False) None[source]

A method that sends a request to the HostManager on a specific IP to start the Host manager and metricbeat

Parameters
  • emulation_env_config – the emulation env config

  • ips – IP of the container

  • initial_start – boolean indicating whether this method is called on emulation initialization or not

  • logger – the logger to use for logging

Returns

None

static start_metricbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger, initial_start: bool = False) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and metricbeat

Parameters
  • emulation_env_config – the emulation env config

  • initial_start – boolean indicating whether this method is called on emulation initialization or not

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_packetbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ips: List[str], logger: logging.Logger, initial_start: bool = False) None[source]

A method that sends a request to the HostManager on a specific IP to start the Host manager and packetbeat

Parameters
  • emulation_env_config – the emulation env config

  • ips – IP of the container

  • initial_start – boolean indicating whether this method is called on emulation initialization or not

  • logger – the logger to use for logging

Returns

None

static start_packetbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger, initial_start: bool = False) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and packetbeat

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • initial_start – boolean indicating whether this method is called on emulation initialziation or not

  • logger – the logger to use for logging

Returns

None

static start_spark(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ips: List[str], logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific IP to start the Host manager and spark

Parameters
  • emulation_env_config – the emulation env config

  • ips – IPs of the container

  • logger – the logger to use for logging

Returns

None

static start_sparks(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for starting Spark on compute nodes

Parameters
  • emulation_config – the emulation env configuration

  • physical_server_ip – the ip of the phsyical server

  • logger – the logger to use for logging

Returns

None

static stop_filebeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to stop filebeat

Parameters
  • emulation_env_config – the emulation env config

  • ip – the IP of the container

  • logger – the logger to use for logging

Returns

None

static stop_filebeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and to stop filebeat

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the physical host ip

  • logger – the logger to use for logging

Returns

None

static stop_heartbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to stop heartbeat

Parameters
  • emulation_env_config – the emulation env config

  • ip – the IP of the container

  • logger – the logger to use for logging

Returns

None

static stop_heartbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger, physical_server_ip: str) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and to stop heartbeat

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

  • physical_server_ip – the physical server ip

Returns

None

static stop_host_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str) None[source]

Utility method for stopping the host manager on a specific container

Parameters
  • emulation_env_config – the emulation env config

  • ip – the ip of the container

Returns

None

static stop_host_managers(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_host_ip: str) None[source]

Utility method for stopping host managers

Parameters
  • emulation_env_config – the emulation env config

  • physical_host_ip – the ip of the physical host

Returns

None

static stop_host_monitor_thread(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to stop the monitor threads

Parameters
  • emulation_env_config – the emulation env config

  • ip – the IP of the container

  • logger – the logger to use for logging

Returns

None

static stop_host_monitor_threads(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger, physical_host_ip: str) None[source]

A method that sends a request to the HostManager on every container to stop the monitor threads

Parameters
  • emulation_env_config – the emulation env config

  • physical_host_ip – the IP of the physical host

  • logger – the logger to use for logging

Returns

None

static stop_metricbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to stop metricbeat

Parameters
  • emulation_env_config – the emulation env config

  • ip – the IP of the container

  • logger – the logger to use for logging

Returns

None

static stop_metricbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger, physical_server_ip: str) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and to stop metricbeat

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

  • physical_server_ip – the physical server ip

Returns

None

static stop_packetbeat(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific container to stop packetbeat

Parameters
  • emulation_env_config – the emulation env config

  • ip – the IP of the container

  • logger – the logger to use for logging

Returns

None

static stop_packetbeats(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger, physical_server_ip: str) None[source]

A method that sends a request to the HostManager on every container to start the Host manager and to stop packetbeat

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

  • physical_server_ip – the of of the physical host

Returns

None

static stop_spark(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ips: List[str], logger: logging.Logger) None[source]

A method that sends a request to the HostManager on a specific IP to stop spark

Parameters
  • emulation_env_config – the emulation env config

  • ips – IPs of the container

  • logger – the logger to use for logging

Returns

None

static stop_sparks(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for stopping Spark on compute nodes

Parameters
  • emulation_config – the emulation env configuration

  • physical_server_ip – the ip of the phsyical server

  • logger – the logger to use for logging

Returns

None

csle_common.controllers.installation_controller module

class csle_common.controllers.installation_controller.InstallationController[source]

Bases: object

Controller managing installation of CSLE

static install_all_emulations() None[source]

Installs all emulations in the metastore

Returns

None

static install_all_simulations() None[source]

Installs all simulations in the metastore

Returns

None

static install_base_image(image_name: str) None[source]

Installs a given base Docker image

Parameters

image_name – the name of the image to install

Returns

None

static install_base_images() None[source]

Installs all base Docker images

Returns

None

static install_derived_image(image_name: str) None[source]

Installs a given derived Docker image

Parameters

image_name – the name of the image to install

Returns

None

static install_derived_images() None[source]

Installs all derived Docker images

Returns

None

static install_emulation(emulation_name: str) None[source]

Installs a given emulation in the metastore

Parameters

emulation_name – the name of the emulation to install

Returns

None

static install_metastore() None[source]

Installs the metastore

Returns

None

static install_simulation(simulation_name: str) None[source]

Installs a given simulation in the metastore

Parameters

simulation_name – the name of the simulation to uninstall

Returns

None

static uninstall_all_emulations() None[source]

Uninstalls all emulations from the metastoer

Returns

None

static uninstall_all_simulations() None[source]

Uninstalls all simulations from the metastore

Returns

None

static uninstall_base_image(image_name: str) None[source]

Uninstalls a given base Docker image

Parameters

image_name – the name of the image to uninstall

Returns

None

static uninstall_base_images() None[source]

Uninstalls all base Docker images

Returns

None

static uninstall_derived_image(image_name: str) None[source]

Uninstalls a given derived Docker image

Parameters

image_name – the name of the image to uninstall

Returns

None

static uninstall_derived_images() None[source]

Uninstalls all derived Docker images

Returns

None

static uninstall_emulation(emulation_name: str) None[source]

Uninstalls a given emulation in the metastore

Parameters

emulation_name – the name of the emulation to uninstall

Returns

None

static uninstall_metastore() None[source]

Uninstalls the metastore

Returns

None

static uninstall_simulation(simulation_name: str) None[source]

Uninstalls a given simulation in the metastore

Parameters

simulation_name – the name of the simulation to install

Returns

None

csle_common.controllers.kafka_controller module

class csle_common.controllers.kafka_controller.KafkaController[source]

Bases: object

Controller for kafka, implements logic for managing kafka instances.

static configure_broker_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

Method for configuring the broker IPs on the Kafka container

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

a KafkaDTO with the status of the server

static create_topics(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

A method that sends a request to the KafkaManager to create topics according to the given configuration

Parameters
  • emulation_env_config – the configuration of the emulation env

  • logger – the logger to use for logging

Returns

None

static get_kafka_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], logger: logging.Logger, physical_host_ip: str) csle_common.dao.emulation_config.kafka_managers_info.KafkaManagersInfo[source]

Extracts the information of the Kafka managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • logger – the logger to use for logging

  • physical_host_ip – the IP of the physical host

Returns

a DTO with the status of the Kafka managers

static get_kafka_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the IPS of the Kafka managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_kafka_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the IPS of the Kafka managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_kafka_status(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) kafka_manager_pb2.KafkaDTO[source]

Method for querying the KafkaManager about the status of the Kafka server

Parameters

emulation_env_config – the emulation config

Returns

a KafkaDTO with the status of the server

static get_kafka_status_by_port_and_ip(ip: str, port: int) kafka_manager_pb2.KafkaDTO[source]

Method for querying the KafkaManager about the status of the Kafka server

Parameters
  • ip – the ip where the KafkaManager is running

  • port – the port the KafkaManager is listening to

Returns

a KafkaDTO with the status of the server

static start_kafka_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) None[source]

Utility method for starting the Kafka manager

Parameters

emulation_env_config – the emulation env config

Returns

None

static start_kafka_server(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) kafka_manager_pb2.KafkaDTO[source]

Method for requesting the KafkaManager to start the Kafka server

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

a KafkaDTO with the status of the server

static stop_kafka_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) None[source]

Utility method for stopping the Kafka manager

Parameters

emulation_env_config – the emulation env config

Returns

None

static stop_kafka_server(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) kafka_manager_pb2.KafkaDTO[source]

Method for requesting the KafkaManager to stop the Kafka server

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

a KafkaDTO with the status of the server

csle_common.controllers.management_system_controller module

class csle_common.controllers.management_system_controller.ManagementSystemController[source]

Bases: object

Controller managing monitoring tools

static is_cadvisor_running() bool[source]
Returns

True if cadvisor is running, otherwise False

static is_docker_engine_running() bool[source]

Checks if Docker engine is running on the host

Returns

True if Docker engine is running, false otherwise

static is_flask_running() bool[source]

Checks if the flask web server is running on the host

Returns

True if it is running, false otherwise

static is_grafana_running() bool[source]
Returns

True if grafana is running otherwise False

static is_nginx_running() bool[source]

Checks if Nginx is running on the host

Returns

True if nginx is running, false otherwise

static is_node_exporter_running() bool[source]

Checks if node_exporter is running on the host

Returns

True if it is running, false otherwise

static is_pgadmin_running() bool[source]
Returns

True if pgadmin is running, otherwise False

static is_pid_running(pid: int, logger: logging.Logger) bool[source]

Checks if the given pid is running on the host

Parameters
  • pid – the pid to check

  • logger – the logger to use for logging

Returns

True if it is running, false otherwise

static is_postgresql_running() bool[source]

Checks if PostgreSQL is running on the host

Returns

True if PostgreSQL is running, false otherwise

static is_prometheus_running() bool[source]

Checks if prometheus is running on the host

Returns

True if it is running, false otherwise

static is_statsmanager_running() bool[source]

Checks if the statsmanager is running on the host

Returns

True if it is running, false otherwise

static read_pid_file(path: str) int[source]

Reads the PID from a pidfile

Parameters

path – the path to the file

Returns

the parsed pid, or -1 if the pidfile could not be read

static start_cadvisor(logger: logging.Logger) bool[source]

Starts cAdvisor

Parameters

logger – the logger to use for logging

Returns

True if cadvisor was started, otherwise False

static start_docker_engine(logger: logging.RootLogger) Tuple[bool, Any, Any][source]

Starts the Docker engine

Parameters

logger – the logger to use for logging

Returns

True if nginx was started, otherwise False

static start_docker_statsmanager(logger: logging.Logger, log_file: str = 'docker_stats_manager.log', log_dir: str = '/var/log/csle', max_workers: int = 10, port: int = 50046) bool[source]

Starts the docker stats manager on the docker host if it is not already started

Parameters
  • logger – the logger to use for logging

  • port – the port that the docker stats manager will listen to

  • log_file – log file of the docker stats manager

  • log_dir – log dir of the docker stats manager

  • max_workers – max workers of the docker stats manager

Returns

True if it was started, False otherwise

static start_flask(logger: logging.Logger) bool[source]

Starts the Flask REST API Server

Parameters

logger – the logger to use for logging

Returns

True if it was started, False otherwise

static start_grafana(logger: logging.RootLogger) bool[source]

Starts Grafana

Parameters

logger – the logger to use for logging

Returns

True if grafana was started, otherwise False

static start_nginx(logger: logging.RootLogger) Tuple[bool, Any, Any][source]

Starts Nginx

Parameters

logger – the logger to use for logging

Returns

True if nginx was started, otherwise False

static start_node_exporter(logger: logging.Logger) bool[source]

Starts the node exporter

Parameters

logger – the logger to use for logging

Returns

True if it was started, False otherwise

static start_pgadmin(logger: logging.RootLogger) bool[source]

Starts pgAdmin

Parameters

logger – the logger to use for logging

Returns

True if pgadmin was started, otherwise False

static start_postgresql(logger: logging.RootLogger) Tuple[bool, Any, Any][source]

Starts PostgreSQL

Parameters

logger – the logger to use for logging

Returns

True if postgresql was started, otherwise False

static start_prometheus(logger: logging.Logger) bool[source]

Starts Prometheus

Parameters

logger – the logger to use for logging

Returns

True if it was started, False otherwise

static stop_cadvisor() bool[source]
Returns

True if cadvisor was stopped, otherwise False

static stop_cluster_manager() bool[source]

Stops the local cluster manager

Returns

True if it was stopped, False otherwise

static stop_docker_engine(logger: logging.RootLogger) Tuple[bool, Any, Any][source]

Stops the Docker engine

Parameters

logger – the logger to use for logging

Returns

True if postgresql was stopped, otherwise False

static stop_docker_statsmanager(logger: logging.Logger) bool[source]

Stops the statsmanager

Parameters

logger – the logger to use for logging

Returns

True if it was stopped, False otherwise

static stop_flask(logger: logging.Logger) bool[source]

Stops the flask REST API

Parameters

logger – the logger to use for logging

Returns

True if it was stopped, False otherwise

static stop_grafana() bool[source]

Stops Grafana

Returns

True if grafana was stopped, otherwise False

static stop_nginx(logger: logging.RootLogger) Tuple[bool, Any, Any][source]

Stops Nginx

Parameters

logger – the logger to use for logging

Returns

True if postgresql was stopped, otherwise False

static stop_node_exporter(logger: logging.Logger) bool[source]

Stops the node exporter

Parameters

logger – the logger to use for logging

Returns

True if it was stopped, False otherwise

static stop_pgadmin() bool[source]
Returns

True if pgadmin was stopped, otherwise False

static stop_pid(pid, logger: logging.Logger) bool[source]

Stops a process with a given pid

Parameters

pid – the pid to stop

Returns

True if the pid was stopped, false if it was not running

static stop_postgresql(logger: logging.RootLogger) Tuple[bool, Any, Any][source]

Stops PostgreSQL

Parameters

logger – the logger to use for logging

Returns

True if postgresql was stopped, otherwise False

static stop_prometheus(logger: logging.RootLogger) bool[source]

Stops Prometheus

Parameters

logger – the logger to use for logging

Returns

True if it was stopped, False otherwise

csle_common.controllers.ossec_ids_controller module

class csle_common.controllers.ossec_ids_controller.OSSECIDSController[source]

Bases: object

Class controlling OSSEC IDS running on nodes in the emulations, as well as OSSECIDS managers

static get_ossec_ids_monitor_thread_status_by_ip_and_port(port: int, ip: str) ossec_ids_manager_pb2.OSSECIdsMonitorDTO[source]

A method that sends a request to the OSSECIDSManager with a specific port and ip to get the status of the IDS monitor thread

Parameters
  • port – the port of the OSSECIDSManager

  • ip – the ip of the OSSECIDSManager

Returns

the status of the OSSECIDSManager

static get_ossec_idses_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the IPS of the OSSEC IDS managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_ossec_idses_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the ports of the OSSEC IDS managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of ports

static get_ossec_idses_monitor_threads_statuses(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str) List[ossec_ids_manager_pb2.OSSECIdsMonitorDTO][source]

A method that sends a request to the OSSECIDSManager on every container to get the status of the IDS monitor thread

Parameters
  • emulation_env_config – the emulation config

  • physical_server_ip – the IP of the physical server

Returns

List of monitor thread statuses

static get_ossec_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], logger: logging.Logger, physical_host_ip: str) csle_common.dao.emulation_config.ossec_managers_info.OSSECIDSManagersInfo[source]

Extracts the information of the OSSEC IDS managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • active_ips – list of active IPs

  • physical_host_ip – the physical host ip

  • logger – the logger to use for logging

Returns

a DTO with the status of the OSSEC IDS managers

static start_ossec_ids(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str) None[source]

Utility function for starting a OSSEC IDS with a specific IP

Parameters
  • emulation_config – the emulation env configuration

  • ip – the IP of the node where the OSSEC IDS should be started

Returns

None

static start_ossec_ids_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str) None[source]

Utility method for starting the OSSEC IDS manager on a specific container

Parameters
  • emulation_env_config – the emulation env config

  • ip – the ip of the container

Returns

None

static start_ossec_ids_monitor_thread(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str) None[source]

A method that sends a request to the OSSECIDSManager on a specific IP to start to start the IDS manager and the monitor thread

Parameters
  • emulation_env_config – the emulation env config

  • ip – the ip of the container

Returns

None

static start_ossec_idses(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for starting the OSSEC IDSes

Parameters
  • emulation_config – the emulation env configuration

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_ossec_idses_managers(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str) None[source]

Utility method for starting OSSEC IDS managers

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

Returns

None

static start_ossec_idses_monitor_threads(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the OSSECIDSManager on every container that runs an IDS to start the IDS manager and the monitor thread

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_ossec_ids(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str) None[source]

Utility function for stopping an OSSEC IDS with a specific IP

Parameters
  • emulation_config – the emulation env configuration

  • ip – the IP of the node where the OSSEC IDS should be stopped

Returns

None

static stop_ossec_ids_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str) None[source]

Utility method for stopping an ossec ids manager with a speicific IP

Parameters
  • emulation_env_config – the emulation env config

  • ip – the ip of the container

Returns

None

static stop_ossec_ids_monitor_thread(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str) None[source]

A method that sends a request to the OSSECIDSManager for a specific IP to stop the monitor threads

Parameters
  • emulation_env_config – the emulation env config

  • ip – the ip of the container

Returns

None

static stop_ossec_idses(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_host_ip: str) None[source]

Utility function for stopping the OSSEC IDSes

Parameters
  • emulation_config – the emulation env configuration

  • physical_host_ip – the physical host ip

Returns

None

static stop_ossec_idses_managers(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str) None[source]

Utility method for stopping ossec ids managers

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the IP of the physical host

Returns

None

static stop_ossec_idses_monitor_threads(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str) None[source]

A method that sends a request to the OSSECIDSManager on every container that runs an IDS to stop the monitor threads

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

Returns

None

csle_common.controllers.ovs_controller module

class csle_common.controllers.ovs_controller.OVSController[source]

Bases: object

Class that contains functionality for interacting and managing OVS bridges in CSLE

static apply_ovs_config(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Aplies the OVS configuration on the OVS switches

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

static create_virtual_switches_on_container(containers_config: csle_common.dao.emulation_config.containers_config.ContainersConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Sets up OVS switches on containers

Parameters
  • containers_config – the containers configuration

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

csle_common.controllers.resource_constraints_controller module

class csle_common.controllers.resource_constraints_controller.ResourceConstraintsController[source]

Bases: object

Class managing resource constraints in the emulation environments

static apply_resource_constraints(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Creates users in an emulation environment according to a specified users-configuration

Parameters
  • emulation_env_config – the emulation env configuration

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

csle_common.controllers.sdn_controller_manager module

class csle_common.controllers.sdn_controller_manager.SDNControllerManager[source]

Bases: object

Class managing interaction with the SDN controller

static get_ryu_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], logger: logging.Logger, physical_server_ip: str) csle_common.dao.emulation_config.ryu_managers_info.RyuManagersInfo[source]

Extracts the information of the Ryu managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • active_ips – list of active IPs

  • logger – the logger to use for logging

  • physical_server_ip – the ip of the physical server

Returns

a DTO with the status of the Ryu managers

static get_ryu_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the IPS of the Ryu managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_ryu_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the ports of the Ryu managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_ryu_status(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) ryu_manager_pb2.RyuDTO[source]

Method for querying the RyuManager about the status of the Ryu SDN controller

Parameters
  • emulation_env_config – the emulation config

  • logger – the logger to use for logging

Returns

a RyuDTO with the status

static get_ryu_status_by_port_and_ip(ip: str, port: int) ryu_manager_pb2.RyuDTO[source]

Method for querying the RyuManager about the status of the Ryu SDN controller

Parameters
  • ip – the ip where the RyuManager is running

  • port – the port the RyuManager is listening to

Returns

an RyuDTO with the status

static start_ryu(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) ryu_manager_pb2.RyuDTO[source]

Method for requesting the RyuManager to start the Ryu SDN controller

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

an RyuDTO with the status of the server

static start_ryu_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

Utility method for starting the Ryu manager

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

None

static start_ryu_monitor(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) ryu_manager_pb2.RyuDTO[source]

Method for requesting the RyuManager to start the Ryu monitor

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

an RyuDTO with the status

static stop_ryu(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) ryu_manager_pb2.RyuDTO[source]

Method for requesting the RyuManager to stop the RYU SDN controller

Parameters

emulation_env_config – the emulation env config

Returns

a RyuDTO with the status of the server

static stop_ryu_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

Utility method for stopping the Ryu manager

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

None

static stop_ryu_monitor(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) ryu_manager_pb2.RyuDTO[source]

Method for requesting the RyuManager to stop the ryu monitor

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

an RyuDTO with the status of the server

csle_common.controllers.simulation_env_controller module

class csle_common.controllers.simulation_env_controller.SimulationEnvController[source]

Bases: object

Class managing operations related to simulation environments

static install_simulation(config: csle_common.dao.simulation_config.simulation_env_config.SimulationEnvConfig) None[source]

Installs the simulation configuration in the metastore

Parameters

config – the configuration to install

Returns

None

static save_simulation_image(img: bytes, simulation: str) None[source]

Saves the simulation image

Parameters
  • image – the image data

  • simulation – the name of the simulation

Returns

None

static uninstall_simulation(config: csle_common.dao.simulation_config.simulation_env_config.SimulationEnvConfig) None[source]

Uninstalls a simulation config from the metastore

Parameters

config – the config to uninstall

Returns

None

csle_common.controllers.snort_ids_controller module

class csle_common.controllers.snort_ids_controller.SnortIDSController[source]

Bases: object

Class managing operations related to Snort IDS Managers

static get_snort_ids_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the IPs of the snort IDS managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_snort_idses_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the ports of the snort IDS managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of ports

static get_snort_idses_monitor_threads_statuses(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger, start_if_stopped: bool = True) List[snort_ids_manager_pb2.SnortIdsMonitorDTO][source]

A method that sends a request to the SnortIDSManager on every container to get the status of the IDS monitor thread

Parameters
  • emulation_env_config – the emulation config

  • start_if_stopped – whether to start the IDS monitor if it is stopped

  • physical_server_ip – the physical server IP

  • logger – the logger to use for logging

Returns

List of monitor thread statuses

static get_snort_idses_monitor_threads_statuses_by_ip_and_port(port: int, ip: str) snort_ids_manager_pb2.SnortIdsMonitorDTO[source]

A method that sends a request to the SnortIDSManager with a specific port and ip to get the status of the IDS monitor thread

Parameters
  • port – the port of the SnortIDSManager

  • ip – the ip of the SnortIDSManager

Returns

the status of the SnortIDSManager

static get_snort_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], logger: logging.Logger, physical_server_ip: str) csle_common.dao.emulation_config.snort_managers_info.SnortIdsManagersInfo[source]

Extracts the information of the Snort managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • active_ips – list of active IPs

  • physical_server_ip – the IP of the physical server

  • logger – the logger to use for logging

Returns

a DTO with the status of the Snort managers

static start_snort_ids(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

Utility function for starting the Snort IDS on a specific IP

Parameters
  • emulation_env_config – the emulation env configuration

  • ip – the ip of the container

  • logger – the logger to use for logging

Returns

None

static start_snort_idses(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for starting the Snort IDSes

Parameters
  • emulation_env_config – the emulation env configuration

  • physical_server_ip – the ip of the phsyical server

  • logger – the logger to use for logging

Returns

None

static start_snort_idses_monitor_thread(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

A method that sends a request to the SnortIDSManager on a specific container that runs an IDS to start the IDS manager and the monitor thread

Parameters
  • emulation_env_config – the emulation env config

  • ip – the ip of the container

  • logger – the logger to use for logging

Returns

None

static start_snort_idses_monitor_threads(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the SnortIDSManager on every container that runs an IDS to start the IDS manager and the monitor thread

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_snort_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

Utility function for starting the snort IDS manager on a specific IP

Parameters
  • emulation_env_config – the emulation env config

  • ip – IP of the container

  • logger – the logger to use for logging

Returns

None

static start_snort_managers(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for starting snort IDS managers

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the physical server ip

  • logger – the logger to use for logging

Returns

None

static stop_snort_ids(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

Utility function for stopping the Snort IDS on a specific IP

Parameters
  • emulation_env_config – the emulation env configuration

  • ip – the ip of the container

  • logger – the logger to use for logging

Returns

None

static stop_snort_idses(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for stopping the Snort IDSes

Parameters
  • emulation_env_config – the emulation env configuration

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_snort_idses_monitor_thread(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

A method that sends a request to the SnortIDSManager on a specific container that runs an IDS to stop the monitor threads

Parameters
  • emulation_env_config – the emulation env config

  • ip – the IP of the container

  • logger – the logger to use for logging

Returns

None

static stop_snort_idses_monitor_threads(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

A method that sends a request to the SnortIDSManager on every container that runs an IDS to stop the monitor threads

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the physical server ip

  • logger – the logger to use for logging

Returns

None

static stop_snort_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, ip: str, logger: logging.Logger) None[source]

Utility function for stopping the snort IDS manager on a specific IP

Parameters
  • emulation_env_config – the emulation env config

  • ip – the IP of the container

  • logger – the logger to use for logging

Returns

None

static stop_snort_managers(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for stopping snort IDS managers

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the physical server ip

  • logger – the logger to use for logging

Returns

None

csle_common.controllers.topology_controller module

class csle_common.controllers.topology_controller.TopologyController[source]

Bases: object

Class managing topologies in the emulation environments

static create_topology(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for connecting to a running emulation and creating the configuration

Parameters
  • emulation_env_config – the emulation configuration

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

csle_common.controllers.traffic_controller module

class csle_common.controllers.traffic_controller.TrafficController[source]

Bases: object

Class managing traffic generators in the emulation environments

static get_client_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], logger: logging.Logger) csle_common.dao.emulation_config.client_managers_info.ClientManagersInfo[source]

Extracts the information of the Client managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • active_ips – list of active IPs

  • logger – the logger to use for logging

Returns

a DTO with the status of the Client managers

static get_client_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the IPS of the Client managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_client_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the ports of the Client managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of ports

static get_clients_dto_by_ip_and_port(ip: str, port: int, logger: logging.Logger) client_manager_pb2.ClientsDTO[source]

A method that sends a request to the ClientManager on a specific container to get its status

Parameters
  • ip – the ip of the container

  • port – the port of the client manager running on the container

  • logger – the logger to use for logging

Returns

the status of the clientmanager

static get_num_active_clients(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) client_manager_pb2.ClientsDTO[source]

Gets the number of active clients

Parameters
  • emulation_env_config – the emulation configuration

  • logger – the logger to use for logging

Returns

A ClientDTO which contains the number of active clients

static get_traffic_manager_status_by_port_and_ip(ip: str, port: int) traffic_manager_pb2.TrafficDTO[source]

A method that sends a request to the TrafficManager on a specific container to get its status

Parameters

emulation_env_config – the emulation config

Returns

the status of the traffic manager

static get_traffic_managers_info(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, active_ips: List[str], physical_host_ip: str, logger: logging.Logger) csle_common.dao.emulation_config.traffic_managers_info.TrafficManagersInfo[source]

Extracts the information of the traffic managers for a given emulation

Parameters
  • emulation_env_config – the configuration of the emulation

  • active_ips – list of active IPs

  • physical_host_ip – the ip of the physical host

  • logger – the logger to use for logging

Returns

a DTO with the status of the traffic managers

static get_traffic_managers_ips(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[str][source]

A method that extracts the ips of the traffic managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of IP addresses

static get_traffic_managers_ports(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig) List[int][source]

A method that extracts the ports of the Traffic managers in a given emulation

Parameters

emulation_env_config – the emulation env config

Returns

the list of ports

static start_client_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) bool[source]

Utility method starting the client manager

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

True if the client manager was started, False otherwise

static start_client_population(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Starts the arrival process of clients

Parameters
  • emulation_env_config – the emulation environment configuration

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_client_producer(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Starts the Kafka producer for client metrics

Parameters
  • emulation_env_config – the emulation environment configuration

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_internal_traffic_generator(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, node_traffic_config: csle_common.dao.emulation_config.node_traffic_config.NodeTrafficConfig, container: csle_common.dao.emulation_config.node_container_config.NodeContainerConfig, logger: logging.Logger) None[source]

Utility function for starting internal traffic generators

Parameters
  • emulation_env_config – the configuration of the emulation env

  • node_traffic_config – the node traffic configuration

  • container – the container

  • logger – the logger to use for logging

Returns

None

static start_internal_traffic_generators(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility function for starting internal traffic generators

Parameters
  • emulation_env_config – the configuration of the emulation env

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static start_traffic_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, node_traffic_config: csle_common.dao.emulation_config.node_traffic_config.NodeTrafficConfig, logger: logging.Logger) None[source]

Utility method for starting traffic manager on a specific container

Parameters
  • emulation_env_config – the emulation env config

  • node_traffic_config – traffic config of the container

  • logger – the logger to use for logging

Returns

None

static start_traffic_managers(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility method for checking if the traffic manager is running and starting it if it is not running on every node

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_client_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

Utility method starting the client manager

Parameters

emulation_env_config – the emulation env config

Returns

None

static stop_client_population(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger) None[source]

Function for stopping the client arrival process of an emulation

Parameters
  • emulation_env_config – the emulation env config

  • logger – the logger to use for logging

Returns

None

static stop_client_producer(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Stops the Kafka producer for client metrics

Parameters
  • emulation_env_config – the emulation environment configuration

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_internal_traffic_generator(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, node_traffic_config: csle_common.dao.emulation_config.node_traffic_config.NodeTrafficConfig, logger: logging.Logger) None[source]

Utility function for stopping a specific internal traffic generator

Parameters
  • emulation_env_config – the configuration of the emulation env

  • logger – the logger to use for logging

  • node_traffic_config – the node traffic config

Returns

None

static stop_internal_traffic_generators(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, logger: logging.Logger, physical_server_ip: str) None[source]

Utility function for stopping internal traffic generators

Parameters
  • emulation_env_config – the configuration of the emulation env

  • physical_server_ip – the ip of the physical server

  • logger – the logger to use for logging

Returns

None

static stop_traffic_manager(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, node_traffic_config: csle_common.dao.emulation_config.node_traffic_config.NodeTrafficConfig, logger: logging.Logger) None[source]

Utility method for stopping a specific traffic manager

Parameters
  • emulation_env_config – the emulation env config

  • node_traffic_config – the node traffic configuration

  • logger – the logger to use for logging

Returns

None

static stop_traffic_managers(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Utility method for stopping traffic managers on a given server

Parameters
  • emulation_env_config – the emulation env config

  • physical_server_ip – the ip of the physical server to stop the traffic managers

  • logger – the logger to use for logging

Returns

None

csle_common.controllers.users_controller module

class csle_common.controllers.users_controller.UsersController[source]

Bases: object

Class managing users in the emulation environments

static create_users(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Creates users in an emulation environment according to a specified users-configuration

Parameters
  • emulation_env_config – the emulation env configuration

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

csle_common.controllers.vulnerabilities_controller module

class csle_common.controllers.vulnerabilities_controller.VulnerabilitiesController[source]

Bases: object

Class managing vulnerabilities in the emulation environments

static create_vulns(emulation_env_config: csle_common.dao.emulation_config.emulation_env_config.EmulationEnvConfig, physical_server_ip: str, logger: logging.Logger) None[source]

Creates vulnerabilities in an emulation environment according to a specified vulnerabilities configuration

Parameters
  • emulation_env_config – the emulation environment configuration

  • physical_server_ip – ip of the physical server

  • logger – the logger to use for logging

Returns

None

Module contents