Updates to documentation and inclusion of how-to guides

This commit is contained in:
Charlie Crane
2025-02-27 18:16:45 +00:00
parent 891467d1d3
commit 1f6f007941
25 changed files with 188 additions and 149 deletions

View File

@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated tests that don't use YAMLs to still use the new action and agent schemas - Updated tests that don't use YAMLs to still use the new action and agent schemas
- Nodes now use a config schema and are extensible, allowing for plugin support. - Nodes now use a config schema and are extensible, allowing for plugin support.
- Node tests have been updated to use the new node config schemas when not using YAML files. - Node tests have been updated to use the new node config schemas when not using YAML files.
- Documentation has been updated to include details of extensability with PrimAITE.
### Fixed ### Fixed
- DNS client no longer fails to check its cache if a DNS server address is missing. - DNS client no longer fails to check its cache if a DNS server address is missing.

View File

@@ -28,6 +28,10 @@ What is PrimAITE?
source/how_to_guides/custom_rewards source/how_to_guides/custom_rewards
source/how_to_guides/custom_software source/how_to_guides/custom_software
source/how_to_guides/using_dev_cli source/how_to_guides/using_dev_cli
source/how_to_guides/extensible_actions
source/how_to_guides/extensible_agents
source/how_to_guides/extensible_nodes
source/how_to_guides/extensible_rewards
.. toctree:: .. toctree::
:caption: Usage: :caption: Usage:

View File

@@ -16,6 +16,10 @@ You configuration file should follow the hierarchy seen below:
metadata: metadata:
version: 4.0 version: 4.0
required_plugins:
- name: Example_Plugin
version: 1.0
io_settings: io_settings:
... ...
game: game:
@@ -25,9 +29,17 @@ You configuration file should follow the hierarchy seen below:
simulation: simulation:
... ...
MetaData Tag MetaData
============ ========
It's important to include the metadata tag within your YAML file, as this is used to ensure PrimAITE can interpret the configuration correctly. This should also include any plugins that are required for the defined environment, along with their respective version. It's important to include the metadata tag within your YAML file, as this is used to ensure PrimAITE can interpret the configuration correctly. This should also include any plugins that are required for the defined environment, along with their respective version.
Required Plugins
================
Should your custom environment need any additional PrimAITE plugins, each must be specified under the `required_plugins` tab, as seen in the above example.
Configuration Items
===================
For detailed information about the remaining configuration items found within the configuration file, see :ref:`Configurable Items`. For detailed information about the remaining configuration items found within the configuration file, see :ref:`Configurable Items`.

View File

@@ -9,6 +9,8 @@ Creating Custom Rewards in PrimAITE
Rewards within PrimAITE are contained within ``rewards.py``, which details the rewards available for all agents within training sessions, how they are calculated and any other specific information where necessary. Rewards within PrimAITE are contained within ``rewards.py``, which details the rewards available for all agents within training sessions, how they are calculated and any other specific information where necessary.
Rewards within PrimAITE have been updated to facilitate extensability and the creation of plugins with the release of PrimAITE version 4.0. Additional information about this is covered within :ref:`extensible_rewards`.
Custom Rewards within PrimAITE should inherit from the ``AbstractReward`` class, found in ``rewards.py``. It's important to include an identifier for any class created within PrimAITE. Custom Rewards within PrimAITE should inherit from the ``AbstractReward`` class, found in ``rewards.py``. It's important to include an identifier for any class created within PrimAITE.
.. code:: Python .. code:: Python

View File

@@ -65,4 +65,4 @@ The above action would fail pydantic validation as the discriminator "node-folde
form_request method form_request method
################### ###################
PrimAITE actions need to have a `form_request` method, which can be passed to the `RequestManager` for processing. This allows the custom action to be actioned within the simulation environment. PrimAITE actions need to have a `form_request` method, which can be passed to the `RequestManager` for processing. This allows the custom action to be actioned within the simulation environment. Further information and an example of this can be seen in :ref:`custom_actions`.

View File

@@ -42,7 +42,7 @@ Example code where a node is turned on:
from primaite.simulator.network.hardware.base import Node from primaite.simulator.network.hardware.base import Node
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
node = Node(hostname="pc_a") node = Node(config={"hostname":"pc_a"})
assert node.operating_state is NodeOperatingState.OFF # By default, node is instantiated in an OFF state assert node.operating_state is NodeOperatingState.OFF # By default, node is instantiated in an OFF state
@@ -65,7 +65,7 @@ If the node needs to be instantiated in an on state:
from primaite.simulator.network.hardware.base import Node from primaite.simulator.network.hardware.base import Node
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
node = Node(hostname="pc_a", operating_state=NodeOperatingState.ON) node = Node(config={"hostname":"pc_a", "operating_state":NodeOperatingState.ON})
assert node.operating_state is NodeOperatingState.ON # node is in ON state assert node.operating_state is NodeOperatingState.ON # node is in ON state
@@ -76,7 +76,7 @@ Setting ``start_up_duration`` and/or ``shut_down_duration`` to ``0`` will allow
from primaite.simulator.network.hardware.base import Node from primaite.simulator.network.hardware.base import Node
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
node = Node(hostname="pc_a", start_up_duration=0, shut_down_duration=0) node = Node(config={"hostname":"pc_a", "start_up_duration":0, "shut_down_duration":0})
assert node.operating_state is NodeOperatingState.OFF # node is in OFF state assert node.operating_state is NodeOperatingState.OFF # node is in OFF state
@@ -196,21 +196,23 @@ Setting up a Client-Server Network
def client_server_network() -> Tuple[Computer, Server, Network]: def client_server_network() -> Tuple[Computer, Server, Network]:
network = Network() network = Network()
client = Computer( client = Computer(config={
hostname="client", "hostname":"client",
ip_address="192.168.1.2", "ip_address":"192.168.1.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0, "start_up_duration":0,
}
) )
client.power_on() client.power_on()
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.1.3", "ip_address":"192.168.1.3",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -48,7 +48,7 @@ we'll use the following Network that has a client, server, two switches, and a r
.. code-block:: python .. code-block:: python
router_1 = Router(hostname="router_1", num_ports=3) router_1 = Router(config={"hostname":"router_1", "num_ports":3})
router_1.power_on() router_1.power_on()
router_1.configure_port(port=1, ip_address="192.168.1.1", subnet_mask="255.255.255.0") router_1.configure_port(port=1, ip_address="192.168.1.1", subnet_mask="255.255.255.0")
router_1.configure_port(port=2, ip_address="192.168.2.1", subnet_mask="255.255.255.0") router_1.configure_port(port=2, ip_address="192.168.2.1", subnet_mask="255.255.255.0")
@@ -57,9 +57,9 @@ we'll use the following Network that has a client, server, two switches, and a r
.. code-block:: python .. code-block:: python
switch_1 = Switch(hostname="switch_1", num_ports=6) switch_1 = Switch(config={"hostname":"switch_1", "num_ports":6})
switch_1.power_on() switch_1.power_on()
switch_2 = Switch(hostname="switch_2", num_ports=6) switch_2 = Switch(config={"hostname":"switch_2", "num_ports":6})
switch_2.power_on() switch_2.power_on()
5. Connect the Switches to the Router 5. Connect the Switches to the Router
@@ -75,18 +75,20 @@ we'll use the following Network that has a client, server, two switches, and a r
.. code-block:: python .. code-block:: python
client_1 = Computer( client_1 = Computer(config = {
hostname="client_1", "hostname":"client_1",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.2.1" "default_gateway":"192.168.2.1",
}
) )
client_1.power_on() client_1.power_on()
server_1 = Server( server_1 = Server(config= {
hostname="server_1", "hostname":"server_1",
ip_address="192.168.1.2", "ip_address":"192.168.1.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1" "default_gateway":"192.168.1.1",
}
) )
server_1.power_on() server_1.power_on()

View File

@@ -128,19 +128,19 @@ Python
network = Network() network = Network()
switch = Switch(hostname="switch", start_up_duration=0, num_ports=4) switch = Switch(config={"hostname":"switch", "start_up_duration":0, "num_ports":4})
switch.power_on() switch.power_on()
node_a = Computer(hostname="node_a", ip_address="192.168.0.10", subnet_mask="255.255.255.0", start_up_duration=0) node_a = Computer(config={"hostname":"node_a", "ip_address":"192.168.0.10", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_a.power_on() node_a.power_on()
network.connect(node_a.network_interface[1], switch.network_interface[1]) network.connect(node_a.network_interface[1], switch.network_interface[1])
node_b = Computer(hostname="node_b", ip_address="192.168.0.11", subnet_mask="255.255.255.0", start_up_duration=0) node_b = Computer(config={"hostname":"node_b", "ip_address":"192.168.0.11", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_b.power_on() node_b.power_on()
network.connect(node_b.network_interface[1], switch.network_interface[2]) network.connect(node_b.network_interface[1], switch.network_interface[2])
node_c = Computer(hostname="node_c", ip_address="192.168.0.12", subnet_mask="255.255.255.0", start_up_duration=0) node_c = Computer(config={"hostname":"node_c", "ip_address":"192.168.0.12", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_c.power_on() node_c.power_on()
network.connect(node_c.network_interface[1], switch.network_interface[3]) network.connect(node_c.network_interface[1], switch.network_interface[3])

View File

@@ -67,12 +67,13 @@ Python
from primaite.simulator.system.applications.red_applications.data_manipulation_bot import DataManipulationBot from primaite.simulator.system.applications.red_applications.data_manipulation_bot import DataManipulationBot
from primaite.simulator.system.applications.database_client import DatabaseClient from primaite.simulator.system.applications.database_client import DatabaseClient
client_1 = Computer( client_1 = Computer(config={
hostname="client_1", "hostname":"client_1",
ip_address="192.168.10.21", "ip_address":"192.168.10.21",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.10.1", "default_gateway":"192.168.10.1",
operating_state=NodeOperatingState.ON # initialise the computer in an ON state "operating_state":NodeOperatingState.ON # initialise the computer in an ON state
}
) )
network.connect(endpoint_b=client_1.network_interface[1], endpoint_a=switch_2.network_interface[1]) network.connect(endpoint_b=client_1.network_interface[1], endpoint_a=switch_2.network_interface[1])
client_1.software_manager.install(DatabaseClient) client_1.software_manager.install(DatabaseClient)

View File

@@ -48,12 +48,13 @@ Python
from primaite.simulator.network.hardware.nodes.host.computer import Computer from primaite.simulator.network.hardware.nodes.host.computer import Computer
from primaite.simulator.system.applications.database_client import DatabaseClient from primaite.simulator.system.applications.database_client import DatabaseClient
client = Computer( client_1 = Computer(config={
hostname="client", "hostname":"client_1",
ip_address="192.168.10.21", "ip_address":"192.168.10.21",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.10.1", "default_gateway":"192.168.10.1",
operating_state=NodeOperatingState.ON # initialise the computer in an ON state "operating_state":NodeOperatingState.ON # initialise the computer in an ON state
}
) )
# install DatabaseClient # install DatabaseClient

View File

@@ -45,12 +45,13 @@ Python
from primaite.simulator.system.applications.red_applications.dos_bot import dos-bot from primaite.simulator.system.applications.red_applications.dos_bot import dos-bot
# Create Computer # Create Computer
computer = Computer( computer = Computer(config={
hostname="computer", "hostname":"computer",
ip_address="192.168.1.2", "ip_address":"192.168.1.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0, "start_up_duration":0,
}
) )
computer.power_on() computer.power_on()

View File

@@ -70,39 +70,41 @@ The network we use for these examples is defined below:
router.configure_port(port=1, ip_address="192.168.1.1", subnet_mask="255.255.255.0") router.configure_port(port=1, ip_address="192.168.1.1", subnet_mask="255.255.255.0")
# Set up PC 1 # Set up PC 1
pc_1 = Computer( pc_1 = Computer(config = {
hostname="pc_1", "hostname":"pc_1",
ip_address="192.168.1.11", "ip_address":"192.168.1.11",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0 "start_up_duration":0,
}
) )
pc_1.power_on() pc_1.power_on()
# Set up PC 2 # Set up PC 2
pc_2 = Computer( pc_2 = Computer(config = {
hostname="pc_2", "hostname":"pc_2",
ip_address="192.168.1.12", "ip_address":"192.168.1.12",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0 "start_up_duration":0,
}
) )
pc_2.power_on() pc_2.power_on()
pc_2.software_manager.install(DatabaseService) pc_2.software_manager.install(DatabaseService)
pc_2.software_manager.software["DatabaseService"].start() # start the postgres server pc_2.software_manager.software["DatabaseService"].start() # start the postgres server
# Set up PC 3 # Set up PC 3
pc_3 = Computer( pc_3 = Computer(config = {
hostname="pc_3", "hostname";"pc_3",
ip_address="192.168.1.13", "ip_address":"192.168.1.13",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0 "start_up_duration":0
) )
# Don't power on PC 3 # Don't power on PC 3
# Set up the switch # Set up the switch
switch = Switch(hostname="switch", start_up_duration=0) switch = Switch(config={"hostname":"switch", "start_up_duration":0})
switch.power_on() switch.power_on()
# Connect devices # Connect devices

View File

@@ -52,12 +52,13 @@ Python
from primaite.simulator.system.applications.red_applications.RansomwareScript import RansomwareScript from primaite.simulator.system.applications.red_applications.RansomwareScript import RansomwareScript
from primaite.simulator.system.applications.database_client import DatabaseClient from primaite.simulator.system.applications.database_client import DatabaseClient
client_1 = Computer( client_1 = Computer(config={
hostname="client_1", "hostname":"client_1",
ip_address="192.168.10.21", "ip_address":"192.168.10.21",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.10.1", "default_gateway":"192.168.10.1",
operating_state=NodeOperatingState.ON # initialise the computer in an ON state "operating_state":NodeOperatingState.ON # initialise the computer in an ON state
}
) )
network.connect(endpoint_b=client_1.network_interface[1], endpoint_a=switch_2.network_interface[1]) network.connect(endpoint_b=client_1.network_interface[1], endpoint_a=switch_2.network_interface[1])
client_1.software_manager.install(DatabaseClient) client_1.software_manager.install(DatabaseClient)

View File

@@ -50,12 +50,13 @@ The :ref:`DNSClient` must be configured to use the :ref:`DNSServer`. The :ref:`D
from primaite.simulator.system.applications.web_browser import WebBrowser from primaite.simulator.system.applications.web_browser import WebBrowser
# Create Computer # Create Computer
computer = Computer( computer = Computer(config={
hostname="computer", "hostname":"computer",
ip_address="192.168.1.2", "ip_address":"192.168.1.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0, "start_up_duration":0,
}
) )
computer.power_on() computer.power_on()

View File

@@ -55,12 +55,13 @@ Python
from primaite.simulator.system.services.database.database_service import DatabaseService from primaite.simulator.system.services.database.database_service import DatabaseService
# Create Server # Create Server
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -45,12 +45,13 @@ Python
from primaite.simulator.system.services.dns.dns_client import DNSClient from primaite.simulator.system.services.dns.dns_client import DNSClient
# Create Server # Create Server
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -42,12 +42,13 @@ Python
from primaite.simulator.system.services.dns.dns_server import DNSServer from primaite.simulator.system.services.dns.dns_server import DNSServer
# Create Server # Create Server
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -49,12 +49,13 @@ Python
from primaite.simulator.system.services.ftp.ftp_client import FTPClient from primaite.simulator.system.services.ftp.ftp_client import FTPClient
# Create Server # Create Server
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.10", "default_gateway":"192.168.1.10",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -44,12 +44,13 @@ Python
from primaite.simulator.system.services.ftp.ftp_server import FTPServer from primaite.simulator.system.services.ftp.ftp_server import FTPServer
# Create Server # Create Server
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.10",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -42,12 +42,13 @@ Python
from primaite.simulator.system.services.ntp.ntp_client import NTPClient from primaite.simulator.system.services.ntp.ntp_client import NTPClient
# Create Server # Create Server
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.10",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -44,12 +44,13 @@ Python
from primaite.simulator.system.services.ntp.ntp_server import NTPServer from primaite.simulator.system.services.ntp.ntp_server import NTPServer
# Create Server # Create Server
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.10",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -57,12 +57,13 @@ Python
from primaite.simulator.system.services.terminal.terminal import Terminal from primaite.simulator.system.services.terminal.terminal import Terminal
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
client = Computer( client = Computer(config= {
hostname="client", "hostname":"client",
ip_address="192.168.10.21", "ip_address":"192.168.10.21",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.10.1", "default_gateway":"192.168.10.1",
operating_state=NodeOperatingState.ON, "operating_state":NodeOperatingState.ON,
}
) )
terminal: Terminal = client.software_manager.software.get("Terminal") terminal: Terminal = client.software_manager.software.get("Terminal")
@@ -80,9 +81,9 @@ Creating Remote Terminal Connection
network = Network() network = Network()
node_a = Computer(hostname="node_a", ip_address="192.168.0.10", subnet_mask="255.255.255.0", start_up_duration=0) node_a = Computer(config={"hostname":"node_a", "ip_address":"192.168.0.10", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_a.power_on() node_a.power_on()
node_b = Computer(hostname="node_b", ip_address="192.168.0.11", subnet_mask="255.255.255.0", start_up_duration=0) node_b = Computer(config={"hostname":"node_b", "ip_address":"192.168.0.11", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_b.power_on() node_b.power_on()
network.connect(node_a.network_interface[1], node_b.network_interface[1]) network.connect(node_a.network_interface[1], node_b.network_interface[1])
@@ -106,9 +107,9 @@ Executing a basic application install command
network = Network() network = Network()
node_a = Computer(hostname="node_a", ip_address="192.168.0.10", subnet_mask="255.255.255.0", start_up_duration=0) node_a = Computer(config={"hostname":"node_a", "ip_address":"192.168.0.10", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_a.power_on() node_a.power_on()
node_b = Computer(hostname="node_b", ip_address="192.168.0.11", subnet_mask="255.255.255.0", start_up_duration=0) node_b = Computer(config={"hostname":"node_b", "ip_address":"192.168.0.11", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_b.power_on() node_b.power_on()
network.connect(node_a.network_interface[1], node_b.network_interface[1]) network.connect(node_a.network_interface[1], node_b.network_interface[1])
@@ -134,9 +135,9 @@ Creating a folder on a remote node
network = Network() network = Network()
node_a = Computer(hostname="node_a", ip_address="192.168.0.10", subnet_mask="255.255.255.0", start_up_duration=0) node_a = Computer(config={"hostname":"node_a", "ip_address":"192.168.0.10", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_a.power_on() node_a.power_on()
node_b = Computer(hostname="node_b", ip_address="192.168.0.11", subnet_mask="255.255.255.0", start_up_duration=0) node_b = Computer(config={"hostname":"node_b", "ip_address":"192.168.0.11", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_b.power_on() node_b.power_on()
network.connect(node_a.network_interface[1], node_b.network_interface[1]) network.connect(node_a.network_interface[1], node_b.network_interface[1])
@@ -161,9 +162,9 @@ Disconnect from Remote Node
network = Network() network = Network()
node_a = Computer(hostname="node_a", ip_address="192.168.0.10", subnet_mask="255.255.255.0", start_up_duration=0) node_a = Computer(config={"hostname":"node_a", "ip_address":"192.168.0.10", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_a.power_on() node_a.power_on()
node_b = Computer(hostname="node_b", ip_address="192.168.0.11", subnet_mask="255.255.255.0", start_up_duration=0) node_b = Computer(config={"hostname":"node_b", "ip_address":"192.168.0.11", "subnet_mask":"255.255.255.0", "start_up_duration":0})
node_b.power_on() node_b.power_on()
network.connect(node_a.network_interface[1], node_b.network_interface[1]) network.connect(node_a.network_interface[1], node_b.network_interface[1])

View File

@@ -45,12 +45,13 @@ Python
from primaite.simulator.system.services.web_server.web_server import WebServer from primaite.simulator.system.services.web_server.web_server import WebServer
# Create Server # Create Server
server = Server( server = Server(config = {
hostname="server", "hostname":"server",
ip_address="192.168.2.2", "ip_address":"192.168.2.2",
subnet_mask="255.255.255.0", "subnet_mask":"255.255.255.0",
default_gateway="192.168.1.1", "default_gateway":"192.168.1.1",
start_up_duration=0, "start_up_duration":0,
}
) )
server.power_on() server.power_on()

View File

@@ -23,7 +23,7 @@ See :ref:`Node Start up and Shut down`
from primaite.simulator.system.services.service import ServiceOperatingState from primaite.simulator.system.services.service import ServiceOperatingState
from primaite.simulator.system.services.web_server.web_server import WebServer from primaite.simulator.system.services.web_server.web_server import WebServer
node = Node(hostname="pc_a", start_up_duration=0, shut_down_duration=0) node = Node(config={"hostname":"pc_a", "start_up_duration":0, "shut_down_duration":0})
node.power_on() node.power_on()
assert node.operating_state is NodeOperatingState.ON assert node.operating_state is NodeOperatingState.ON

View File

@@ -703,7 +703,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": ".venv",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@@ -717,7 +717,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.12" "version": "3.10.11"
} }
}, },
"nbformat": 4, "nbformat": 4,