Move class docstrings out of init function.
This commit is contained in:
@@ -9,7 +9,6 @@ class AccessControlList:
|
|||||||
"""Access Control List class."""
|
"""Access Control List class."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Init."""
|
|
||||||
self.acl: Dict[str, AccessControlList] = {} # A dictionary of ACL Rules
|
self.acl: Dict[str, AccessControlList] = {} # A dictionary of ACL Rules
|
||||||
|
|
||||||
def check_address_match(self, _rule, _source_ip_address, _dest_ip_address):
|
def check_address_match(self, _rule, _source_ip_address, _dest_ip_address):
|
||||||
|
|||||||
@@ -3,18 +3,16 @@
|
|||||||
|
|
||||||
|
|
||||||
class ACLRule:
|
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):
|
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.permission = _permission
|
||||||
self.source_ip = _source_ip
|
self.source_ip = _source_ip
|
||||||
self.dest_ip = _dest_ip
|
self.dest_ip = _dest_ip
|
||||||
|
|||||||
@@ -3,14 +3,12 @@
|
|||||||
|
|
||||||
|
|
||||||
class Protocol(object):
|
class Protocol(object):
|
||||||
"""Protocol class."""
|
"""Protocol class.
|
||||||
|
|
||||||
|
:param _name: The protocol name
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, _name):
|
def __init__(self, _name):
|
||||||
"""Init.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
_name: The protocol name
|
|
||||||
"""
|
|
||||||
self.name = _name
|
self.name = _name
|
||||||
self.load = 0 # bps
|
self.load = 0 # bps
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,14 @@ from primaite.common.enums import SoftwareState
|
|||||||
|
|
||||||
|
|
||||||
class Service(object):
|
class Service(object):
|
||||||
"""Service class."""
|
"""Service class.
|
||||||
|
|
||||||
def __init__(self, name: str, port: str, software_state: SoftwareState):
|
|
||||||
"""Init.
|
|
||||||
|
|
||||||
:param name: The service name.
|
:param name: The service name.
|
||||||
:param port: The service port.
|
:param port: The service port.
|
||||||
:param software_state: The service SoftwareState.
|
:param software_state: The service SoftwareState.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, name: str, port: str, software_state: SoftwareState):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.port = port
|
self.port = port
|
||||||
self.software_state = software_state
|
self.software_state = software_state
|
||||||
|
|||||||
@@ -6,18 +6,16 @@ from primaite.common.protocol import Protocol
|
|||||||
|
|
||||||
|
|
||||||
class Link(object):
|
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):
|
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.id = _id
|
||||||
self.bandwidth = _bandwidth
|
self.bandwidth = _bandwidth
|
||||||
self.source_node_name = _source_node_name
|
self.source_node_name = _source_node_name
|
||||||
|
|||||||
@@ -11,7 +11,19 @@ _LOGGER: Final[logging.Logger] = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class ActiveNode(Node):
|
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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -25,18 +37,6 @@ class ActiveNode(Node):
|
|||||||
file_system_state: FileSystemState,
|
file_system_state: FileSystemState,
|
||||||
config_values: TrainingConfig,
|
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)
|
super().__init__(node_id, name, node_type, priority, hardware_state, config_values)
|
||||||
self.ip_address: str = ip_address
|
self.ip_address: str = ip_address
|
||||||
# Related to Software
|
# Related to Software
|
||||||
|
|||||||
@@ -7,7 +7,15 @@ from primaite.config.training_config import TrainingConfig
|
|||||||
|
|
||||||
|
|
||||||
class Node:
|
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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -18,15 +26,6 @@ class Node:
|
|||||||
hardware_state: HardwareState,
|
hardware_state: HardwareState,
|
||||||
config_values: TrainingConfig,
|
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.node_id: Final[str] = node_id
|
||||||
self.name: Final[str] = name
|
self.name: Final[str] = name
|
||||||
self.node_type: Final[NodeType] = node_type
|
self.node_type: Final[NodeType] = node_type
|
||||||
|
|||||||
@@ -3,7 +3,16 @@
|
|||||||
|
|
||||||
|
|
||||||
class NodeStateInstructionGreen(object):
|
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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -15,17 +24,6 @@ class NodeStateInstructionGreen(object):
|
|||||||
_service_name,
|
_service_name,
|
||||||
_state,
|
_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.id = _id
|
||||||
self.start_step = _start_step
|
self.start_step = _start_step
|
||||||
self.end_step = _end_step
|
self.end_step = _end_step
|
||||||
|
|||||||
@@ -7,7 +7,19 @@ from primaite.common.enums import NodePOLType
|
|||||||
|
|
||||||
@dataclass()
|
@dataclass()
|
||||||
class NodeStateInstructionRed(object):
|
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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -23,21 +35,6 @@ class NodeStateInstructionRed(object):
|
|||||||
_pol_source_node_service,
|
_pol_source_node_service,
|
||||||
_pol_source_node_service_state,
|
_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.id = _id
|
||||||
self.start_step = _start_step
|
self.start_step = _start_step
|
||||||
self.end_step = _end_step
|
self.end_step = _end_step
|
||||||
|
|||||||
@@ -6,7 +6,15 @@ from primaite.nodes.node import Node
|
|||||||
|
|
||||||
|
|
||||||
class PassiveNode(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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -17,15 +25,6 @@ class PassiveNode(Node):
|
|||||||
hardware_state: HardwareState,
|
hardware_state: HardwareState,
|
||||||
config_values: TrainingConfig,
|
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
|
# Pass through to Super for now
|
||||||
super().__init__(node_id, name, node_type, priority, hardware_state, config_values)
|
super().__init__(node_id, name, node_type, priority, hardware_state, config_values)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,18 @@ _LOGGER: Final[logging.Logger] = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class ServiceNode(ActiveNode):
|
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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -26,18 +37,6 @@ class ServiceNode(ActiveNode):
|
|||||||
file_system_state: FileSystemState,
|
file_system_state: FileSystemState,
|
||||||
config_values: TrainingConfig,
|
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__(
|
super().__init__(
|
||||||
node_id,
|
node_id,
|
||||||
name,
|
name,
|
||||||
|
|||||||
@@ -6,7 +6,19 @@ Used to represent an information flow from source to destination.
|
|||||||
|
|
||||||
|
|
||||||
class IER(object):
|
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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -21,20 +33,6 @@ class IER(object):
|
|||||||
_mission_criticality,
|
_mission_criticality,
|
||||||
_running=False,
|
_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.id = _id
|
||||||
self.start_step = _start_step
|
self.start_step = _start_step
|
||||||
self.end_step = _end_step
|
self.end_step = _end_step
|
||||||
|
|||||||
Reference in New Issue
Block a user