#2064: turn on everything when node is turned on

This commit is contained in:
Czar Echavez
2023-11-23 22:10:53 +00:00
parent f0fc6518a0
commit 2ce03e0262
7 changed files with 126 additions and 48 deletions

View File

@@ -1424,7 +1424,17 @@ class Node(SimComponent):
def _start_up_actions(self):
"""Actions to perform when the node is starting up."""
pass
# Turn on all the services in the node
for service_id in self.services:
self.services[service_id].start()
# Turn on all the applications in the node
for app_id in self.applications:
self.applications[app_id].run()
# Turn off all processes in the node
# for process_id in self.processes:
# self.processes[process_id]
def __contains__(self, item: Any) -> bool:
if isinstance(item, Service):

View File

@@ -2,6 +2,7 @@ from abc import abstractmethod
from enum import Enum
from typing import Any, Dict, Set
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
from primaite.simulator.system.software import IOSoftware, SoftwareHealthState
@@ -61,6 +62,10 @@ class Application(IOSoftware):
def run(self) -> None:
"""Open the Application."""
if self.software_manager and self.software_manager.node.operating_state is not NodeOperatingState.ON:
self.sys_log.error(f"Unable to run application. {self.software_manager.node.hostname} is not turned on.")
return
if self.operating_state == ApplicationOperatingState.CLOSED:
self.sys_log.info(f"Running Application {self.name}")
self.operating_state = ApplicationOperatingState.RUNNING

View File

@@ -42,10 +42,13 @@ class DataManipulationBot(DatabaseClient):
if self.server_ip_address and self.payload:
self.sys_log.info(f"{self.name}: Attempting to start the {self.name}")
super().run()
if not self.connected:
self.connect()
if self.connected:
self.query(self.payload)
self.sys_log.info(f"{self.name} payload delivered: {self.payload}")
else:
self.sys_log.error(f"Failed to start the {self.name} as it requires both a target_ip_address and payload.")
def attack(self):
"""Run the datab manipulation attack."""
if not self.connected:
self.connect()
if self.connected:
self.query(self.payload)
self.sys_log.info(f"{self.name} payload delivered: {self.payload}")