From 1f6f0079417774e38a3f5e232b32f377ad8e515d Mon Sep 17 00:00:00 2001 From: Charlie Crane Date: Thu, 27 Feb 2025 18:16:45 +0000 Subject: [PATCH] Updates to documentation and inclusion of how-to guides --- CHANGELOG.md | 1 + docs/index.rst | 4 ++ .../how_to_guides/custom_environments.rst | 16 +++++++- docs/source/how_to_guides/custom_rewards.rst | 2 + .../how_to_guides/extensible_actions.rst | 2 +- .../network/base_hardware.rst | 32 ++++++++------- .../simulation_components/network/network.rst | 28 +++++++------ .../system/applications/c2_suite.rst | 8 ++-- .../applications/data_manipulation_bot.rst | 13 +++--- .../system/applications/database_client.rst | 13 +++--- .../system/applications/dos_bot.rst | 13 +++--- .../system/applications/nmap.rst | 40 ++++++++++--------- .../system/applications/ransomware_script.rst | 13 +++--- .../system/applications/web_browser.rst | 13 +++--- .../system/services/database_service.rst | 13 +++--- .../system/services/dns_client.rst | 13 +++--- .../system/services/dns_server.rst | 13 +++--- .../system/services/ftp_client.rst | 13 +++--- .../system/services/ftp_server.rst | 13 +++--- .../system/services/ntp_client.rst | 13 +++--- .../system/services/ntp_server.rst | 13 +++--- .../system/services/terminal.rst | 29 +++++++------- .../system/services/web_server.rst | 13 +++--- .../simulation_components/system/software.rst | 2 +- .../Data-Manipulation-E2E-Demonstration.ipynb | 4 +- 25 files changed, 188 insertions(+), 149 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f87f54e..e4fb0172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - 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. +- Documentation has been updated to include details of extensability with PrimAITE. ### Fixed - DNS client no longer fails to check its cache if a DNS server address is missing. diff --git a/docs/index.rst b/docs/index.rst index 53d2e1b3..00ace007 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,6 +28,10 @@ What is PrimAITE? source/how_to_guides/custom_rewards source/how_to_guides/custom_software 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:: :caption: Usage: diff --git a/docs/source/how_to_guides/custom_environments.rst b/docs/source/how_to_guides/custom_environments.rst index 23c70d85..f4d49810 100644 --- a/docs/source/how_to_guides/custom_environments.rst +++ b/docs/source/how_to_guides/custom_environments.rst @@ -16,6 +16,10 @@ You configuration file should follow the hierarchy seen below: metadata: version: 4.0 + required_plugins: + - name: Example_Plugin + version: 1.0 + io_settings: ... game: @@ -25,9 +29,17 @@ You configuration file should follow the hierarchy seen below: 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. +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`. diff --git a/docs/source/how_to_guides/custom_rewards.rst b/docs/source/how_to_guides/custom_rewards.rst index 22b1de30..93bea700 100644 --- a/docs/source/how_to_guides/custom_rewards.rst +++ b/docs/source/how_to_guides/custom_rewards.rst @@ -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 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. .. code:: Python diff --git a/docs/source/how_to_guides/extensible_actions.rst b/docs/source/how_to_guides/extensible_actions.rst index fe61949b..5649428d 100644 --- a/docs/source/how_to_guides/extensible_actions.rst +++ b/docs/source/how_to_guides/extensible_actions.rst @@ -65,4 +65,4 @@ The above action would fail pydantic validation as the discriminator "node-folde 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`. diff --git a/docs/source/simulation_components/network/base_hardware.rst b/docs/source/simulation_components/network/base_hardware.rst index 8b325ffc..e60831e2 100644 --- a/docs/source/simulation_components/network/base_hardware.rst +++ b/docs/source/simulation_components/network/base_hardware.rst @@ -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.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 @@ -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.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 @@ -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.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 @@ -196,21 +196,23 @@ Setting up a Client-Server Network def client_server_network() -> Tuple[Computer, Server, Network]: network = Network() - client = Computer( - hostname="client", - ip_address="192.168.1.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + client = Computer(config={ + "hostname":"client", + "ip_address":"192.168.1.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) client.power_on() - server = Server( - hostname="server", - ip_address="192.168.1.3", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.1.3", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/network/network.rst b/docs/source/simulation_components/network/network.rst index 152b74b8..95bfb9fe 100644 --- a/docs/source/simulation_components/network/network.rst +++ b/docs/source/simulation_components/network/network.rst @@ -48,7 +48,7 @@ we'll use the following Network that has a client, server, two switches, and a r .. 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.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") @@ -57,9 +57,9 @@ we'll use the following Network that has a client, server, two switches, and a r .. 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_2 = Switch(hostname="switch_2", num_ports=6) + switch_2 = Switch(config={"hostname":"switch_2", "num_ports":6}) switch_2.power_on() 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 - client_1 = Computer( - hostname="client_1", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.2.1" + client_1 = Computer(config = { + "hostname":"client_1", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.2.1", + } ) client_1.power_on() - server_1 = Server( - hostname="server_1", - ip_address="192.168.1.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1" + server_1 = Server(config= { + "hostname":"server_1", + "ip_address":"192.168.1.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + } ) server_1.power_on() diff --git a/docs/source/simulation_components/system/applications/c2_suite.rst b/docs/source/simulation_components/system/applications/c2_suite.rst index 34175fc3..ce083406 100644 --- a/docs/source/simulation_components/system/applications/c2_suite.rst +++ b/docs/source/simulation_components/system/applications/c2_suite.rst @@ -128,19 +128,19 @@ Python 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() - 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() 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() 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() network.connect(node_c.network_interface[1], switch.network_interface[3]) diff --git a/docs/source/simulation_components/system/applications/data_manipulation_bot.rst b/docs/source/simulation_components/system/applications/data_manipulation_bot.rst index 8e008504..053ad8d7 100644 --- a/docs/source/simulation_components/system/applications/data_manipulation_bot.rst +++ b/docs/source/simulation_components/system/applications/data_manipulation_bot.rst @@ -67,12 +67,13 @@ Python from primaite.simulator.system.applications.red_applications.data_manipulation_bot import DataManipulationBot from primaite.simulator.system.applications.database_client import DatabaseClient - client_1 = Computer( - hostname="client_1", - ip_address="192.168.10.21", - subnet_mask="255.255.255.0", - default_gateway="192.168.10.1", - operating_state=NodeOperatingState.ON # initialise the computer in an ON state + client_1 = Computer(config={ + "hostname":"client_1", + "ip_address":"192.168.10.21", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.10.1", + "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]) client_1.software_manager.install(DatabaseClient) diff --git a/docs/source/simulation_components/system/applications/database_client.rst b/docs/source/simulation_components/system/applications/database_client.rst index 7087dedf..341876fe 100644 --- a/docs/source/simulation_components/system/applications/database_client.rst +++ b/docs/source/simulation_components/system/applications/database_client.rst @@ -48,12 +48,13 @@ Python from primaite.simulator.network.hardware.nodes.host.computer import Computer from primaite.simulator.system.applications.database_client import DatabaseClient - client = Computer( - hostname="client", - ip_address="192.168.10.21", - subnet_mask="255.255.255.0", - default_gateway="192.168.10.1", - operating_state=NodeOperatingState.ON # initialise the computer in an ON state + client_1 = Computer(config={ + "hostname":"client_1", + "ip_address":"192.168.10.21", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.10.1", + "operating_state":NodeOperatingState.ON # initialise the computer in an ON state + } ) # install DatabaseClient diff --git a/docs/source/simulation_components/system/applications/dos_bot.rst b/docs/source/simulation_components/system/applications/dos_bot.rst index 47b72be7..e6e03cfe 100644 --- a/docs/source/simulation_components/system/applications/dos_bot.rst +++ b/docs/source/simulation_components/system/applications/dos_bot.rst @@ -45,12 +45,13 @@ Python from primaite.simulator.system.applications.red_applications.dos_bot import dos-bot # Create Computer - computer = Computer( - hostname="computer", - ip_address="192.168.1.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + computer = Computer(config={ + "hostname":"computer", + "ip_address":"192.168.1.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) computer.power_on() diff --git a/docs/source/simulation_components/system/applications/nmap.rst b/docs/source/simulation_components/system/applications/nmap.rst index a82735c8..06badf7e 100644 --- a/docs/source/simulation_components/system/applications/nmap.rst +++ b/docs/source/simulation_components/system/applications/nmap.rst @@ -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") # Set up PC 1 - pc_1 = Computer( - hostname="pc_1", - ip_address="192.168.1.11", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0 + pc_1 = Computer(config = { + "hostname":"pc_1", + "ip_address":"192.168.1.11", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) pc_1.power_on() # Set up PC 2 - pc_2 = Computer( - hostname="pc_2", - ip_address="192.168.1.12", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0 + pc_2 = Computer(config = { + "hostname":"pc_2", + "ip_address":"192.168.1.12", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) pc_2.power_on() pc_2.software_manager.install(DatabaseService) pc_2.software_manager.software["DatabaseService"].start() # start the postgres server # Set up PC 3 - pc_3 = Computer( - hostname="pc_3", - ip_address="192.168.1.13", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0 + pc_3 = Computer(config = { + "hostname";"pc_3", + "ip_address":"192.168.1.13", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0 ) # Don't power on PC 3 # Set up the switch - switch = Switch(hostname="switch", start_up_duration=0) + switch = Switch(config={"hostname":"switch", "start_up_duration":0}) switch.power_on() # Connect devices diff --git a/docs/source/simulation_components/system/applications/ransomware_script.rst b/docs/source/simulation_components/system/applications/ransomware_script.rst index 192618fc..517167fd 100644 --- a/docs/source/simulation_components/system/applications/ransomware_script.rst +++ b/docs/source/simulation_components/system/applications/ransomware_script.rst @@ -52,12 +52,13 @@ Python from primaite.simulator.system.applications.red_applications.RansomwareScript import RansomwareScript from primaite.simulator.system.applications.database_client import DatabaseClient - client_1 = Computer( - hostname="client_1", - ip_address="192.168.10.21", - subnet_mask="255.255.255.0", - default_gateway="192.168.10.1", - operating_state=NodeOperatingState.ON # initialise the computer in an ON state + client_1 = Computer(config={ + "hostname":"client_1", + "ip_address":"192.168.10.21", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.10.1", + "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]) client_1.software_manager.install(DatabaseClient) diff --git a/docs/source/simulation_components/system/applications/web_browser.rst b/docs/source/simulation_components/system/applications/web_browser.rst index c04e60af..36290235 100644 --- a/docs/source/simulation_components/system/applications/web_browser.rst +++ b/docs/source/simulation_components/system/applications/web_browser.rst @@ -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 # Create Computer - computer = Computer( - hostname="computer", - ip_address="192.168.1.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + computer = Computer(config={ + "hostname":"computer", + "ip_address":"192.168.1.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) computer.power_on() diff --git a/docs/source/simulation_components/system/services/database_service.rst b/docs/source/simulation_components/system/services/database_service.rst index 961f2e45..d071a5c4 100644 --- a/docs/source/simulation_components/system/services/database_service.rst +++ b/docs/source/simulation_components/system/services/database_service.rst @@ -55,12 +55,13 @@ Python from primaite.simulator.system.services.database.database_service import DatabaseService # Create Server - server = Server( - hostname="server", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/system/services/dns_client.rst b/docs/source/simulation_components/system/services/dns_client.rst index 17a1ed25..aa99bc0e 100644 --- a/docs/source/simulation_components/system/services/dns_client.rst +++ b/docs/source/simulation_components/system/services/dns_client.rst @@ -45,12 +45,13 @@ Python from primaite.simulator.system.services.dns.dns_client import DNSClient # Create Server - server = Server( - hostname="server", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/system/services/dns_server.rst b/docs/source/simulation_components/system/services/dns_server.rst index 633221d5..787b2a70 100644 --- a/docs/source/simulation_components/system/services/dns_server.rst +++ b/docs/source/simulation_components/system/services/dns_server.rst @@ -42,12 +42,13 @@ Python from primaite.simulator.system.services.dns.dns_server import DNSServer # Create Server - server = Server( - hostname="server", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/system/services/ftp_client.rst b/docs/source/simulation_components/system/services/ftp_client.rst index d4375069..b8b493bd 100644 --- a/docs/source/simulation_components/system/services/ftp_client.rst +++ b/docs/source/simulation_components/system/services/ftp_client.rst @@ -49,12 +49,13 @@ Python from primaite.simulator.system.services.ftp.ftp_client import FTPClient # Create Server - server = Server( - hostname="server", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.10", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.10", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/system/services/ftp_server.rst b/docs/source/simulation_components/system/services/ftp_server.rst index a5ad32fe..df080125 100644 --- a/docs/source/simulation_components/system/services/ftp_server.rst +++ b/docs/source/simulation_components/system/services/ftp_server.rst @@ -44,12 +44,13 @@ Python from primaite.simulator.system.services.ftp.ftp_server import FTPServer # Create Server - server = Server( - hostname="server", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.10", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/system/services/ntp_client.rst b/docs/source/simulation_components/system/services/ntp_client.rst index 8c011cad..22ae4516 100644 --- a/docs/source/simulation_components/system/services/ntp_client.rst +++ b/docs/source/simulation_components/system/services/ntp_client.rst @@ -42,12 +42,13 @@ Python from primaite.simulator.system.services.ntp.ntp_client import NTPClient # Create Server - server = Server( - hostname="server", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.10", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/system/services/ntp_server.rst b/docs/source/simulation_components/system/services/ntp_server.rst index c1d16d61..784aac0c 100644 --- a/docs/source/simulation_components/system/services/ntp_server.rst +++ b/docs/source/simulation_components/system/services/ntp_server.rst @@ -44,12 +44,13 @@ Python from primaite.simulator.system.services.ntp.ntp_server import NTPServer # Create Server - server = Server( - hostname="server", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.10", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/system/services/terminal.rst b/docs/source/simulation_components/system/services/terminal.rst index bc5cee48..1fec3b53 100644 --- a/docs/source/simulation_components/system/services/terminal.rst +++ b/docs/source/simulation_components/system/services/terminal.rst @@ -57,12 +57,13 @@ Python from primaite.simulator.system.services.terminal.terminal import Terminal from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState - client = Computer( - hostname="client", - ip_address="192.168.10.21", - subnet_mask="255.255.255.0", - default_gateway="192.168.10.1", - operating_state=NodeOperatingState.ON, + client = Computer(config= { + "hostname":"client", + "ip_address":"192.168.10.21", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.10.1", + "operating_state":NodeOperatingState.ON, + } ) terminal: Terminal = client.software_manager.software.get("Terminal") @@ -80,9 +81,9 @@ Creating Remote Terminal Connection 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_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() network.connect(node_a.network_interface[1], node_b.network_interface[1]) @@ -106,9 +107,9 @@ Executing a basic application install command 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_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() 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() - 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_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() network.connect(node_a.network_interface[1], node_b.network_interface[1]) @@ -161,9 +162,9 @@ Disconnect from Remote Node 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_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() network.connect(node_a.network_interface[1], node_b.network_interface[1]) diff --git a/docs/source/simulation_components/system/services/web_server.rst b/docs/source/simulation_components/system/services/web_server.rst index bce42791..dc7ebd4b 100644 --- a/docs/source/simulation_components/system/services/web_server.rst +++ b/docs/source/simulation_components/system/services/web_server.rst @@ -45,12 +45,13 @@ Python from primaite.simulator.system.services.web_server.web_server import WebServer # Create Server - server = Server( - hostname="server", - ip_address="192.168.2.2", - subnet_mask="255.255.255.0", - default_gateway="192.168.1.1", - start_up_duration=0, + server = Server(config = { + "hostname":"server", + "ip_address":"192.168.2.2", + "subnet_mask":"255.255.255.0", + "default_gateway":"192.168.1.1", + "start_up_duration":0, + } ) server.power_on() diff --git a/docs/source/simulation_components/system/software.rst b/docs/source/simulation_components/system/software.rst index d28815bb..be284af1 100644 --- a/docs/source/simulation_components/system/software.rst +++ b/docs/source/simulation_components/system/software.rst @@ -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.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() assert node.operating_state is NodeOperatingState.ON diff --git a/src/primaite/notebooks/Data-Manipulation-E2E-Demonstration.ipynb b/src/primaite/notebooks/Data-Manipulation-E2E-Demonstration.ipynb index 31e1f9d3..9d9fb654 100644 --- a/src/primaite/notebooks/Data-Manipulation-E2E-Demonstration.ipynb +++ b/src/primaite/notebooks/Data-Manipulation-E2E-Demonstration.ipynb @@ -703,7 +703,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -717,7 +717,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.10.11" } }, "nbformat": 4,