refactor: ruff autofixes

This commit is contained in:
Mark Paronyan committed 2026-09-27 15:55:10 +03:00
1 parent 2ac637c662
commit a0450b6bce
455 files changed
+12322 -14762

No files matched your search

File diff suppressed because it is too large. Load diff
-1
View File
@@ -20,6 +20,5 @@ from pydantic import BaseModel
class DateTimeModelMixin(BaseModel):
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None
+9 -9
View File
@@ -40,7 +40,7 @@ class ChatRequest(BaseModel):
None,
description="LLM temperature parameter (NOTE: currently not used. "
"Temperature is loaded from user's LLM config in database. "
"Reserved for future runtime override support.)"
"Reserved for future runtime override support.)",
)
mode: Literal["text"] = Field(default="text", description="Interaction mode")
@@ -49,14 +49,14 @@ class ChatResponse(BaseModel):
"""Chat streaming response model."""
type: Literal[
"content", # AI text content
"tool_call", # Tool call request
"tool_start", # Tool execution started
"tool_end", # Tool execution completed
"error", # Error message
"done", # Stream ended
"heartbeat", # Keep-alive signal
"abort" # Stream aborted
"content", # AI text content
"tool_call", # Tool call request
"tool_start", # Tool execution started
"tool_end", # Tool execution completed
"error", # Error message
"done", # Stream ended
"heartbeat", # Keep-alive signal
"abort", # Stream aborted
] = Field(..., description="Response message type")
content: Optional[str] = Field(None, description="Text content (for type=content)")
message_id: Optional[str] = Field(None, description="Message ID")
+19 -27
View File
@@ -16,14 +16,7 @@
import uuid
from pydantic import (
ConfigDict,
BaseModel,
Field,
SecretStr,
field_validator,
model_validator
)
from pydantic import ConfigDict, BaseModel, Field, SecretStr, field_validator, model_validator
from typing import List, Optional, Union, Any
from enum import Enum
@@ -60,27 +53,22 @@ class ComputeCreate(ComputeBase):
"""
compute_id: Union[str, uuid.UUID] = None
model_config = ConfigDict(json_schema_extra={
"example": {
"name": "My compute",
"host": "127.0.0.1",
"port": 3080,
"user": "user",
"password": "password"
model_config = ConfigDict(
json_schema_extra={
"example": {"name": "My compute", "host": "127.0.0.1", "port": 3080, "user": "user", "password": "password"}
}
})
)
@model_validator(mode='before')
@model_validator(mode="before")
@classmethod
def set_default_compute_id_and_name(cls, data: Any) -> Any:
if "compute_id" not in data:
data['compute_id'] = uuid.uuid5(
uuid.NAMESPACE_URL,
f"{data.get('protocol')}://{data.get('host')}:{data.get('port')}"
data["compute_id"] = uuid.uuid5(
uuid.NAMESPACE_URL, f"{data.get('protocol')}://{data.get('host')}:{data.get('port')}"
)
if "name" not in data:
data['name'] = f"{data.get('protocol')}://{data.get('user', '')}@{data.get('host')}:{data.get('port')}"
data["name"] = f"{data.get('protocol')}://{data.get('user', '')}@{data.get('host')}:{data.get('port')}"
return data
@@ -94,12 +82,14 @@ class ComputeUpdate(ComputeBase):
port: Optional[int] = Field(None, gt=0, le=65535)
user: Optional[str] = None
password: Optional[SecretStr] = None
model_config = ConfigDict(json_schema_extra={
"example": {
"host": "10.0.0.1",
"port": 8080,
model_config = ConfigDict(
json_schema_extra={
"example": {
"host": "10.0.0.1",
"port": 8080,
}
}
})
)
class Capabilities(BaseModel):
@@ -165,4 +155,6 @@ class AutoIdlePC(BaseModel):
platform: str = Field(..., description="Cisco platform")
image: str = Field(..., description="Image path")
ram: int = Field(..., description="Amount of RAM in MB")
model_config = ConfigDict(json_schema_extra={"example": {"platform": "c7200", "image": "/path/to/c7200_image.bin", "ram": 256}})
model_config = ConfigDict(
json_schema_extra={"example": {"platform": "c7200", "image": "/path/to/c7200_image.bin", "ram": 256}}
)
-1
View File
@@ -21,7 +21,6 @@ from .base import DateTimeModelMixin
class ImageType(str, Enum):
qemu = "qemu"
ios = "ios"
iou = "iou"
@@ -18,6 +18,5 @@ from pydantic import BaseModel, Field
class IOULicense(BaseModel):
iourc_content: str = Field(..., description="Content of iourc file")
license_check: bool = Field(..., description="Whether the license must be checked or not")
+10 -28
View File
@@ -43,7 +43,6 @@ class LinkType(str, Enum):
class LinkStyle(BaseModel):
color: Optional[str] = None
width: Optional[int] = None
type: Optional[int] = None
@@ -63,50 +62,36 @@ class LinkBase(BaseModel):
link_style: Optional[LinkStyle] = None
filters: Optional[dict] = None
markers: Optional[dict] = Field(
None,
description="Traffic-insight markers on this link: name → {bpf, tag, enabled}"
)
show_filters_icon: Optional[bool] = Field(
True,
description="Show filters icon in Web UI"
None, description="Traffic-insight markers on this link: name → {bpf, tag, enabled}"
)
show_filters_icon: Optional[bool] = Field(True, description="Show filters icon in Web UI")
class LinkCreate(LinkBase):
link_id: UUID = Field(default_factory=uuid4)
nodes: List[LinkNode] = Field(..., min_length=2, max_length=2)
class LinkUpdate(LinkBase):
pass
class Link(LinkBase):
link_id: UUID
project_id: Optional[UUID] = None
link_type: Optional[LinkType] = None
capturing: Optional[bool] = Field(
None,
description="Read only property. True if a capture running on the link"
)
capturing: Optional[bool] = Field(None, description="Read only property. True if a capture running on the link")
capture_file_name: Optional[str] = Field(
None,
description="Read only property. The name of the capture file if a capture is running"
None, description="Read only property. The name of the capture file if a capture is running"
)
capture_file_path: Optional[str] = Field(
None,
description="Read only property. The full path of the capture file if a capture is running"
None, description="Read only property. The full path of the capture file if a capture is running"
)
capture_compute_id: Optional[str] = Field(
None,
description="Read only property. The compute identifier where a capture is running"
None, description="Read only property. The compute identifier where a capture is running"
)
wireshark: Optional[bool] = Field(
False,
description="Read only property. True if a Web Wireshark session is active on the link"
False, description="Read only property. True if a Web Wireshark session is active on the link"
)
@@ -121,6 +106,7 @@ class UDPPortInfo(BaseModel):
rport: int
type: str
class EthernetPortInfo(BaseModel):
"""
Ethernet port information.
@@ -153,7 +139,7 @@ class MarkerCreate(BaseModel):
None,
pattern=r"^[A-Za-z0-9][A-Za-z0-9_.-]*$",
max_length=32,
description='Unique marker name on the link. Auto-generated when absent.',
description="Unique marker name on the link. Auto-generated when absent.",
)
bpf: str
tag: Optional[int] = None
@@ -226,9 +212,7 @@ class MarkerUpdate(BaseModel):
description="Direction filter; 'both' or an explicit null clears it to both. Omit to keep.",
)
color: Optional[str] = Field(None, description="Hex color render hint, e.g. '#ff5722'")
highlight_duration: Optional[int] = Field(
None, ge=1, description="UI highlight duration in ms; null = UI default"
)
highlight_duration: Optional[int] = Field(None, ge=1, description="UI highlight duration in ms; null = UI default")
enabled: Optional[bool] = Field(None, description="Toggle the marker on/off (instant).")
@field_validator("direction", mode="before")
@@ -288,5 +272,3 @@ class MarkerDefinitionCreate(BaseModel):
@classmethod
def _both_to_none(cls, v):
return None if v == "both" else v
@@ -22,7 +22,7 @@ from .base import DateTimeModelMixin
# Valid model types
ModelType = Literal['text', 'vision', 'stt', 'tts', 'multimodal', 'embedding', 'reranking', 'other']
ModelType = Literal["text", "vision", "stt", "tts", "multimodal", "embedding", "reranking", "other"]
# Core model config schema (stored in config JSONB field)
@@ -51,8 +51,7 @@ class LLMModelConfigData(BaseModel):
"balanced", description="Context trimming strategy: conservative (60%), balanced (75%), aggressive (85%)"
)
copilot_mode: Optional[str] = Field(
None,
description="GNS3-Copilot mode: 'teaching_assistant' or 'lab_automation_assistant'"
None, description="GNS3-Copilot mode: 'teaching_assistant' or 'lab_automation_assistant'"
)
# Allow extra fields for extensibility
@@ -81,8 +80,7 @@ class LLMModelConfigCreate(BaseModel):
"balanced", description="Context trimming strategy"
)
copilot_mode: Optional[str] = Field(
None,
description="GNS3-Copilot mode: 'teaching_assistant' or 'lab_automation_assistant'"
None, description="GNS3-Copilot mode: 'teaching_assistant' or 'lab_automation_assistant'"
)
# Allow extra config fields
@@ -112,14 +110,13 @@ class LLMModelConfigUpdate(BaseModel):
None, description="Context trimming strategy"
)
copilot_mode: Optional[str] = Field(
None,
description="GNS3-Copilot mode: 'teaching_assistant' or 'lab_automation_assistant'"
None, description="GNS3-Copilot mode: 'teaching_assistant' or 'lab_automation_assistant'"
)
# Allow extra config fields
model_config = ConfigDict(extra="allow")
@field_validator('max_tokens', mode='before')
@field_validator("max_tokens", mode="before")
@classmethod
def validate_max_tokens(cls, v):
"""Handle string 'null' values for max_tokens."""
@@ -150,8 +147,7 @@ class LLMModelConfigDataWithoutSecret(BaseModel):
"balanced", description="Context trimming strategy: conservative (60%), balanced (75%), aggressive (85%)"
)
copilot_mode: Optional[str] = Field(
None,
description="GNS3-Copilot mode: 'teaching_assistant' or 'lab_automation_assistant'"
None, description="GNS3-Copilot mode: 'teaching_assistant' or 'lab_automation_assistant'"
)
# Allow extra fields for extensibility
+4 -6
View File
@@ -157,13 +157,11 @@ class NodeBase(BaseModel):
first_port_name: Optional[str] = Field(None, description="Name of the first port")
custom_adapters: Optional[List[CustomAdapter]] = None
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')"
)
class NodeCreate(NodeBase):
node_id: UUID = Field(default_factory=uuid4)
@@ -178,9 +176,9 @@ class NodeUpdate(NodeBase):
class Node(NodeBase):
template_id: Optional[UUID] = Field(None,
description="Template UUID from which the node has been created. Read only")
template_id: Optional[UUID] = Field(
None, description="Template UUID from which the node has been created. Read only"
)
project_id: Optional[UUID] = None
node_directory: Optional[str] = Field(None, description="Working directory of the node. Read only")
status: Optional[NodeStatus] = Field(None, description="Node status. Read only")
-3
View File
@@ -23,7 +23,6 @@ from .base import DateTimeModelMixin
class ResourceType(str, Enum):
project = "project"
@@ -47,7 +46,6 @@ class ResourceCreate(ResourceBase):
class Resource(DateTimeModelMixin, ResourceBase):
model_config = ConfigDict(from_attributes=True)
@@ -76,6 +74,5 @@ class ResourcePoolUpdate(ResourcePoolBase):
class ResourcePool(DateTimeModelMixin, ResourcePoolBase):
resource_pool_id: UUID
model_config = ConfigDict(from_attributes=True)
@@ -31,13 +31,11 @@ class ProjectStatus(str, Enum):
class Supplier(BaseModel):
logo: str = Field(..., description="Path to the project supplier logo")
url: Optional[HttpUrl] = Field(None, description="URL to the project supplier site")
class Variable(BaseModel):
name: str = Field(..., description="Variable name")
value: Optional[str] = Field(None, description="Variable value")
@@ -91,7 +89,6 @@ class ProjectUpdate(ProjectBase):
class Project(ProjectBase):
project_id: UUID
name: Optional[str] = None
status: Optional[ProjectStatus] = None
@@ -100,7 +97,6 @@ class Project(ProjectBase):
class ProjectFile(BaseModel):
path: str = Field(..., description="File path")
md5sum: str = Field(..., description="File checksum")
-4
View File
@@ -32,13 +32,11 @@ class PrivilegeBase(BaseModel):
class Privilege(DateTimeModelMixin, PrivilegeBase):
privilege_id: UUID
model_config = ConfigDict(from_attributes=True)
class ACEType(str, Enum):
user = "user"
group = "group"
@@ -75,7 +73,6 @@ class ACEUpdate(ACEBase):
class ACE(DateTimeModelMixin, ACEBase):
ace_id: UUID
model_config = ConfigDict(from_attributes=True)
@@ -106,7 +103,6 @@ class RoleUpdate(RoleBase):
class Role(DateTimeModelMixin, RoleBase):
role_id: UUID
is_builtin: bool
privileges: List[Privilege]
+12 -19
View File
@@ -47,11 +47,9 @@ SECRET_MASK = "**********"
class ServerSettingsResponse(ServerSettings):
# plain strings instead of FilePath/DirectoryPath: paths are validated when
# the settings are loaded or updated, not when echoed back to the client
secrets_dir: Optional[str] = Field(
None, description="Directory where secrets are stored (e.g. the JWT secret key)")
secrets_dir: Optional[str] = Field(None, description="Directory where secrets are stored (e.g. the JWT secret key)")
certfile: Optional[str] = Field(None, description="SSL certificate file, requires enable_ssl")
certkey: Optional[str] = Field(None, description="SSL key file, requires enable_ssl")
# Optional overrides: typed as plain "str = None" in the config schema,
@@ -59,28 +57,30 @@ class ServerSettingsResponse(ServerSettings):
resources_path: Optional[str] = Field(
None,
description="Path where files like built-in appliances and Docker resources are stored "
"(defaults to the local user data directory)")
"(defaults to the local user data directory)",
)
default_nat_interface: Optional[str] = Field(
None, description="Interface used by the NAT node, default is virbr0 on Linux (requires libvirt)")
None, description="Interface used by the NAT node, default is virbr0 on Linux (requires libvirt)"
)
class ControllerSettingsResponse(ControllerSettings):
# never serialized: managed via the secrets directory, not the configuration file
jwt_secret_key: Optional[str] = Field(
default=None, exclude=True,
default=None,
exclude=True,
description="Secret key used to sign the JWT authentication tokens "
"(normally managed via the secrets directory, not the configuration file)")
"(normally managed via the secrets directory, not the configuration file)",
)
class IOUSettingsResponse(IOUSettings):
iourc_path: Optional[str] = Field(
None, description="Path of your .iourc file, the file is searched in $HOME/.iourc if not provided")
None, description="Path of your .iourc file, the file is searched in $HOME/.iourc if not provided"
)
class SettingsResponse(BaseModel):
Server: ServerSettingsResponse
Controller: ControllerSettingsResponse
VPCS: VPCSSettings
@@ -160,14 +160,12 @@ class ControllerSettingsUpdate(BaseModel):
class VPCSSettingsUpdate(BaseModel):
model_config = ConfigDict(extra="forbid", str_strip_whitespace=True)
vpcs_path: Optional[str] = None
class DynamipsSettingsUpdate(BaseModel):
model_config = ConfigDict(extra="forbid", str_strip_whitespace=True)
allocate_aux_console_ports: Optional[bool] = None
@@ -178,7 +176,6 @@ class DynamipsSettingsUpdate(BaseModel):
class IOUSettingsUpdate(BaseModel):
model_config = ConfigDict(extra="forbid", str_strip_whitespace=True)
iourc_path: Optional[str] = None
@@ -186,7 +183,6 @@ class IOUSettingsUpdate(BaseModel):
class QemuSettingsUpdate(BaseModel):
model_config = ConfigDict(extra="forbid", str_strip_whitespace=True)
enable_monitor: Optional[bool] = None
@@ -198,7 +194,6 @@ class QemuSettingsUpdate(BaseModel):
class WebWiresharkSettingsUpdate(BaseModel):
model_config = ConfigDict(extra="forbid", str_strip_whitespace=True)
enabled: Optional[bool] = None
@@ -210,7 +205,6 @@ class WebWiresharkSettingsUpdate(BaseModel):
class SettingsUpdate(BaseModel):
model_config = ConfigDict(extra="forbid")
Server: Optional[ServerSettingsUpdate] = None
@@ -223,8 +217,7 @@ class SettingsUpdate(BaseModel):
class SettingsUpdateResponse(SettingsResponse):
restart_required: List[str] = Field(
default_factory=list,
description="Changed 'Section.option' settings that require a server restart to take effect"
description="Changed 'Section.option' settings that require a server restart to take effect",
)
+1 -1
View File
@@ -28,6 +28,7 @@ class SnapshotBase(BaseModel):
name: str = Field(..., description="Name of the snapshot")
description: Optional[str] = Field(None, description="Description of the snapshot")
class SnapshotCreate(SnapshotBase):
"""
Properties for snapshot creation.
@@ -37,7 +38,6 @@ class SnapshotCreate(SnapshotBase):
class Snapshot(SnapshotBase):
snapshot_id: UUID
project_id: UUID
name: str = Field(..., description="Name of the snapshot")
@@ -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
-2
View File
@@ -19,14 +19,12 @@ from pydantic import BaseModel
class Token(BaseModel):
access_token: str
token_type: str
refresh_token: Optional[str] = None
class TokenData(BaseModel):
username: Optional[str] = None
token_version: int = 0
token_use: str = "access"
@@ -33,12 +33,10 @@ from uuid import UUID
class TopologyType(str, Enum):
topology = "topology"
class TopologyContent(BaseModel):
computes: List[Compute] = Field(..., description="List of computes")
drawings: List[Drawing] = Field(..., description="List of drawings")
links: List[Link] = Field(..., description="List of links")
@@ -46,7 +44,6 @@ class TopologyContent(BaseModel):
class Topology(BaseModel):
project_id: UUID = Field(..., description="Project UUID")
type: TopologyType = Field(..., description="Type of file. It's always topology")
revision: int = Field(..., description="Version of the .gns3 specification")
-3
View File
@@ -61,7 +61,6 @@ class LoggedInUserUpdate(BaseModel):
class User(DateTimeModelMixin, UserBase):
user_id: UUID
last_login: Optional[datetime] = None
is_superadmin: bool = False
@@ -93,13 +92,11 @@ class UserGroupUpdate(UserGroupBase):
class UserGroup(DateTimeModelMixin, UserGroupBase):
user_group_id: UUID
is_builtin: bool
model_config = ConfigDict(from_attributes=True)
class Credentials(BaseModel):
username: str
password: str