Format docstrings
This commit is contained in:
@@ -25,8 +25,7 @@ class ActiveNode(Node):
|
||||
file_system_state: FileSystemState,
|
||||
config_values: TrainingConfig,
|
||||
):
|
||||
"""
|
||||
Init.
|
||||
"""Init.
|
||||
|
||||
:param node_id: The node ID
|
||||
:param name: The node name
|
||||
@@ -52,8 +51,7 @@ class ActiveNode(Node):
|
||||
|
||||
@property
|
||||
def software_state(self) -> SoftwareState:
|
||||
"""
|
||||
Get the software_state.
|
||||
"""Get the software_state.
|
||||
|
||||
:return: The software_state.
|
||||
"""
|
||||
@@ -61,8 +59,7 @@ class ActiveNode(Node):
|
||||
|
||||
@software_state.setter
|
||||
def software_state(self, software_state: SoftwareState):
|
||||
"""
|
||||
Get the software_state.
|
||||
"""Get the software_state.
|
||||
|
||||
:param software_state: Software State.
|
||||
"""
|
||||
@@ -80,8 +77,7 @@ class ActiveNode(Node):
|
||||
)
|
||||
|
||||
def set_software_state_if_not_compromised(self, software_state: SoftwareState):
|
||||
"""
|
||||
Sets Software State if the node is not compromised.
|
||||
"""Sets Software State if the node is not compromised.
|
||||
|
||||
Args:
|
||||
software_state: Software State
|
||||
@@ -107,8 +103,7 @@ class ActiveNode(Node):
|
||||
self._software_state = SoftwareState.GOOD
|
||||
|
||||
def set_file_system_state(self, file_system_state: FileSystemState):
|
||||
"""
|
||||
Sets the file system state (actual and observed).
|
||||
"""Sets the file system state (actual and observed).
|
||||
|
||||
Args:
|
||||
file_system_state: File system state
|
||||
@@ -134,8 +129,7 @@ class ActiveNode(Node):
|
||||
)
|
||||
|
||||
def set_file_system_state_if_not_compromised(self, file_system_state: FileSystemState):
|
||||
"""
|
||||
Sets the file system state (actual and observed) if not in a compromised state.
|
||||
"""Sets the file system state (actual and observed) if not in a compromised state.
|
||||
|
||||
Use for green PoL to prevent it overturning a compromised state
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ class Node:
|
||||
hardware_state: HardwareState,
|
||||
config_values: TrainingConfig,
|
||||
):
|
||||
"""
|
||||
Init.
|
||||
"""Init.
|
||||
|
||||
:param node_id: The node id.
|
||||
:param name: The name of the node.
|
||||
|
||||
@@ -15,8 +15,7 @@ class NodeStateInstructionGreen(object):
|
||||
_service_name,
|
||||
_state,
|
||||
):
|
||||
"""
|
||||
Init.
|
||||
"""Init.
|
||||
|
||||
Args:
|
||||
_id: The node state instruction id
|
||||
@@ -36,8 +35,7 @@ class NodeStateInstructionGreen(object):
|
||||
self.state = _state
|
||||
|
||||
def get_start_step(self):
|
||||
"""
|
||||
Gets the start step.
|
||||
"""Gets the start step.
|
||||
|
||||
Returns:
|
||||
The start step
|
||||
@@ -45,8 +43,7 @@ class NodeStateInstructionGreen(object):
|
||||
return self.start_step
|
||||
|
||||
def get_end_step(self):
|
||||
"""
|
||||
Gets the end step.
|
||||
"""Gets the end step.
|
||||
|
||||
Returns:
|
||||
The end step
|
||||
@@ -54,8 +51,7 @@ class NodeStateInstructionGreen(object):
|
||||
return self.end_step
|
||||
|
||||
def get_node_id(self):
|
||||
"""
|
||||
Gets the node ID.
|
||||
"""Gets the node ID.
|
||||
|
||||
Returns:
|
||||
The node ID
|
||||
@@ -63,8 +59,7 @@ class NodeStateInstructionGreen(object):
|
||||
return self.node_id
|
||||
|
||||
def get_node_pol_type(self):
|
||||
"""
|
||||
Gets the node pattern of life type (enum).
|
||||
"""Gets the node pattern of life type (enum).
|
||||
|
||||
Returns:
|
||||
The node pattern of life type (enum)
|
||||
@@ -72,8 +67,7 @@ class NodeStateInstructionGreen(object):
|
||||
return self.node_pol_type
|
||||
|
||||
def get_service_name(self):
|
||||
"""
|
||||
Gets the service name.
|
||||
"""Gets the service name.
|
||||
|
||||
Returns:
|
||||
The service name
|
||||
@@ -81,8 +75,7 @@ class NodeStateInstructionGreen(object):
|
||||
return self.service_name
|
||||
|
||||
def get_state(self):
|
||||
"""
|
||||
Gets the state (node or service).
|
||||
"""Gets the state (node or service).
|
||||
|
||||
Returns:
|
||||
The state (node or service)
|
||||
|
||||
@@ -23,8 +23,7 @@ class NodeStateInstructionRed(object):
|
||||
_pol_source_node_service,
|
||||
_pol_source_node_service_state,
|
||||
):
|
||||
"""
|
||||
Init.
|
||||
"""Init.
|
||||
|
||||
Args:
|
||||
_id: The node state instruction id
|
||||
@@ -52,8 +51,7 @@ class NodeStateInstructionRed(object):
|
||||
self.source_node_service_state = _pol_source_node_service_state
|
||||
|
||||
def get_start_step(self):
|
||||
"""
|
||||
Gets the start step.
|
||||
"""Gets the start step.
|
||||
|
||||
Returns:
|
||||
The start step
|
||||
@@ -61,8 +59,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.start_step
|
||||
|
||||
def get_end_step(self):
|
||||
"""
|
||||
Gets the end step.
|
||||
"""Gets the end step.
|
||||
|
||||
Returns:
|
||||
The end step
|
||||
@@ -70,8 +67,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.end_step
|
||||
|
||||
def get_target_node_id(self):
|
||||
"""
|
||||
Gets the node ID.
|
||||
"""Gets the node ID.
|
||||
|
||||
Returns:
|
||||
The node ID
|
||||
@@ -79,8 +75,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.target_node_id
|
||||
|
||||
def get_initiator(self):
|
||||
"""
|
||||
Gets the initiator.
|
||||
"""Gets the initiator.
|
||||
|
||||
Returns:
|
||||
The initiator
|
||||
@@ -88,8 +83,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.initiator
|
||||
|
||||
def get_pol_type(self) -> NodePOLType:
|
||||
"""
|
||||
Gets the node pattern of life type (enum).
|
||||
"""Gets the node pattern of life type (enum).
|
||||
|
||||
Returns:
|
||||
The node pattern of life type (enum)
|
||||
@@ -97,8 +91,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.pol_type
|
||||
|
||||
def get_service_name(self):
|
||||
"""
|
||||
Gets the service name.
|
||||
"""Gets the service name.
|
||||
|
||||
Returns:
|
||||
The service name
|
||||
@@ -106,8 +99,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.service_name
|
||||
|
||||
def get_state(self):
|
||||
"""
|
||||
Gets the state (node or service).
|
||||
"""Gets the state (node or service).
|
||||
|
||||
Returns:
|
||||
The state (node or service)
|
||||
@@ -115,8 +107,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.state
|
||||
|
||||
def get_source_node_id(self):
|
||||
"""
|
||||
Gets the source node id (used for initiator type SERVICE).
|
||||
"""Gets the source node id (used for initiator type SERVICE).
|
||||
|
||||
Returns:
|
||||
The source node id
|
||||
@@ -124,8 +115,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.source_node_id
|
||||
|
||||
def get_source_node_service(self):
|
||||
"""
|
||||
Gets the source node service (used for initiator type SERVICE).
|
||||
"""Gets the source node service (used for initiator type SERVICE).
|
||||
|
||||
Returns:
|
||||
The source node service
|
||||
@@ -133,8 +123,7 @@ class NodeStateInstructionRed(object):
|
||||
return self.source_node_service
|
||||
|
||||
def get_source_node_service_state(self):
|
||||
"""
|
||||
Gets the source node service state (used for initiator type SERVICE).
|
||||
"""Gets the source node service state (used for initiator type SERVICE).
|
||||
|
||||
Returns:
|
||||
The source node service state
|
||||
|
||||
@@ -17,8 +17,7 @@ class PassiveNode(Node):
|
||||
hardware_state: HardwareState,
|
||||
config_values: TrainingConfig,
|
||||
):
|
||||
"""
|
||||
Init.
|
||||
"""Init.
|
||||
|
||||
:param node_id: The node id.
|
||||
:param name: The name of the node.
|
||||
@@ -32,8 +31,7 @@ class PassiveNode(Node):
|
||||
|
||||
@property
|
||||
def ip_address(self) -> str:
|
||||
"""
|
||||
Gets the node IP address as an empty string.
|
||||
"""Gets the node IP address as an empty string.
|
||||
|
||||
No concept of IP address for passive nodes for now.
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ class ServiceNode(ActiveNode):
|
||||
file_system_state: FileSystemState,
|
||||
config_values: TrainingConfig,
|
||||
):
|
||||
"""
|
||||
Init.
|
||||
"""Init.
|
||||
|
||||
:param node_id: The node ID
|
||||
:param name: The node name
|
||||
@@ -53,16 +52,14 @@ class ServiceNode(ActiveNode):
|
||||
self.services: Dict[str, Service] = {}
|
||||
|
||||
def add_service(self, service: Service):
|
||||
"""
|
||||
Adds a service to the node.
|
||||
"""Adds a service to the node.
|
||||
|
||||
:param service: The service to add
|
||||
"""
|
||||
self.services[service.name] = service
|
||||
|
||||
def has_service(self, protocol_name: str) -> bool:
|
||||
"""
|
||||
Indicates whether a service is on a node.
|
||||
"""Indicates whether a service is on a node.
|
||||
|
||||
:param protocol_name: The service (protocol)e.
|
||||
:return: True if service (protocol) is on the node, otherwise False.
|
||||
@@ -73,12 +70,10 @@ class ServiceNode(ActiveNode):
|
||||
return False
|
||||
|
||||
def service_running(self, protocol_name: str) -> bool:
|
||||
"""
|
||||
Indicates whether a service is in a running state on the node.
|
||||
"""Indicates whether a service is in a running state on the node.
|
||||
|
||||
:param protocol_name: The service (protocol)
|
||||
:return: True if service (protocol) is in a running state on the
|
||||
node, otherwise False.
|
||||
:return: True if service (protocol) is in a running state on the node, otherwise False.
|
||||
"""
|
||||
for service_key, service_value in self.services.items():
|
||||
if service_key == protocol_name:
|
||||
@@ -89,12 +84,10 @@ class ServiceNode(ActiveNode):
|
||||
return False
|
||||
|
||||
def service_is_overwhelmed(self, protocol_name: str) -> bool:
|
||||
"""
|
||||
Indicates whether a service is in an overwhelmed state on the node.
|
||||
"""Indicates whether a service is in an overwhelmed state on the node.
|
||||
|
||||
:param protocol_name: The service (protocol)
|
||||
:return: True if service (protocol) is in an overwhelmed state on the
|
||||
node, otherwise False.
|
||||
:return: True if service (protocol) is in an overwhelmed state on the node, otherwise False.
|
||||
"""
|
||||
for service_key, service_value in self.services.items():
|
||||
if service_key == protocol_name:
|
||||
@@ -105,8 +98,7 @@ class ServiceNode(ActiveNode):
|
||||
return False
|
||||
|
||||
def set_service_state(self, protocol_name: str, software_state: SoftwareState):
|
||||
"""
|
||||
Sets the software_state of a service (protocol) on the node.
|
||||
"""Sets the software_state of a service (protocol) on the node.
|
||||
|
||||
:param protocol_name: The service (protocol).
|
||||
:param software_state: The software_state.
|
||||
@@ -134,8 +126,7 @@ class ServiceNode(ActiveNode):
|
||||
)
|
||||
|
||||
def set_service_state_if_not_compromised(self, protocol_name: str, software_state: SoftwareState):
|
||||
"""
|
||||
Sets the software_state of a service (protocol) on the node.
|
||||
"""Sets the software_state of a service (protocol) on the node.
|
||||
|
||||
Done if the software_state is not "compromised".
|
||||
|
||||
@@ -161,8 +152,7 @@ class ServiceNode(ActiveNode):
|
||||
)
|
||||
|
||||
def get_service_state(self, protocol_name):
|
||||
"""
|
||||
Gets the state of a service.
|
||||
"""Gets the state of a service.
|
||||
|
||||
:return: The software_state of the service.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user