bugfix - Make node schemas stricter
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
|
||||
from typing import Dict
|
||||
from typing import Dict, Literal
|
||||
|
||||
from prettytable import MARKDOWN, PrettyTable
|
||||
|
||||
@@ -18,6 +18,9 @@ class GigaSwitch(NetworkNode, discriminator="gigaswitch"):
|
||||
:ivar num_ports: The number of ports on the switch. Default is 24.
|
||||
"""
|
||||
|
||||
class ConfigSchema(NetworkNode.ConfigSchema):
|
||||
type: Literal["gigaswitch"] = "gigaswitch"
|
||||
|
||||
num_ports: int = 24
|
||||
"The number of ports on the switch."
|
||||
network_interfaces: Dict[str, SwitchPort] = {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
|
||||
from typing import ClassVar, Dict
|
||||
from typing import ClassVar, Dict, Literal
|
||||
|
||||
from primaite.simulator.network.hardware.nodes.host.host_node import HostNode, NIC
|
||||
from primaite.simulator.system.services.ftp.ftp_client import FTPClient
|
||||
@@ -34,6 +34,9 @@ class SuperComputer(HostNode, discriminator="supercomputer"):
|
||||
* Web Browser
|
||||
"""
|
||||
|
||||
class ConfigSchema(HostNode.ConfigSchema):
|
||||
type: Literal["supercomputer"] = "supercomputer"
|
||||
|
||||
SYSTEM_SOFTWARE: ClassVar[Dict] = {**HostNode.SYSTEM_SOFTWARE, "ftp-client": FTPClient}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
@@ -16,7 +16,7 @@ def test_wireless_link_loading(wireless_wan_network):
|
||||
# Configure Router 2 ACLs
|
||||
router_2.acl.add_rule(action=ACLAction.PERMIT, position=1)
|
||||
|
||||
airspace = router_1.config.airspace
|
||||
airspace = router_1.airspace
|
||||
|
||||
client.software_manager.install(FTPClient)
|
||||
ftp_client: FTPClient = client.software_manager.software.get("ftp-client")
|
||||
|
||||
@@ -32,7 +32,7 @@ def wireless_wan_network():
|
||||
|
||||
# Configure Router 1
|
||||
router_1 = WirelessRouter.from_config(
|
||||
config={"type": "wireless_router", "hostname": "router_1", "start_up_duration": 0, "airspace": network.airspace}
|
||||
config={"type": "wireless-router", "hostname": "router_1", "start_up_duration": 0}, airspace=network.airspace
|
||||
)
|
||||
router_1.power_on()
|
||||
network.add_node(router_1)
|
||||
@@ -63,7 +63,7 @@ def wireless_wan_network():
|
||||
|
||||
# Configure Router 2
|
||||
router_2: WirelessRouter = WirelessRouter.from_config(
|
||||
config={"type": "wireless_router", "hostname": "router_2", "start_up_duration": 0, "airspace": network.airspace}
|
||||
config={"type": "wireless-router", "hostname": "router_2", "start_up_duration": 0}, airspace=network.airspace
|
||||
)
|
||||
router_2.power_on()
|
||||
network.add_node(router_2)
|
||||
|
||||
@@ -8,7 +8,6 @@ from primaite.utils.validation.port import PORT_LOOKUP
|
||||
|
||||
def test_wireless_router_from_config():
|
||||
cfg = {
|
||||
"ref": "router_1",
|
||||
"type": "router",
|
||||
"hostname": "router_1",
|
||||
"num_ports": 6,
|
||||
|
||||
@@ -95,7 +95,7 @@ def wireless_wan_network():
|
||||
|
||||
# Configure Router 1
|
||||
router_1 = WirelessRouter.from_config(
|
||||
config={"type": "wireless_router", "hostname": "router_1", "start_up_duration": 0, "airspace": network.airspace}
|
||||
config={"type": "wireless-router", "hostname": "router_1", "start_up_duration": 0}, airspace=network.airspace
|
||||
)
|
||||
router_1.power_on()
|
||||
network.add_node(router_1)
|
||||
|
||||
Reference in New Issue
Block a user