Make changes to the way actions work

This commit is contained in:
Marek Wolan
2023-08-28 22:34:20 +01:00
parent a9e969aa13
commit 319e87d200
8 changed files with 83 additions and 70 deletions

View File

@@ -1,6 +1,6 @@
from abc import abstractmethod
from enum import Enum
from typing import Any, Dict, List, Set
from typing import Any, Dict, Set
from primaite.simulator.system.software import IOSoftware
@@ -53,14 +53,6 @@ class Application(IOSoftware):
)
return state
def apply_action(self, action: List[str]) -> None:
"""
Applies a list of actions to the Application.
:param action: A list of actions to apply.
"""
pass
def reset_component_for_episode(self, episode: int):
"""
Resets the Application component for a new episode.

View File

@@ -28,6 +28,8 @@ class DatabaseService(Service):
:param folder_name: Name of the folder which will be setup to hold the db files, defaults to "database"
:type folder_name: str, optional
"""
# note that this parent.file_system.create_folder call in the future will be authenticated by using permissions
# handler. This permission will be granted based on service account given to the database service.
folder = self.parent.file_system.create_folder(folder_name)
self.parent.file_system.create_file("db_primary_store", db_size, FileSystemFileType.MDF, folder=folder)
self.parent.file_system.create_file("db_transaction_log", "1", FileSystemFileType.LDF, folder=folder)

View File

@@ -2,7 +2,6 @@ from abc import abstractmethod
from enum import Enum
from typing import Any, Dict, List
from primaite.simulator.network.hardware.base import Node
from primaite.simulator.system.software import IOSoftware
@@ -33,17 +32,6 @@ class Service(IOSoftware):
operating_state: ServiceOperatingState
"The current operating state of the Service."
@abstractmethod
def __init__(self, parent_node: Node, **kwargs):
"""Create the service on a node.
:param parent_node: The node on which this service runs.
:type parent_node: Node
"""
super().__init__(**kwargs)
self.parent: Node = parent_node
self.parent.software_manager.add_service(self)
@abstractmethod
def describe_state(self) -> Dict:
"""

View File

@@ -1,6 +1,6 @@
from abc import abstractmethod
from enum import Enum
from typing import Any, Dict, List, Set
from typing import Any, Dict, Set
from primaite.simulator.core import SimComponent
from primaite.simulator.network.transmission.transport_layer import Port
@@ -98,17 +98,6 @@ class Software(SimComponent):
)
return state
def apply_action(self, action: List[str]) -> None:
"""
Applies a list of actions to the software.
The specifics of how these actions are applied should be implemented in subclasses.
:param action: A list of actions to apply.
:type action: List[str]
"""
pass
def reset_component_for_episode(self, episode: int):
"""
Resets the software component for a new episode.
@@ -119,6 +108,19 @@ class Software(SimComponent):
"""
pass
def set_health_state(self, health_state: SoftwareHealthState) -> None:
"""
Assign a new health state to this software.
Note: this should only be possible when the software is currently running, but the software base class has no
operating state, only subclasses do. So subclasses will need to implement this check. TODO: check if this should
be changed so that the base Software class has a running attr.
:param health_state: New health state to assign to the software
:type health_state: SoftwareHealthState
"""
self.health_state_actual = health_state
class IOSoftware(Software):
"""