#1859 - Added the call to file system reset

This commit is contained in:
Chris McCarthy
2023-11-28 11:58:09 +00:00
parent da955038f5
commit 9a4855e7bd
14 changed files with 95 additions and 27 deletions

View File

@@ -993,6 +993,7 @@ class Node(SimComponent):
def set_original_state(self):
"""Sets the original state."""
print(f"Setting node original state for {self.hostname}")
for software in self.software_manager.software.values():
software.set_original_state()
@@ -1019,6 +1020,7 @@ class Node(SimComponent):
def reset_component_for_episode(self, episode: int):
"""Reset the original state of the SimComponent."""
print(f"Resetting node state for {self.hostname}")
# Reset ARP Cache
self.arp.clear()
@@ -1031,6 +1033,10 @@ class Node(SimComponent):
# 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()
# Reset File System
self.file_system.reset_component_for_episode(episode)
@@ -1039,13 +1045,16 @@ class Node(SimComponent):
for nic in self.nics.values():
nic.reset_component_for_episode(episode)
#
if episode and self.sys_log:
self.sys_log.current_episode = episode
self.sys_log.setup_logger()
super().reset_component_for_episode(episode)
self.power_on()
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
# need a better name and better documentation.

View File

@@ -678,8 +678,9 @@ class Router(Node):
"""Sets the original state."""
self.acl.set_original_state()
self.route_table.set_original_state()
super().set_original_state()
vals_to_include = {"num_ports"}
self._original_state = 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):
"""Reset the original state of the SimComponent."""