Move class docstrings out of init function.

This commit is contained in:
Marek Wolan
2023-07-05 10:14:16 +01:00
parent cda9819e72
commit 38a3666e8e
12 changed files with 105 additions and 123 deletions

View File

@@ -9,7 +9,6 @@ class AccessControlList:
"""Access Control List class."""
def __init__(self):
"""Init."""
self.acl: Dict[str, AccessControlList] = {} # A dictionary of ACL Rules
def check_address_match(self, _rule, _source_ip_address, _dest_ip_address):

View File

@@ -3,18 +3,16 @@
class ACLRule:
"""Access Control List Rule class."""
"""Access Control List Rule class.
:param _permission: The permission (ALLOW or DENY)
:param _source_ip: The source IP address
:param _dest_ip: The destination IP address
:param _protocol: The rule protocol
:param _port: The rule port
"""
def __init__(self, _permission, _source_ip, _dest_ip, _protocol, _port):
"""Init.
Args:
_permission: The permission (ALLOW or DENY)
_source_ip: The source IP address
_dest_ip: The destination IP address
_protocol: The rule protocol
_port: The rule port
"""
self.permission = _permission
self.source_ip = _source_ip
self.dest_ip = _dest_ip

View File

@@ -3,14 +3,12 @@
class Protocol(object):
"""Protocol class."""
"""Protocol class.
:param _name: The protocol name
"""
def __init__(self, _name):
"""Init.
Args:
_name: The protocol name
"""
self.name = _name
self.load = 0 # bps

View File

@@ -5,15 +5,14 @@ from primaite.common.enums import SoftwareState
class Service(object):
"""Service class."""
"""Service class.
:param name: The service name.
:param port: The service port.
:param software_state: The service SoftwareState.
"""
def __init__(self, name: str, port: str, software_state: SoftwareState):
"""Init.
:param name: The service name.
:param port: The service port.
:param software_state: The service SoftwareState.
"""
self.name = name
self.port = port
self.software_state = software_state

View File

@@ -6,18 +6,16 @@ from primaite.common.protocol import Protocol
class Link(object):
"""Link class."""
"""Link class.
:param _id: The IER id
:param _bandwidth: The bandwidth of the link (bps)
:param _source_node_name: The name of the source node
:param _dest_node_name: The name of the destination node
:param _protocols: The protocols to add to the link
"""
def __init__(self, _id, _bandwidth, _source_node_name, _dest_node_name, _services):
"""Init.
Args:
_id: The IER id
_bandwidth: The bandwidth of the link (bps)
_source_node_name: The name of the source node
_dest_node_name: The name of the destination node
_protocols: The protocols to add to the link
"""
self.id = _id
self.bandwidth = _bandwidth
self.source_node_name = _source_node_name

View File

@@ -11,7 +11,19 @@ _LOGGER: Final[logging.Logger] = logging.getLogger(__name__)
class ActiveNode(Node):
"""Active Node class."""
"""Active Node class.
:param node_id: The node ID
:param name: The node name
:param node_type: The node type (enum)
:param priority: The node priority (enum)
:param hardware_state: The node Hardware State
:param ip_address: The node IP address
:param software_state: The node Software State
:param file_system_state: The node file system state
:param config_values: The config values
"""
def __init__(
self,
@@ -25,18 +37,6 @@ class ActiveNode(Node):
file_system_state: FileSystemState,
config_values: TrainingConfig,
):
"""Init.
:param node_id: The node ID
:param name: The node name
:param node_type: The node type (enum)
:param priority: The node priority (enum)
:param hardware_state: The node Hardware State
:param ip_address: The node IP address
:param software_state: The node Software State
:param file_system_state: The node file system state
:param config_values: The config values
"""
super().__init__(node_id, name, node_type, priority, hardware_state, config_values)
self.ip_address: str = ip_address
# Related to Software

View File

@@ -7,7 +7,15 @@ from primaite.config.training_config import TrainingConfig
class Node:
"""Node class."""
"""Node class.
:param node_id: The node id.
:param name: The name of the node.
:param node_type: The type of the node.
:param priority: The priority of the node.
:param hardware_state: The state of the node.
:param config_values: Config values.
"""
def __init__(
self,
@@ -18,15 +26,6 @@ class Node:
hardware_state: HardwareState,
config_values: TrainingConfig,
):
"""Init.
:param node_id: The node id.
:param name: The name of the node.
:param node_type: The type of the node.
:param priority: The priority of the node.
:param hardware_state: The state of the node.
:param config_values: Config values.
"""
self.node_id: Final[str] = node_id
self.name: Final[str] = name
self.node_type: Final[NodeType] = node_type

View File

@@ -3,7 +3,16 @@
class NodeStateInstructionGreen(object):
"""The Node State Instruction class."""
"""The Node State Instruction class.#
:param _id: The node state instruction id
:param _start_step: The start step of the instruction
:param _end_step: The end step of the instruction
:param _node_id: The id of the associated node
:param _node_pol_type: The pattern of life type
:param _service_name: The service name
:param _state: The state (node or service)
"""
def __init__(
self,
@@ -15,17 +24,6 @@ class NodeStateInstructionGreen(object):
_service_name,
_state,
):
"""Init.
Args:
_id: The node state instruction id
_start_step: The start step of the instruction
_end_step: The end step of the instruction
_node_id: The id of the associated node
_node_pol_type: The pattern of life type
_service_name: The service name
_state: The state (node or service)
"""
self.id = _id
self.start_step = _start_step
self.end_step = _end_step

View File

@@ -7,7 +7,19 @@ from primaite.common.enums import NodePOLType
@dataclass()
class NodeStateInstructionRed(object):
"""The Node State Instruction class."""
"""The Node State Instruction class.
:param _id: The node state instruction id
:param _start_step: The start step of the instruction
:param _end_step: The end step of the instruction
:param _target_node_id: The id of the associated node
:param -pol_initiator: The way the PoL is applied (DIRECT, IER or SERVICE)
:param _pol_type: The pattern of life type
:param pol_protocol: The pattern of life protocol/service affected
:param _pol_state: The state (node or service)
:param _pol_source_node_id: The source node Id (used for initiator type SERVICE)
:param _pol_source_node_service: The source node service (used for initiator type SERVICE)
:param _pol_source_node_service_state: The source node service state (used for initiator type SERVICE)
"""
def __init__(
self,
@@ -23,21 +35,6 @@ class NodeStateInstructionRed(object):
_pol_source_node_service,
_pol_source_node_service_state,
):
"""Init.
Args:
_id: The node state instruction id
_start_step: The start step of the instruction
_end_step: The end step of the instruction
_target_node_id: The id of the associated node
-pol_initiator: The way the PoL is applied (DIRECT, IER or SERVICE)
_pol_type: The pattern of life type
-pol_protocol: The pattern of life protocol/service affected
_pol_state: The state (node or service)
_pol_source_node_id: The source node Id (used for initiator type SERVICE)
_pol_source_node_service: The source node service (used for initiator type SERVICE)
_pol_source_node_service_state: The source node service state (used for initiator type SERVICE)
"""
self.id = _id
self.start_step = _start_step
self.end_step = _end_step

View File

@@ -6,7 +6,15 @@ from primaite.nodes.node import Node
class PassiveNode(Node):
"""The Passive Node class."""
"""The Passive Node class.
:param node_id: The node id.
:param name: The name of the node.
:param node_type: The type of the node.
:param priority: The priority of the node.
:param hardware_state: The state of the node.
:param config_values: Config values.
"""
def __init__(
self,
@@ -17,15 +25,6 @@ class PassiveNode(Node):
hardware_state: HardwareState,
config_values: TrainingConfig,
):
"""Init.
:param node_id: The node id.
:param name: The name of the node.
:param node_type: The type of the node.
:param priority: The priority of the node.
:param hardware_state: The state of the node.
:param config_values: Config values.
"""
# Pass through to Super for now
super().__init__(node_id, name, node_type, priority, hardware_state, config_values)

View File

@@ -12,7 +12,18 @@ _LOGGER: Final[logging.Logger] = logging.getLogger(__name__)
class ServiceNode(ActiveNode):
"""ServiceNode class."""
"""ServiceNode class.
:param node_id: The node ID
:param name: The node name
:param node_type: The node type (enum)
:param priority: The node priority (enum)
:param hardware_state: The node Hardware State
:param ip_address: The node IP address
:param software_state: The node Software State
:param file_system_state: The node file system state
:param config_values: The config values
"""
def __init__(
self,
@@ -26,18 +37,6 @@ class ServiceNode(ActiveNode):
file_system_state: FileSystemState,
config_values: TrainingConfig,
):
"""Init.
:param node_id: The node ID
:param name: The node name
:param node_type: The node type (enum)
:param priority: The node priority (enum)
:param hardware_state: The node Hardware State
:param ip_address: The node IP address
:param software_state: The node Software State
:param file_system_state: The node file system state
:param config_values: The config values
"""
super().__init__(
node_id,
name,

View File

@@ -6,7 +6,19 @@ Used to represent an information flow from source to destination.
class IER(object):
"""Information Exchange Requirement class."""
"""Information Exchange Requirement class.
:param _id: The IER id
:param _start_step: The step when this IER should start
:param _end_step: The step when this IER should end
:param _load: The load this IER should put on a link (bps)
:param _protocol: The protocol of this IER
:param _port: The port this IER runs on
:param _source_node_id: The source node ID
:param _dest_node_id: The destination node ID
:param _mission_criticality: Criticality of this IER to the mission (0 none, 5 mission critical)
:param _running: Indicates whether the IER is currently running
"""
def __init__(
self,
@@ -21,20 +33,6 @@ class IER(object):
_mission_criticality,
_running=False,
):
"""Init.
Args:
_id: The IER id
_start_step: The step when this IER should start
_end_step: The step when this IER should end
_load: The load this IER should put on a link (bps)
_protocol: The protocol of this IER
_port: The port this IER runs on
_source_node_id: The source node ID
_dest_node_id: The destination node ID
_mission_criticality: Criticality of this IER to the mission (0 none, 5 mission critical)
_running: Indicates whether the IER is currently running
"""
self.id = _id
self.start_step = _start_step
self.end_step = _end_step