bugfix - Make node schemas stricter

This commit is contained in:
Marek Wolan
2025-02-05 15:04:41 +00:00
parent 4a472c5c75
commit c1abbfe58c
17 changed files with 73 additions and 34 deletions

View File

@@ -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] = {}

View File

@@ -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):