refactor(gns3server,tests): StrEnum, ASYNC109 and others

This commit is contained in:
Mark Paronyan committed 2026-10-17 12:02:53 +03:00
1 parent b7e6c02647
commit 4c311baabf
54 files changed
+195 -165

No files matched your search

+22 -22
View File
@@ -16,7 +16,7 @@
# Unified Pydantic model supporting both appliance registry versions using discriminated unions
from enum import Enum
from enum import StrEnum
from typing import Annotated, List, Literal, Optional, Union
from uuid import UUID
@@ -29,7 +29,7 @@ from ..common import ExtraConfig
# ============================================================================
class Category(str, Enum):
class Category(StrEnum):
"""Appliance category enum"""
router = "router"
@@ -39,7 +39,7 @@ class Category(str, Enum):
guest = "guest"
class Status(str, Enum):
class Status(StrEnum):
"""Appliance status enum"""
stable = "stable"
@@ -47,7 +47,7 @@ class Status(str, Enum):
broken = "broken"
class Availability(str, Enum):
class Availability(StrEnum):
"""Image availability enum"""
free = "free"
@@ -56,7 +56,7 @@ class Availability(str, Enum):
service_contract = "service-contract"
class Compression(str, Enum):
class Compression(StrEnum):
"""Compression type enum"""
bzip2 = "bzip2"
@@ -68,7 +68,7 @@ class Compression(str, Enum):
field_7z = "7z"
class DynamipsPlatform(str, Enum):
class DynamipsPlatform(StrEnum):
"""Dynamips platform enum"""
c1700 = "c1700"
@@ -80,7 +80,7 @@ class DynamipsPlatform(str, Enum):
c7200 = "c7200"
class DynamipsChassis(str, Enum):
class DynamipsChassis(StrEnum):
"""Dynamips chassis enum"""
chassis_1720 = "1720"
@@ -103,7 +103,7 @@ class DynamipsChassis(str, Enum):
_ = ""
class DynamipsSlot(str, Enum):
class DynamipsSlot(StrEnum):
"""Dynamips slot enum"""
C7200_IO_2FE = "C7200-IO-2FE"
@@ -134,7 +134,7 @@ class DynamipsSlot(str, Enum):
_ = ""
class DynamipsWic(str, Enum):
class DynamipsWic(StrEnum):
"""Dynamips WIC enum"""
WIC_1ENET = "WIC-1ENET"
@@ -143,14 +143,14 @@ class DynamipsWic(str, Enum):
_ = ""
class DynamipsMidplane(str, Enum):
class DynamipsMidplane(StrEnum):
"""Dynamips midplane enum"""
std = "std"
vxr = "vxr"
class DynamipsNpe(str, Enum):
class DynamipsNpe(StrEnum):
"""Dynamips NPE enum"""
npe_100 = "npe-100"
@@ -163,7 +163,7 @@ class DynamipsNpe(str, Enum):
npe_g2 = "npe-g2"
class QemuConsoleType(str, Enum):
class QemuConsoleType(StrEnum):
"""Qemu console type enum"""
telnet = "telnet"
@@ -174,7 +174,7 @@ class QemuConsoleType(str, Enum):
none = "none"
class QemuAdapterType(str, Enum):
class QemuAdapterType(StrEnum):
"""Qemu adapter type enum"""
e1000 = "e1000"
@@ -200,7 +200,7 @@ class QemuAdapterType(str, Enum):
vmxnet3 = "vmxnet3"
class QemuPlatform(str, Enum):
class QemuPlatform(StrEnum):
"""Qemu platform enum"""
aarch64 = "aarch64"
@@ -233,7 +233,7 @@ class QemuPlatform(str, Enum):
xtensaeb = "xtensaeb"
class QemuDiskInterface(str, Enum):
class QemuDiskInterface(StrEnum):
"""Disk interface enum"""
ide = "ide"
@@ -248,7 +248,7 @@ class QemuDiskInterface(str, Enum):
none = "none"
class QemuBootPriority(str, Enum):
class QemuBootPriority(StrEnum):
"""Boot priority enum"""
c = "c"
@@ -262,7 +262,7 @@ class QemuBootPriority(str, Enum):
nd = "nd"
class QemuOnClose(str, Enum):
class QemuOnClose(StrEnum):
"""Qemu on_close action enum"""
power_off = "power_off"
@@ -270,7 +270,7 @@ class QemuOnClose(str, Enum):
save_vm_state = "save_vm_state"
class QemuProcessPriority(str, Enum):
class QemuProcessPriority(StrEnum):
"""Qemu process priority enum"""
realtime = "realtime"
@@ -281,7 +281,7 @@ class QemuProcessPriority(str, Enum):
very_low = "very low"
class DockerConsoleType(str, Enum):
class DockerConsoleType(StrEnum):
"""Docker console type enum"""
telnet = "telnet"
@@ -293,13 +293,13 @@ class DockerConsoleType(str, Enum):
docker_exec = "docker_exec"
class ChecksumType(str, Enum):
class ChecksumType(StrEnum):
"""Checksum type enum"""
md5 = "md5"
class TemplateType(str, Enum):
class TemplateType(StrEnum):
"""Template type enum"""
docker = "docker"
@@ -313,7 +313,7 @@ class TemplateType(str, Enum):
# ============================================================================
class Kvm(str, Enum):
class Kvm(StrEnum):
"""KVM requirements enum"""
require = "require"
+2 -2
View File
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import uuid
from enum import Enum
from enum import StrEnum
from typing import Any, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, SecretStr, model_validator
@@ -29,7 +29,7 @@ from .base import DateTimeModelMixin
from .capabilities import Capabilities
class Protocol(str, Enum):
class Protocol(StrEnum):
"""
Protocol supported to communicate with a compute.
"""
+3 -3
View File
@@ -14,13 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import Optional
from pydantic import BaseModel, Field
class WhenExit(str, Enum):
class WhenExit(StrEnum):
"""
What to do with the VM when GNS3 VM exits.
"""
@@ -30,7 +30,7 @@ class WhenExit(str, Enum):
keep = "keep"
class Engine(str, Enum):
class Engine(StrEnum):
"""
"The engine to use for the GNS3 VM.
"""
+2 -2
View File
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import datetime
from enum import Enum
from enum import StrEnum
from typing import Annotated, List, Literal, Optional
from uuid import UUID
@@ -24,7 +24,7 @@ from pydantic import BaseModel, ConfigDict, Field
from .base import DateTimeModelMixin
class ImageType(str, Enum):
class ImageType(StrEnum):
qemu = "qemu"
ios = "ios"
iou = "iou"
+3 -3
View File
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import Annotated, List, Literal, Optional, Tuple, Union
from uuid import UUID, uuid4
@@ -62,7 +62,7 @@ class LinkNodeCreate(BaseModel):
return self
class LinkType(str, Enum):
class LinkType(StrEnum):
"""
Link type.
"""
@@ -81,7 +81,7 @@ class LinkStyle(BaseModel):
control_offset: Optional[Tuple[float, float]] = None
class LinkFilterType(str, Enum):
class LinkFilterType(StrEnum):
"""
Packet filter type. The first five run on relay and kernel-datapath links
alike; the rest are kernel-datapath only (tc netem / cls_bpf / the eBPF
+4 -4
View File
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import List, Optional, Union
from uuid import UUID, uuid4
@@ -25,7 +25,7 @@ from ..update import PartialUpdateModel
from .labels import Label
class NodeType(str, Enum):
class NodeType(StrEnum):
"""
Supported node types.
"""
@@ -56,7 +56,7 @@ class Image(BaseModel):
filesize: Optional[int] = None
class LinkType(str, Enum):
class LinkType(StrEnum):
"""
Supported link types.
"""
@@ -65,7 +65,7 @@ class LinkType(str, Enum):
serial = "serial"
class DataLinkType(str, Enum):
class DataLinkType(StrEnum):
"""
Supported data link types.
"""
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import Any, Dict, List, Optional, Union
from uuid import UUID
@@ -28,7 +28,7 @@ from .projects import Project
from .snapshots import Snapshot
class NotificationAction(str, Enum):
class NotificationAction(StrEnum):
"""
Values of the "action" field of a notification.
"""
+2 -2
View File
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import Optional
from uuid import UUID
@@ -23,7 +23,7 @@ from pydantic import BaseModel, ConfigDict, Field
from .base import DateTimeModelMixin
class ResourceType(str, Enum):
class ResourceType(StrEnum):
project = "project"
+3 -3
View File
@@ -16,7 +16,7 @@
from datetime import datetime
from enum import Enum
from enum import StrEnum
from typing import List, Optional
from uuid import UUID
@@ -25,7 +25,7 @@ from pydantic import BaseModel, Field, HttpUrl
from ..update import PartialUpdateModel
class ProjectStatus(str, Enum):
class ProjectStatus(StrEnum):
"""
Supported project statuses.
"""
@@ -117,7 +117,7 @@ class NodeFile(BaseModel):
file_type: str = Field(..., description="File type determined by the file command")
class ProjectCompression(str, Enum):
class ProjectCompression(StrEnum):
"""
Supported project compression.
"""
+2 -2
View File
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import List, Optional
from uuid import UUID
@@ -37,7 +37,7 @@ class Privilege(DateTimeModelMixin, PrivilegeBase):
model_config = ConfigDict(from_attributes=True)
class ACEType(str, Enum):
class ACEType(StrEnum):
user = "user"
group = "group"
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import List, Optional
from uuid import UUID
@@ -25,7 +25,7 @@ from ..base import DateTimeModelMixin
from ..nodes import NodeType
class Category(str, Enum):
class Category(StrEnum):
"""
Supported categories
"""
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import Optional
from pydantic import Field
@@ -123,7 +123,7 @@ class C3745DynamipsTemplate(C3745DynamipsTemplateBase):
image: str = Field(..., description="Path to the IOS image")
class C3600ChassisType(str, Enum):
class C3600ChassisType(StrEnum):
chassis_3620 = "3620"
chassis_3640 = "3640"
chassis_3660 = "3660"
@@ -162,7 +162,7 @@ class C2691DynamipsTemplate(C2691DynamipsTemplateBase):
image: str = Field(..., description="Path to the IOS image")
class C2600ChassisType(str, Enum):
class C2600ChassisType(StrEnum):
chassis_2610 = "2610"
chassis_2620 = "2620"
chassis_2610xm = "2610XM"
@@ -191,7 +191,7 @@ class C2600DynamipsTemplate(C2600DynamipsTemplateBase):
image: str = Field(..., description="Path to the IOS image")
class C1700ChassisType(str, Enum):
class C1700ChassisType(StrEnum):
chassis_1720 = "1720"
chassis_1721 = "1721"
chassis_1750 = "1750"
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum
from enum import StrEnum
from typing import List, Optional
from pydantic import Field
@@ -37,7 +37,7 @@ DEFAULT_PORTS = [
]
class ConsoleType(str, Enum):
class ConsoleType(StrEnum):
"""
Supported console types for Ethernet switch nodes.
"""
+2 -2
View File
@@ -19,7 +19,7 @@
# This file contains the validation for checking a .gns3 file
#
from enum import Enum
from enum import StrEnum
from typing import List, Optional
from uuid import UUID
@@ -37,7 +37,7 @@ class TopologyLink(Link):
filters: Optional[dict] = None
class TopologyType(str, Enum):
class TopologyType(StrEnum):
topology = "topology"