mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 22:41:12 +02:00
Merge branch '3.1' into image-manager-out-of-sync
This commit is contained in:
129 files changed
+944
-863
No files matched your search
@@ -782,7 +782,7 @@ Appliance = ApplianceUnion
|
||||
# Create a validator wrapper for convenience
|
||||
from pydantic import TypeAdapter
|
||||
|
||||
_appliance_validator = TypeAdapter(ApplianceUnion)
|
||||
_appliance_validator: TypeAdapter[Union[ApplianceV1_6, ApplianceV8]] = TypeAdapter(ApplianceUnion)
|
||||
|
||||
|
||||
class ApplianceModel:
|
||||
|
||||
@@ -38,10 +38,10 @@ class ComputeBase(BaseModel):
|
||||
Data to create a compute.
|
||||
"""
|
||||
|
||||
protocol: Protocol
|
||||
host: str
|
||||
port: int = Field(..., gt=0, le=65535)
|
||||
user: str = None
|
||||
protocol: Optional[Protocol] = None
|
||||
host: Optional[str] = None
|
||||
port: Optional[int] = Field(None, gt=0, le=65535)
|
||||
user: Optional[str] = None
|
||||
password: Optional[SecretStr] = None
|
||||
name: Optional[str] = None
|
||||
model_config = ConfigDict(use_enum_values=True)
|
||||
@@ -52,7 +52,10 @@ class ComputeCreate(ComputeBase):
|
||||
Data to create a compute.
|
||||
"""
|
||||
|
||||
compute_id: Union[str, uuid.UUID] = None
|
||||
protocol: Protocol
|
||||
host: str
|
||||
port: int = Field(..., gt=0, le=65535)
|
||||
compute_id: Optional[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"}
|
||||
@@ -77,9 +80,6 @@ class ComputeUpdate(ComputeBase):
|
||||
Data to update a compute.
|
||||
"""
|
||||
|
||||
protocol: Optional[Protocol] = None
|
||||
host: Optional[str] = None
|
||||
port: Optional[int] = Field(None, gt=0, le=65535)
|
||||
user: Optional[str] = None
|
||||
password: Optional[SecretStr] = None
|
||||
model_config = ConfigDict(
|
||||
@@ -110,6 +110,9 @@ class Compute(DateTimeModelMixin, ComputeBase):
|
||||
Data returned for a compute.
|
||||
"""
|
||||
|
||||
protocol: Protocol
|
||||
host: str
|
||||
port: int = Field(..., gt=0, le=65535)
|
||||
compute_id: Union[str, uuid.UUID]
|
||||
name: str
|
||||
connected: Optional[bool] = Field(None, description="Whether the controller is connected to the compute or not")
|
||||
|
||||
@@ -114,9 +114,9 @@ class NodeBase(BaseModel):
|
||||
Node data.
|
||||
"""
|
||||
|
||||
compute_id: Union[UUID, str]
|
||||
name: str
|
||||
node_type: NodeType
|
||||
compute_id: Optional[Union[UUID, str]] = None
|
||||
name: Optional[str] = None
|
||||
node_type: Optional[NodeType] = None
|
||||
|
||||
node_id: Optional[UUID] = None
|
||||
|
||||
@@ -162,6 +162,9 @@ class NodeBase(BaseModel):
|
||||
|
||||
|
||||
class NodeCreate(NodeBase):
|
||||
compute_id: Union[UUID, str]
|
||||
name: str
|
||||
node_type: NodeType
|
||||
node_id: UUID = Field(default_factory=uuid4)
|
||||
|
||||
|
||||
@@ -170,12 +173,13 @@ class NodeUpdate(NodeBase):
|
||||
Data to update a node.
|
||||
"""
|
||||
|
||||
compute_id: Optional[Union[UUID, str]] = None
|
||||
name: Optional[str] = None
|
||||
node_type: Optional[NodeType] = None
|
||||
pass
|
||||
|
||||
|
||||
class Node(NodeBase):
|
||||
compute_id: Union[UUID, str]
|
||||
name: str
|
||||
node_type: NodeType
|
||||
template_id: Optional[UUID] = Field(
|
||||
None, description="Template UUID from which the node has been created. Read only"
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ class ProjectBase(BaseModel):
|
||||
Common properties for projects.
|
||||
"""
|
||||
|
||||
name: str
|
||||
name: Optional[str] = None
|
||||
project_id: Optional[UUID] = None
|
||||
path: Optional[str] = Field(None, description="Project directory")
|
||||
auto_close: Optional[bool] = Field(None, description="Close project when last client leaves")
|
||||
@@ -69,7 +69,7 @@ class ProjectCreate(ProjectBase):
|
||||
Properties for project creation.
|
||||
"""
|
||||
|
||||
pass
|
||||
name: str
|
||||
|
||||
|
||||
class ProjectDuplicate(ProjectBase):
|
||||
@@ -77,6 +77,7 @@ class ProjectDuplicate(ProjectBase):
|
||||
Properties for project duplication.
|
||||
"""
|
||||
|
||||
name: str
|
||||
reset_mac_addresses: Optional[bool] = Field(False, description="Reset MAC addresses for this project")
|
||||
|
||||
|
||||
@@ -85,12 +86,11 @@ class ProjectUpdate(ProjectBase):
|
||||
Properties for project update.
|
||||
"""
|
||||
|
||||
name: Optional[str] = None
|
||||
pass
|
||||
|
||||
|
||||
class Project(ProjectBase):
|
||||
project_id: UUID
|
||||
name: Optional[str] = None
|
||||
status: Optional[ProjectStatus] = None
|
||||
filename: Optional[str] = None
|
||||
created_by: Optional[str] = Field(None, description="Username of the user who created the project")
|
||||
|
||||
@@ -25,6 +25,7 @@ says, so exposing or writing it via the API would be useless at best and
|
||||
a secret leak at worst.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import ConfigDict, BaseModel, Field
|
||||
@@ -49,9 +50,11 @@ 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)")
|
||||
certfile: Optional[str] = Field(None, description="SSL certificate file, requires enable_ssl")
|
||||
certkey: Optional[str] = Field(None, description="SSL key file, requires enable_ssl")
|
||||
secrets_dir: Optional[Path] = Field(
|
||||
None, description="Directory where secrets are stored (e.g. the JWT secret key)"
|
||||
)
|
||||
certfile: Optional[Path] = Field(None, description="SSL certificate file, requires enable_ssl")
|
||||
certkey: Optional[Path] = Field(None, description="SSL key file, requires enable_ssl")
|
||||
# Optional overrides: typed as plain "str = None" in the config schema,
|
||||
# which fails re-validation when the value actually is None
|
||||
resources_path: Optional[str] = Field(
|
||||
|
||||
@@ -22,11 +22,11 @@ from pydantic import Field
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
class DockerTemplate(TemplateBase):
|
||||
class DockerTemplateBase(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")
|
||||
image: Optional[str] = Field(None, 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})$|^$"
|
||||
@@ -58,5 +58,9 @@ class DockerTemplate(TemplateBase):
|
||||
custom_adapters: Optional[List[CustomAdapter]] = Field(default_factory=list, description="Custom adapters")
|
||||
|
||||
|
||||
class DockerTemplateUpdate(DockerTemplate):
|
||||
image: Optional[str] = Field(None, description="Docker image name")
|
||||
class DockerTemplate(DockerTemplateBase):
|
||||
image: str = Field(..., description="Docker image name")
|
||||
|
||||
|
||||
class DockerTemplateUpdate(DockerTemplateBase):
|
||||
pass
|
||||
@@ -30,12 +30,12 @@ from typing import Optional
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class DynamipsTemplate(TemplateBase):
|
||||
class DynamipsTemplateBase(TemplateBase):
|
||||
category: Optional[Category] = Category.router
|
||||
default_name_format: Optional[str] = "R{0}"
|
||||
symbol: Optional[str] = "router"
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
exec_area: Optional[int] = Field(64, ge=0, description="Exec area value")
|
||||
mmap: Optional[bool] = Field(True, description="MMAP feature")
|
||||
mac_addr: Optional[str] = Field(
|
||||
@@ -67,7 +67,12 @@ class DynamipsTemplate(TemplateBase):
|
||||
wic2: Optional[DynamipsWics] = Field(None, description="Network module WIC slot 2")
|
||||
|
||||
|
||||
class C7200DynamipsTemplate(DynamipsTemplate):
|
||||
class DynamipsTemplate(DynamipsTemplateBase):
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
|
||||
|
||||
class C7200DynamipsTemplateUpdate(DynamipsTemplateBase):
|
||||
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")
|
||||
@@ -75,33 +80,33 @@ class C7200DynamipsTemplate(DynamipsTemplate):
|
||||
sparsemem: Optional[bool] = Field(True, description="Sparse memory feature")
|
||||
|
||||
|
||||
class C7200DynamipsTemplateUpdate(C7200DynamipsTemplate):
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
class C7200DynamipsTemplate(C7200DynamipsTemplateUpdate):
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
|
||||
|
||||
class C3725DynamipsTemplate(DynamipsTemplate):
|
||||
class C3725DynamipsTemplateUpdate(DynamipsTemplateBase):
|
||||
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")
|
||||
sparsemem: Optional[bool] = Field(True, description="Sparse memory feature")
|
||||
|
||||
|
||||
class C3725DynamipsTemplateUpdate(C3725DynamipsTemplate):
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
class C3725DynamipsTemplate(C3725DynamipsTemplateUpdate):
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
|
||||
|
||||
class C3745DynamipsTemplate(DynamipsTemplate):
|
||||
class C3745DynamipsTemplateUpdate(DynamipsTemplateBase):
|
||||
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")
|
||||
sparsemem: Optional[bool] = Field(True, description="Sparse memory feature")
|
||||
|
||||
|
||||
class C3745DynamipsTemplateUpdate(C3745DynamipsTemplate):
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
class C3745DynamipsTemplate(C3745DynamipsTemplateUpdate):
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
|
||||
|
||||
class C3600ChassisType(str, Enum):
|
||||
@@ -110,29 +115,29 @@ class C3600ChassisType(str, Enum):
|
||||
chassis_3660 = "3660"
|
||||
|
||||
|
||||
class C3600DynamipsTemplate(DynamipsTemplate):
|
||||
chassis: Optional[C3600ChassisType] = Field("c3660", description="Chassis type")
|
||||
class C3600DynamipsTemplateUpdate(DynamipsTemplateBase):
|
||||
chassis: Optional[C3600ChassisType] = Field(C3600ChassisType.chassis_3660, 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")
|
||||
iomem: Optional[int] = Field(5, ge=0, le=100, description="I/O memory percentage")
|
||||
sparsemem: Optional[bool] = Field(True, description="Sparse memory feature")
|
||||
|
||||
|
||||
class C3600DynamipsTemplateUpdate(C3600DynamipsTemplate):
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
class C3600DynamipsTemplate(C3600DynamipsTemplateUpdate):
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
|
||||
|
||||
class C2691DynamipsTemplate(DynamipsTemplate):
|
||||
class C2691DynamipsTemplateUpdate(DynamipsTemplateBase):
|
||||
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")
|
||||
sparsemem: Optional[bool] = Field(True, description="Sparse memory feature")
|
||||
|
||||
|
||||
class C2691DynamipsTemplateUpdate(C2691DynamipsTemplate):
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
class C2691DynamipsTemplate(C2691DynamipsTemplateUpdate):
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
|
||||
|
||||
class C2600ChassisType(str, Enum):
|
||||
@@ -147,17 +152,17 @@ class C2600ChassisType(str, Enum):
|
||||
chassis_2651xm = "2651XM"
|
||||
|
||||
|
||||
class C2600DynamipsTemplate(DynamipsTemplate):
|
||||
chassis: Optional[C2600ChassisType] = Field("2651XM", description="Chassis type")
|
||||
class C2600DynamipsTemplateUpdate(DynamipsTemplateBase):
|
||||
chassis: Optional[C2600ChassisType] = Field(C2600ChassisType.chassis_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")
|
||||
iomem: Optional[int] = Field(15, ge=0, le=100, description="I/O memory percentage")
|
||||
sparsemem: Optional[bool] = Field(True, description="Sparse memory feature")
|
||||
|
||||
|
||||
class C2600DynamipsTemplateUpdate(C2600DynamipsTemplate):
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
class C2600DynamipsTemplate(C2600DynamipsTemplateUpdate):
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
|
||||
|
||||
class C1700ChassisType(str, Enum):
|
||||
@@ -168,14 +173,14 @@ class C1700ChassisType(str, Enum):
|
||||
chassis_1760 = "1760"
|
||||
|
||||
|
||||
class C1700DynamipsTemplate(DynamipsTemplate):
|
||||
chassis: Optional[C1700ChassisType] = Field("1760", description="Chassis type")
|
||||
class C1700DynamipsTemplateUpdate(DynamipsTemplateBase):
|
||||
chassis: Optional[C1700ChassisType] = Field(C1700ChassisType.chassis_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")
|
||||
iomem: Optional[int] = Field(15, ge=0, le=100, description="I/O memory percentage")
|
||||
sparsemem: Optional[bool] = Field(False, description="Sparse memory feature")
|
||||
|
||||
|
||||
class C1700DynamipsTemplateUpdate(C1700DynamipsTemplate):
|
||||
platform: Optional[DynamipsPlatform] = Field(None, description="Cisco router platform")
|
||||
image: Optional[str] = Field(None, description="Path to the IOS image")
|
||||
class C1700DynamipsTemplate(C1700DynamipsTemplateUpdate):
|
||||
platform: DynamipsPlatform = Field(..., description="Cisco router platform")
|
||||
image: str = Field(..., description="Path to the IOS image")
|
||||
@@ -22,11 +22,11 @@ from pydantic import Field
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class IOUTemplate(TemplateBase):
|
||||
class IOUTemplateBase(TemplateBase):
|
||||
category: Optional[Category] = Category.router
|
||||
default_name_format: Optional[str] = "IOU{0}"
|
||||
symbol: Optional[str] = "multilayer_switch"
|
||||
path: str = Field(..., description="Path of IOU executable")
|
||||
path: Optional[str] = Field(None, description="Path of IOU executable")
|
||||
ethernet_adapters: Optional[int] = Field(2, ge=0, description="Number of ethernet adapters")
|
||||
serial_adapters: Optional[int] = Field(2, ge=0, description="Number of serial adapters")
|
||||
ram: Optional[int] = Field(1024, gt=0, description="Amount of RAM in MB")
|
||||
@@ -44,5 +44,9 @@ class IOUTemplate(TemplateBase):
|
||||
)
|
||||
|
||||
|
||||
class IOUTemplateUpdate(IOUTemplate):
|
||||
path: Optional[str] = Field(None, description="Path of IOU executable")
|
||||
class IOUTemplate(IOUTemplateBase):
|
||||
path: str = Field(..., description="Path of IOU executable")
|
||||
|
||||
|
||||
class IOUTemplateUpdate(IOUTemplateBase):
|
||||
pass
|
||||
@@ -26,11 +26,11 @@ from pydantic import Field
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
class VirtualBoxTemplate(TemplateBase):
|
||||
class VirtualBoxTemplateBase(TemplateBase):
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "{name}-{0}"
|
||||
symbol: Optional[str] = "vbox_guest"
|
||||
vmname: str = Field(..., description="VirtualBox VM name (in VirtualBox itself)")
|
||||
vmname: Optional[str] = Field(None, description="VirtualBox VM name (in VirtualBox itself)")
|
||||
ram: Optional[int] = Field(256, gt=0, description="Amount of RAM in MB")
|
||||
linked_clone: Optional[bool] = Field(False, description="Whether the VM is a linked clone or not")
|
||||
adapters: Optional[int] = Field(
|
||||
@@ -59,5 +59,9 @@ class VirtualBoxTemplate(TemplateBase):
|
||||
custom_adapters: Optional[List[CustomAdapter]] = Field(default_factory=list, description="Custom adapters")
|
||||
|
||||
|
||||
class VirtualBoxTemplateUpdate(VirtualBoxTemplate):
|
||||
vmname: Optional[str] = Field(None, description="VirtualBox VM name (in VirtualBox itself)")
|
||||
class VirtualBoxTemplate(VirtualBoxTemplateBase):
|
||||
vmname: str = Field(..., description="VirtualBox VM name (in VirtualBox itself)")
|
||||
|
||||
|
||||
class VirtualBoxTemplateUpdate(VirtualBoxTemplateBase):
|
||||
pass
|
||||
@@ -27,11 +27,11 @@ from pydantic import Field
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
class VMwareTemplate(TemplateBase):
|
||||
class VMwareTemplateBase(TemplateBase):
|
||||
category: Optional[Category] = Category.guest
|
||||
default_name_format: Optional[str] = "{name}-{0}"
|
||||
symbol: Optional[str] = "vmware_guest"
|
||||
vmx_path: str = Field(..., description="Path to the vmx file")
|
||||
vmx_path: Optional[str] = Field(None, description="Path to the vmx file")
|
||||
linked_clone: Optional[bool] = Field(False, description="Whether the VM is a linked clone or not")
|
||||
first_port_name: Optional[str] = Field("", description="Optional name of the first networking port example: eth0")
|
||||
port_name_format: Optional[str] = Field(
|
||||
@@ -57,5 +57,9 @@ class VMwareTemplate(TemplateBase):
|
||||
custom_adapters: Optional[List[CustomAdapter]] = Field(default_factory=list, description="Custom adapters")
|
||||
|
||||
|
||||
class VMwareTemplateUpdate(VMwareTemplate):
|
||||
vmx_path: Optional[str] = Field(None, description="Path to the vmx file")
|
||||
class VMwareTemplate(VMwareTemplateBase):
|
||||
vmx_path: str = Field(..., description="Path to the vmx file")
|
||||
|
||||
|
||||
class VMwareTemplateUpdate(VMwareTemplateBase):
|
||||
pass
|
||||
@@ -25,7 +25,7 @@ class Token(BaseModel):
|
||||
|
||||
|
||||
class TokenData(BaseModel):
|
||||
username: Optional[str] = None
|
||||
username: str
|
||||
token_version: int = 0
|
||||
token_use: str = "access"
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class UserGroupCreate(UserGroupBase):
|
||||
Properties to create a user group.
|
||||
"""
|
||||
|
||||
name: Optional[str] = Field(..., min_length=3, pattern="[a-zA-Z0-9_-]+$")
|
||||
name: str = Field(..., min_length=3, pattern="[a-zA-Z0-9_-]+$")
|
||||
|
||||
|
||||
class UserGroupUpdate(UserGroupBase):
|
||||
|
||||
Reference in new issue
Block a user