Minor refactor and add comment

This commit is contained in:
Marek Wolan
2024-01-03 16:23:44 +00:00
parent a1dcfa291b
commit 48f1d13fd8

View File

@@ -527,14 +527,7 @@ class NetworkNICAbstractAction(AbstractAction):
nic_num = self.manager.get_nic_num_by_idx(node_idx=node_id, nic_idx=nic_id) nic_num = self.manager.get_nic_num_by_idx(node_idx=node_id, nic_idx=nic_id)
if node_name is None or nic_num is None: if node_name is None or nic_num is None:
return ["do_nothing"] return ["do_nothing"]
return [ return ["network", "node", node_name, "nic", nic_num, self.verb]
"network",
"node",
node_name,
"nic",
nic_num,
self.verb,
]
class NetworkNICEnableAction(NetworkNICAbstractAction): class NetworkNICEnableAction(NetworkNICAbstractAction):
@@ -610,8 +603,8 @@ class ActionManager:
:type game: PrimaiteGame :type game: PrimaiteGame
:param actions: List of action types which should be made available to the agent. :param actions: List of action types which should be made available to the agent.
:type actions: List[str] :type actions: List[str]
:param node_uuids: List of node UUIDs that this agent can act on. :param nodes: Extra configuration for each node.
:type node_uuids: List[str] :type nodes: Dict
:param max_folders_per_node: Maximum number of folders per node. Used for calculating action shape. :param max_folders_per_node: Maximum number of folders per node. Used for calculating action shape.
:type max_folders_per_node: int :type max_folders_per_node: int
:param max_files_per_folder: Maximum number of files per folder. Used for calculating action shape. :param max_files_per_folder: Maximum number of files per folder. Used for calculating action shape.
@@ -690,6 +683,13 @@ class ActionManager:
self.ports: List[str] = ports self.ports: List[str] = ports
self.ip_address_list: List[str] self.ip_address_list: List[str]
# If the user has provided a list of IP addresses, use that. Otherwise, generate a list of IP addresses from
# the nodes in the simulation.
# TODO: refactor. Options:
# 1: This should be pulled out into it's own function for clarity
# 2: The simulation itself should be able to provide a list of IP addresses with its API, rather than having to
# go through the nodes here.
if ip_address_list is not None: if ip_address_list is not None:
self.ip_address_list = ip_address_list self.ip_address_list = ip_address_list
else: else:
@@ -936,7 +936,6 @@ class ActionManager:
obj = cls( obj = cls(
game=game, game=game,
actions=cfg["action_list"], actions=cfg["action_list"],
# node_uuids=cfg["options"]["node_uuids"],
**cfg["options"], **cfg["options"],
protocols=game.options.protocols, protocols=game.options.protocols,
ports=game.options.ports, ports=game.options.ports,