mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
refactor: ruff autofixes
This commit is contained in:
455 files changed
+12322
-14762
No files matched your search
@@ -43,9 +43,7 @@ class ApplianceMetadata(BaseModel):
|
||||
|
||||
model_config = ConfigDict(extra="allow")
|
||||
|
||||
appliance_id: Optional[str] = Field(
|
||||
None, description="ID of the appliance the template was installed from"
|
||||
)
|
||||
appliance_id: Optional[str] = Field(None, description="ID of the appliance the template was installed from")
|
||||
description: Optional[str] = None
|
||||
vendor_name: Optional[str] = None
|
||||
vendor_url: Optional[str] = None
|
||||
@@ -82,12 +80,10 @@ class TemplateBase(BaseModel):
|
||||
pattern=r"^[a-z0-9_]+$|^$",
|
||||
)
|
||||
tags: Optional[List[str]] = Field(
|
||||
default_factory=list,
|
||||
description="User-defined metadata tags (e.g. 'vendor:cisco' or 'model:7200')"
|
||||
default_factory=list, description="User-defined metadata tags (e.g. 'vendor:cisco' or 'model:7200')"
|
||||
)
|
||||
appliance_metadata: Optional[ApplianceMetadata] = Field(
|
||||
None,
|
||||
description="Metadata inherited from the appliance the template was installed from"
|
||||
None, description="Metadata inherited from the appliance the template was installed from"
|
||||
)
|
||||
|
||||
|
||||
@@ -106,7 +102,6 @@ class TemplateUpdate(TemplateBase):
|
||||
|
||||
|
||||
class Template(DateTimeModelMixin, TemplateBase):
|
||||
|
||||
template_id: UUID
|
||||
name: str
|
||||
category: Category
|
||||
@@ -117,7 +112,6 @@ class Template(DateTimeModelMixin, TemplateBase):
|
||||
|
||||
|
||||
class TemplateUsage(BaseModel):
|
||||
|
||||
x: int
|
||||
y: int
|
||||
name: Optional[str] = Field(None, description="Use this name to create a new node")
|
||||
|
||||
@@ -16,19 +16,13 @@
|
||||
|
||||
|
||||
from . import Category, TemplateBase
|
||||
from gns3server.schemas.compute.cloud_nodes import (
|
||||
EthernetPort,
|
||||
TAPPort,
|
||||
UDPPort,
|
||||
CloudConsoleType
|
||||
)
|
||||
from gns3server.schemas.compute.cloud_nodes import EthernetPort, TAPPort, UDPPort, CloudConsoleType
|
||||
|
||||
from pydantic import Field
|
||||
from typing import Optional, Union, List
|
||||
|
||||
|
||||
class CloudTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "Cloud{0}"
|
||||
symbol: Optional[str] = "cloud"
|
||||
@@ -40,5 +34,4 @@ class CloudTemplate(TemplateBase):
|
||||
|
||||
|
||||
class CloudTemplateUpdate(CloudTemplate):
|
||||
|
||||
pass
|
||||
@@ -23,13 +23,14 @@ from typing import Optional, List
|
||||
|
||||
|
||||
class DockerTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "{name}-{0}"
|
||||
symbol: Optional[str] = "docker_guest"
|
||||
image: str = Field(..., description="Docker image name")
|
||||
adapters: Optional[int] = Field(1, ge=0, le=100, description="Number of adapters")
|
||||
mac_address: Optional[str] = Field("", description="Base MAC address", pattern="^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$|^$")
|
||||
mac_address: Optional[str] = Field(
|
||||
"", description="Base MAC address", pattern="^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$|^$"
|
||||
)
|
||||
start_command: Optional[str] = Field("", description="Docker CMD entry")
|
||||
environment: Optional[str] = Field("", description="Docker environment variables")
|
||||
console_type: Optional[ConsoleType] = Field(ConsoleType.telnet, description="Console type")
|
||||
@@ -49,12 +50,13 @@ class DockerTemplate(TemplateBase):
|
||||
)
|
||||
extra_hosts: Optional[str] = Field("", description="Docker extra hosts (added to /etc/hosts)")
|
||||
extra_volumes: Optional[List] = Field([], description="Additional directories to make persistent")
|
||||
extra_configs: Optional[List[ExtraConfig]] = Field(default_factory=list, description="Configuration files injected into the container (bind-mounted read-only)")
|
||||
extra_configs: Optional[List[ExtraConfig]] = Field(
|
||||
default_factory=list, description="Configuration files injected into the container (bind-mounted read-only)"
|
||||
)
|
||||
memory: Optional[int] = Field(0, ge=0, description="Maximum amount of memory the container can use in MB")
|
||||
cpus: Optional[float] = Field(0, ge=0, description="Maximum amount of CPU resources the container can use")
|
||||
custom_adapters: Optional[List[CustomAdapter]] = Field(default_factory=list, description="Custom adapters")
|
||||
|
||||
|
||||
class DockerTemplateUpdate(DockerTemplate):
|
||||
|
||||
image: Optional[str] = Field(None, description="Docker image name")
|
||||
image: Optional[str] = Field(None, description="Docker image name")
|
||||
@@ -31,7 +31,6 @@ from enum import Enum
|
||||
|
||||
|
||||
class DynamipsTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.router
|
||||
default_name_format: Optional[str] = "R{0}"
|
||||
symbol: Optional[str] = "router"
|
||||
@@ -69,7 +68,6 @@ class DynamipsTemplate(TemplateBase):
|
||||
|
||||
|
||||
class C7200DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
ram: Optional[int] = Field(512, gt=0, description="Amount of RAM in MB")
|
||||
nvram: Optional[int] = Field(512, gt=0, description="Amount of NVRAM in KB")
|
||||
npe: Optional[DynamipsNPE] = Field(DynamipsNPE.npe_400, description="NPE model")
|
||||
@@ -78,13 +76,11 @@ class C7200DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
|
||||
class C7200DynamipsTemplateUpdate(C7200DynamipsTemplate):
|
||||
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
|
||||
|
||||
class C3725DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
ram: Optional[int] = Field(128, gt=0, description="Amount of RAM in MB")
|
||||
nvram: Optional[int] = Field(256, gt=0, description="Amount of NVRAM in KB")
|
||||
iomem: Optional[int] = Field(5, ge=0, le=100, description="I/O memory percentage")
|
||||
@@ -92,13 +88,11 @@ class C3725DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
|
||||
class C3725DynamipsTemplateUpdate(C3725DynamipsTemplate):
|
||||
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
|
||||
|
||||
class C3745DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
ram: Optional[int] = Field(256, gt=0, description="Amount of RAM in MB")
|
||||
nvram: Optional[int] = Field(256, gt=0, description="Amount of NVRAM in KB")
|
||||
iomem: Optional[int] = Field(5, ge=0, le=100, description="I/O memory percentage")
|
||||
@@ -106,20 +100,17 @@ class C3745DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
|
||||
class C3745DynamipsTemplateUpdate(C3745DynamipsTemplate):
|
||||
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
|
||||
|
||||
class C3600ChassisType(str, Enum):
|
||||
|
||||
chassis_3620 = "3620"
|
||||
chassis_3640 = "3640"
|
||||
chassis_3660 = "3660"
|
||||
|
||||
|
||||
class C3600DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
chassis: Optional[C3600ChassisType] = Field("c3660", description="Chassis type")
|
||||
ram: Optional[int] = Field(192, gt=0, description="Amount of RAM in MB")
|
||||
nvram: Optional[int] = Field(128, gt=0, description="Amount of NVRAM in KB")
|
||||
@@ -128,13 +119,11 @@ class C3600DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
|
||||
class C3600DynamipsTemplateUpdate(C3600DynamipsTemplate):
|
||||
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
|
||||
|
||||
class C2691DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
ram: Optional[int] = Field(192, gt=0, description="Amount of RAM in MB")
|
||||
nvram: Optional[int] = Field(256, gt=0, description="Amount of NVRAM in KB")
|
||||
iomem: Optional[int] = Field(5, ge=0, le=100, description="I/O memory percentage")
|
||||
@@ -142,13 +131,11 @@ class C2691DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
|
||||
class C2691DynamipsTemplateUpdate(C2691DynamipsTemplate):
|
||||
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
|
||||
|
||||
class C2600ChassisType(str, Enum):
|
||||
|
||||
chassis_2610 = "2610"
|
||||
chassis_2620 = "2620"
|
||||
chassis_2610xm = "2610XM"
|
||||
@@ -161,7 +148,6 @@ class C2600ChassisType(str, Enum):
|
||||
|
||||
|
||||
class C2600DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
chassis: Optional[C2600ChassisType] = Field("2651XM", description="Chassis type")
|
||||
ram: Optional[int] = Field(160, gt=0, description="Amount of RAM in MB")
|
||||
nvram: Optional[int] = Field(128, gt=0, description="Amount of NVRAM in KB")
|
||||
@@ -170,13 +156,11 @@ class C2600DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
|
||||
class C2600DynamipsTemplateUpdate(C2600DynamipsTemplate):
|
||||
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
|
||||
|
||||
class C1700ChassisType(str, Enum):
|
||||
|
||||
chassis_1720 = "1720"
|
||||
chassis_1721 = "1721"
|
||||
chassis_1750 = "1750"
|
||||
@@ -185,7 +169,6 @@ class C1700ChassisType(str, Enum):
|
||||
|
||||
|
||||
class C1700DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
chassis: Optional[C1700ChassisType] = Field("1760", description="Chassis type")
|
||||
ram: Optional[int] = Field(160, gt=0, description="Amount of RAM in MB")
|
||||
nvram: Optional[int] = Field(128, gt=0, description="Amount of NVRAM in KB")
|
||||
@@ -194,6 +177,5 @@ class C1700DynamipsTemplate(DynamipsTemplate):
|
||||
|
||||
|
||||
class C1700DynamipsTemplateUpdate(C1700DynamipsTemplate):
|
||||
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
@@ -34,7 +34,6 @@ DEFAULT_PORTS = [
|
||||
|
||||
|
||||
class EthernetHubTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.switch
|
||||
default_name_format: Optional[str] = "Hub{0}"
|
||||
symbol: Optional[str] = "hub"
|
||||
@@ -42,5 +41,4 @@ class EthernetHubTemplate(TemplateBase):
|
||||
|
||||
|
||||
class EthernetHubTemplateUpdate(EthernetHubTemplate):
|
||||
|
||||
pass
|
||||
@@ -44,7 +44,6 @@ class ConsoleType(str, Enum):
|
||||
|
||||
|
||||
class EthernetSwitchTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.switch
|
||||
default_name_format: Optional[str] = "Switch{0}"
|
||||
symbol: Optional[str] = "ethernet_switch"
|
||||
@@ -53,5 +52,4 @@ class EthernetSwitchTemplate(TemplateBase):
|
||||
|
||||
|
||||
class EthernetSwitchTemplateUpdate(EthernetSwitchTemplate):
|
||||
|
||||
pass
|
||||
@@ -23,7 +23,6 @@ from typing import Optional
|
||||
|
||||
|
||||
class IOUTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.router
|
||||
default_name_format: Optional[str] = "IOU{0}"
|
||||
symbol: Optional[str] = "multilayer_switch"
|
||||
@@ -46,5 +45,4 @@ class IOUTemplate(TemplateBase):
|
||||
|
||||
|
||||
class IOUTemplateUpdate(IOUTemplate):
|
||||
|
||||
path: Optional[str] = Field(None, description="Path of IOU executable")
|
||||
@@ -32,7 +32,6 @@ from typing import Optional, List
|
||||
|
||||
|
||||
class QemuTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "{name}-{0}"
|
||||
symbol: Optional[str] = "qemu_guest"
|
||||
@@ -62,13 +61,21 @@ class QemuTemplate(TemplateBase):
|
||||
aux_type: Optional[QemuConsoleType] = Field(QemuConsoleType.none, description="Auxiliary console type")
|
||||
boot_priority: Optional[QemuBootPriority] = Field(QemuBootPriority.c, description="QEMU boot priority")
|
||||
hda_disk_image: Optional[str] = Field("", description="QEMU hda disk image path")
|
||||
hda_disk_interface: Optional[QemuDiskInterfaceType] = Field(QemuDiskInterfaceType.none, description="QEMU hda interface")
|
||||
hda_disk_interface: Optional[QemuDiskInterfaceType] = Field(
|
||||
QemuDiskInterfaceType.none, description="QEMU hda interface"
|
||||
)
|
||||
hdb_disk_image: Optional[str] = Field("", description="QEMU hdb disk image path")
|
||||
hdb_disk_interface: Optional[QemuDiskInterfaceType] = Field(QemuDiskInterfaceType.none, description="QEMU hdb interface")
|
||||
hdb_disk_interface: Optional[QemuDiskInterfaceType] = Field(
|
||||
QemuDiskInterfaceType.none, description="QEMU hdb interface"
|
||||
)
|
||||
hdc_disk_image: Optional[str] = Field("", description="QEMU hdc disk image path")
|
||||
hdc_disk_interface: Optional[QemuDiskInterfaceType] = Field(QemuDiskInterfaceType.none, description="QEMU hdc interface")
|
||||
hdc_disk_interface: Optional[QemuDiskInterfaceType] = Field(
|
||||
QemuDiskInterfaceType.none, description="QEMU hdc interface"
|
||||
)
|
||||
hdd_disk_image: Optional[str] = Field("", description="QEMU hdd disk image path")
|
||||
hdd_disk_interface: Optional[QemuDiskInterfaceType] = Field(QemuDiskInterfaceType.none, description="QEMU hdd interface")
|
||||
hdd_disk_interface: Optional[QemuDiskInterfaceType] = Field(
|
||||
QemuDiskInterfaceType.none, description="QEMU hdd interface"
|
||||
)
|
||||
cdrom_image: Optional[str] = Field("", description="QEMU cdrom image path")
|
||||
initrd: Optional[str] = Field("", description="QEMU initrd path")
|
||||
kernel_image: Optional[str] = Field("", description="QEMU kernel image path")
|
||||
@@ -82,13 +89,16 @@ class QemuTemplate(TemplateBase):
|
||||
)
|
||||
tpm: Optional[bool] = Field(False, description="Enable Trusted Platform Module (TPM)")
|
||||
uefi: Optional[bool] = Field(False, description="Enable UEFI boot mode")
|
||||
on_close: Optional[QemuOnCloseAction] = Field(QemuOnCloseAction.power_off, description="Action to execute on the VM is closed")
|
||||
on_close: Optional[QemuOnCloseAction] = Field(
|
||||
QemuOnCloseAction.power_off, description="Action to execute on the VM is closed"
|
||||
)
|
||||
cpu_throttling: Optional[int] = Field(0, ge=0, le=800, description="Percentage of CPU allowed for QEMU")
|
||||
process_priority: Optional[QemuProcessPriority] = Field(QemuProcessPriority.normal, description="Process priority for QEMU")
|
||||
process_priority: Optional[QemuProcessPriority] = Field(
|
||||
QemuProcessPriority.normal, description="Process priority for QEMU"
|
||||
)
|
||||
options: Optional[str] = Field("", description="Additional QEMU options")
|
||||
custom_adapters: Optional[List[CustomAdapter]] = Field(default_factory=list, description="Custom adapters")
|
||||
|
||||
|
||||
class QemuTemplateUpdate(QemuTemplate):
|
||||
|
||||
pass
|
||||
@@ -19,7 +19,7 @@ from gns3server.schemas.compute.virtualbox_nodes import (
|
||||
VirtualBoxConsoleType,
|
||||
VirtualBoxAdapterType,
|
||||
VirtualBoxOnCloseAction,
|
||||
CustomAdapter
|
||||
CustomAdapter,
|
||||
)
|
||||
|
||||
from pydantic import Field
|
||||
@@ -27,7 +27,6 @@ from typing import Optional, List
|
||||
|
||||
|
||||
class VirtualBoxTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "{name}-{0}"
|
||||
symbol: Optional[str] = "vbox_guest"
|
||||
@@ -38,7 +37,8 @@ class VirtualBoxTemplate(TemplateBase):
|
||||
1, ge=0, le=36, description="Number of adapters"
|
||||
) # 36 is the maximum given by the ICH9 chipset in VirtualBox
|
||||
use_any_adapter: Optional[bool] = Field(False, description="Allow GNS3 to use any VirtualBox adapter")
|
||||
adapter_type: Optional[VirtualBoxAdapterType] = Field(VirtualBoxAdapterType.intel_pro_1000_mt_desktop, description="VirtualBox adapter type"
|
||||
adapter_type: Optional[VirtualBoxAdapterType] = Field(
|
||||
VirtualBoxAdapterType.intel_pro_1000_mt_desktop, description="VirtualBox adapter type"
|
||||
)
|
||||
first_port_name: Optional[str] = Field("", description="Optional name of the first networking port example: eth0")
|
||||
port_name_format: Optional[str] = Field(
|
||||
@@ -60,5 +60,4 @@ class VirtualBoxTemplate(TemplateBase):
|
||||
|
||||
|
||||
class VirtualBoxTemplateUpdate(VirtualBoxTemplate):
|
||||
|
||||
vmname: Optional[str] = Field(None, description="VirtualBox VM name (in VirtualBox itself)")
|
||||
@@ -20,7 +20,7 @@ from gns3server.schemas.compute.vmware_nodes import (
|
||||
VMwareConsoleType,
|
||||
VMwareAdapterType,
|
||||
VMwareOnCloseAction,
|
||||
CustomAdapter
|
||||
CustomAdapter,
|
||||
)
|
||||
|
||||
from pydantic import Field
|
||||
@@ -28,7 +28,6 @@ from typing import Optional, List
|
||||
|
||||
|
||||
class VMwareTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "{name}-{0}"
|
||||
symbol: Optional[str] = "vmware_guest"
|
||||
@@ -48,7 +47,9 @@ class VMwareTemplate(TemplateBase):
|
||||
adapter_type: Optional[VMwareAdapterType] = Field(VMwareAdapterType.e1000, description="VMware adapter type")
|
||||
use_any_adapter: Optional[bool] = Field(False, description="Allow GNS3 to use any VMware adapter")
|
||||
headless: Optional[bool] = Field(False, description="Headless mode")
|
||||
on_close: Optional[VMwareOnCloseAction] = Field(VMwareOnCloseAction.power_off, description="Action to execute on the VM is closed")
|
||||
on_close: Optional[VMwareOnCloseAction] = Field(
|
||||
VMwareOnCloseAction.power_off, description="Action to execute on the VM is closed"
|
||||
)
|
||||
console_type: Optional[VMwareConsoleType] = Field(VMwareConsoleType.none, description="Console type")
|
||||
console_auto_start: Optional[bool] = Field(
|
||||
False, description="Automatically start the console when the node has started"
|
||||
@@ -57,5 +58,4 @@ class VMwareTemplate(TemplateBase):
|
||||
|
||||
|
||||
class VMwareTemplateUpdate(VMwareTemplate):
|
||||
|
||||
vmx_path: Optional[str] = Field(None, description="Path to the vmx file")
|
||||
@@ -23,7 +23,6 @@ from typing import Optional
|
||||
|
||||
|
||||
class VPCSTemplate(TemplateBase):
|
||||
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "PC{0}"
|
||||
symbol: Optional[str] = "vpcs_guest"
|
||||
@@ -35,5 +34,4 @@ class VPCSTemplate(TemplateBase):
|
||||
|
||||
|
||||
class VPCSTemplateUpdate(VPCSTemplate):
|
||||
|
||||
pass
|
||||
Reference in new issue
Block a user