#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.router import Router
|
||||||
from primaite.simulator.network.hardware.nodes.server import Server
|
from primaite.simulator.network.hardware.nodes.server import Server
|
||||||
from primaite.simulator.network.hardware.nodes.switch import Switch
|
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__)
|
_LOGGER = getLogger(__name__)
|
||||||
|
|
||||||
@@ -56,6 +58,20 @@ class Network(SimComponent):
|
|||||||
node.reset_component_for_episode(episode)
|
node.reset_component_for_episode(episode)
|
||||||
for link in self.links.values():
|
for link in self.links.values():
|
||||||
link.reset_component_for_episode(episode)
|
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:
|
def _init_request_manager(self) -> RequestManager:
|
||||||
rm = super()._init_request_manager()
|
rm = super()._init_request_manager()
|
||||||
|
|||||||
@@ -1035,8 +1035,6 @@ class Node(SimComponent):
|
|||||||
# Reset File System
|
# Reset File System
|
||||||
self.file_system.reset_component_for_episode(episode)
|
self.file_system.reset_component_for_episode(episode)
|
||||||
|
|
||||||
self.power_on()
|
|
||||||
|
|
||||||
# Reset all Nics
|
# Reset all Nics
|
||||||
for nic in self.nics.values():
|
for nic in self.nics.values():
|
||||||
nic.reset_component_for_episode(episode)
|
nic.reset_component_for_episode(episode)
|
||||||
@@ -1045,16 +1043,6 @@ class Node(SimComponent):
|
|||||||
self.sys_log.current_episode = episode
|
self.sys_log.current_episode = episode
|
||||||
self.sys_log.setup_logger()
|
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:
|
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
|
# 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."""
|
"""Sets the original state."""
|
||||||
print(f"Setting DatabaseClient WebServer original state on node {self.software_manager.node.hostname}")
|
print(f"Setting DatabaseClient WebServer original state on node {self.software_manager.node.hostname}")
|
||||||
super().set_original_state()
|
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))
|
self._original_state.update(self.model_dump(include=vals_to_include))
|
||||||
|
|
||||||
def reset_component_for_episode(self, episode: int):
|
def reset_component_for_episode(self, episode: int):
|
||||||
"""Reset the original state of the SimComponent."""
|
"""Reset the original state of the SimComponent."""
|
||||||
print(f"Resetting DataBaseClient state on node {self.software_manager.node.hostname}")
|
print(f"Resetting DataBaseClient state on node {self.software_manager.node.hostname}")
|
||||||
super().reset_component_for_episode(episode)
|
super().reset_component_for_episode(episode)
|
||||||
|
self._query_success_tracker.clear()
|
||||||
|
|
||||||
def describe_state(self) -> Dict:
|
def describe_state(self) -> Dict:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user