#1859 - Re-ordered the node reset function again
This commit is contained in:
@@ -12,6 +12,8 @@ from primaite.simulator.network.hardware.nodes.computer import Computer
|
||||
from primaite.simulator.network.hardware.nodes.router import Router
|
||||
from primaite.simulator.network.hardware.nodes.server import Server
|
||||
from primaite.simulator.network.hardware.nodes.switch import Switch
|
||||
from primaite.simulator.system.applications.application import Application
|
||||
from primaite.simulator.system.services.service import Service
|
||||
|
||||
_LOGGER = getLogger(__name__)
|
||||
|
||||
@@ -56,6 +58,20 @@ class Network(SimComponent):
|
||||
node.reset_component_for_episode(episode)
|
||||
for link in self.links.values():
|
||||
link.reset_component_for_episode(episode)
|
||||
|
||||
for node in self.nodes.values():
|
||||
node.power_on()
|
||||
|
||||
# Reset software
|
||||
for software in node.software_manager.software.values():
|
||||
software.reset_component_for_episode(episode)
|
||||
if isinstance(software, Service):
|
||||
software.start()
|
||||
elif isinstance(software, Application):
|
||||
software.run()
|
||||
|
||||
for nic in node.nics.values():
|
||||
nic.enable()
|
||||
|
||||
def _init_request_manager(self) -> RequestManager:
|
||||
rm = super()._init_request_manager()
|
||||
|
||||
@@ -1035,8 +1035,6 @@ class Node(SimComponent):
|
||||
# Reset File System
|
||||
self.file_system.reset_component_for_episode(episode)
|
||||
|
||||
self.power_on()
|
||||
|
||||
# Reset all Nics
|
||||
for nic in self.nics.values():
|
||||
nic.reset_component_for_episode(episode)
|
||||
@@ -1045,16 +1043,6 @@ class Node(SimComponent):
|
||||
self.sys_log.current_episode = episode
|
||||
self.sys_log.setup_logger()
|
||||
|
||||
# Reset software
|
||||
for software in self.software_manager.software.values():
|
||||
software.reset_component_for_episode(episode)
|
||||
if isinstance(software, Service):
|
||||
software.start()
|
||||
elif isinstance(software, Application):
|
||||
software.run()
|
||||
|
||||
for nic in self.nics.values():
|
||||
nic.enable()
|
||||
|
||||
def _init_request_manager(self) -> RequestManager:
|
||||
# TODO: I see that this code is really confusing and hard to read right now... I think some of these things will
|
||||
|
||||
@@ -37,13 +37,14 @@ class DatabaseClient(Application):
|
||||
"""Sets the original state."""
|
||||
print(f"Setting DatabaseClient WebServer original state on node {self.software_manager.node.hostname}")
|
||||
super().set_original_state()
|
||||
vals_to_include = {"server_ip_address", "server_password", "connected"}
|
||||
vals_to_include = {"server_ip_address", "server_password", "connected", "_query_success_tracker"}
|
||||
self._original_state.update(self.model_dump(include=vals_to_include))
|
||||
|
||||
def reset_component_for_episode(self, episode: int):
|
||||
"""Reset the original state of the SimComponent."""
|
||||
print(f"Resetting DataBaseClient state on node {self.software_manager.node.hostname}")
|
||||
super().reset_component_for_episode(episode)
|
||||
self._query_success_tracker.clear()
|
||||
|
||||
def describe_state(self) -> Dict:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user