mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
Handle creating Qemu disk images and resizing
This commit is contained in:
1 parent
888c773dc0
commit
fda2a37b98
20 files changed
+701
-472
No files matched your search
@@ -73,9 +73,12 @@ from .compute.dynamips_nodes import DynamipsCreate, DynamipsUpdate, Dynamips
|
||||
from .compute.ethernet_hub_nodes import EthernetHubCreate, EthernetHubUpdate, EthernetHub
|
||||
from .compute.ethernet_switch_nodes import EthernetSwitchCreate, EthernetSwitchUpdate, EthernetSwitch
|
||||
from .compute.frame_relay_switch_nodes import FrameRelaySwitchCreate, FrameRelaySwitchUpdate, FrameRelaySwitch
|
||||
from .compute.qemu_nodes import QemuCreate, QemuUpdate, QemuImageCreate, QemuImageUpdate, QemuDiskResize, Qemu
|
||||
from .compute.qemu_nodes import QemuCreate, QemuUpdate, Qemu
|
||||
from .compute.iou_nodes import IOUCreate, IOUUpdate, IOUStart, IOU
|
||||
from .compute.nat_nodes import NATCreate, NATUpdate, NAT
|
||||
from .compute.vpcs_nodes import VPCSCreate, VPCSUpdate, VPCS
|
||||
from .compute.vmware_nodes import VMwareCreate, VMwareUpdate, VMware
|
||||
from .compute.virtualbox_nodes import VirtualBoxCreate, VirtualBoxUpdate, VirtualBox
|
||||
|
||||
# Schemas for both controller and compute
|
||||
from .qemu_disk_image import QemuDiskImageCreate, QemuDiskImageUpdate
|
||||
@@ -15,7 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, Union
|
||||
from typing import Optional
|
||||
from enum import Enum
|
||||
|
||||
|
||||
|
||||
@@ -232,113 +232,7 @@ class Qemu(QemuBase):
|
||||
status: NodeStatus = Field(..., description="Container status (read only)")
|
||||
|
||||
|
||||
class QemuDriveName(str, Enum):
|
||||
"""
|
||||
Supported Qemu drive names.
|
||||
"""
|
||||
|
||||
hda = "hda"
|
||||
hdb = "hdb"
|
||||
hdc = "hdc"
|
||||
hdd = "hdd"
|
||||
|
||||
|
||||
class QemuDiskResize(BaseModel):
|
||||
"""
|
||||
Properties to resize a Qemu disk.
|
||||
"""
|
||||
|
||||
drive_name: QemuDriveName = Field(..., description="Qemu drive name")
|
||||
extend: int = Field(..., description="Number of Megabytes to extend the image")
|
||||
|
||||
|
||||
class QemuBinaryPath(BaseModel):
|
||||
|
||||
path: str
|
||||
version: str
|
||||
|
||||
|
||||
class QemuImageFormat(str, Enum):
|
||||
"""
|
||||
Supported Qemu image formats.
|
||||
"""
|
||||
|
||||
qcow2 = "qcow2"
|
||||
qcow = "qcow"
|
||||
vpc = "vpc"
|
||||
vdi = "vdi"
|
||||
vdmk = "vdmk"
|
||||
raw = "raw"
|
||||
|
||||
|
||||
class QemuImagePreallocation(str, Enum):
|
||||
"""
|
||||
Supported Qemu image preallocation options.
|
||||
"""
|
||||
|
||||
off = "off"
|
||||
metadata = "metadata"
|
||||
falloc = "falloc"
|
||||
full = "full"
|
||||
|
||||
|
||||
class QemuImageOnOff(str, Enum):
|
||||
"""
|
||||
Supported Qemu image on/off options.
|
||||
"""
|
||||
|
||||
on = "off"
|
||||
off = "off"
|
||||
|
||||
|
||||
class QemuImageSubformat(str, Enum):
|
||||
"""
|
||||
Supported Qemu image preallocation options.
|
||||
"""
|
||||
|
||||
dynamic = "dynamic"
|
||||
fixed = "fixed"
|
||||
stream_optimized = "streamOptimized"
|
||||
two_gb_max_extent_sparse = "twoGbMaxExtentSparse"
|
||||
two_gb_max_extent_flat = "twoGbMaxExtentFlat"
|
||||
monolithic_sparse = "monolithicSparse"
|
||||
monolithic_flat = "monolithicFlat"
|
||||
|
||||
|
||||
class QemuImageAdapterType(str, Enum):
|
||||
"""
|
||||
Supported Qemu image on/off options.
|
||||
"""
|
||||
|
||||
ide = "ide"
|
||||
lsilogic = "lsilogic"
|
||||
buslogic = "buslogic"
|
||||
legacy_esx = "legacyESX"
|
||||
|
||||
|
||||
class QemuImageBase(BaseModel):
|
||||
|
||||
qemu_img: str = Field(..., description="Path to the qemu-img binary")
|
||||
path: str = Field(..., description="Absolute or relative path of the image")
|
||||
format: QemuImageFormat = Field(..., description="Image format type")
|
||||
size: int = Field(..., description="Image size in Megabytes")
|
||||
preallocation: Optional[QemuImagePreallocation]
|
||||
cluster_size: Optional[int]
|
||||
refcount_bits: Optional[int]
|
||||
lazy_refcounts: Optional[QemuImageOnOff]
|
||||
subformat: Optional[QemuImageSubformat]
|
||||
static: Optional[QemuImageOnOff]
|
||||
zeroed_grain: Optional[QemuImageOnOff]
|
||||
adapter_type: Optional[QemuImageAdapterType]
|
||||
|
||||
|
||||
class QemuImageCreate(QemuImageBase):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class QemuImageUpdate(QemuImageBase):
|
||||
|
||||
format: Optional[QemuImageFormat] = Field(None, description="Image format type")
|
||||
size: Optional[int] = Field(None, description="Image size in Megabytes")
|
||||
extend: Optional[int] = Field(None, description="Number of Megabytes to extend the image")
|
||||
@@ -0,0 +1,103 @@
|
||||
#
|
||||
# Copyright (C) 2022 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# 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 pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class QemuDiskImageFormat(str, Enum):
|
||||
"""
|
||||
Supported Qemu disk image formats.
|
||||
"""
|
||||
|
||||
qcow2 = "qcow2"
|
||||
qcow = "qcow"
|
||||
vpc = "vpc"
|
||||
vdi = "vdi"
|
||||
vdmk = "vdmk"
|
||||
raw = "raw"
|
||||
|
||||
|
||||
class QemuDiskImagePreallocation(str, Enum):
|
||||
"""
|
||||
Supported Qemu disk image pre-allocation options.
|
||||
"""
|
||||
|
||||
off = "off"
|
||||
metadata = "metadata"
|
||||
falloc = "falloc"
|
||||
full = "full"
|
||||
|
||||
|
||||
class QemuDiskImageOnOff(str, Enum):
|
||||
"""
|
||||
Supported Qemu image on/off options.
|
||||
"""
|
||||
|
||||
on = "on"
|
||||
off = "off"
|
||||
|
||||
|
||||
class QemuDiskImageSubformat(str, Enum):
|
||||
"""
|
||||
Supported Qemu disk image sub-format options.
|
||||
"""
|
||||
|
||||
dynamic = "dynamic"
|
||||
fixed = "fixed"
|
||||
stream_optimized = "streamOptimized"
|
||||
two_gb_max_extent_sparse = "twoGbMaxExtentSparse"
|
||||
two_gb_max_extent_flat = "twoGbMaxExtentFlat"
|
||||
monolithic_sparse = "monolithicSparse"
|
||||
monolithic_flat = "monolithicFlat"
|
||||
|
||||
|
||||
class QemuDiskImageAdapterType(str, Enum):
|
||||
"""
|
||||
Supported Qemu disk image on/off options.
|
||||
"""
|
||||
|
||||
ide = "ide"
|
||||
lsilogic = "lsilogic"
|
||||
buslogic = "buslogic"
|
||||
legacy_esx = "legacyESX"
|
||||
|
||||
|
||||
class QemuDiskImageBase(BaseModel):
|
||||
|
||||
format: QemuDiskImageFormat = Field(..., description="Image format type")
|
||||
size: int = Field(..., description="Image size in Megabytes")
|
||||
preallocation: Optional[QemuDiskImagePreallocation]
|
||||
cluster_size: Optional[int]
|
||||
refcount_bits: Optional[int]
|
||||
lazy_refcounts: Optional[QemuDiskImageOnOff]
|
||||
subformat: Optional[QemuDiskImageSubformat]
|
||||
static: Optional[QemuDiskImageOnOff]
|
||||
zeroed_grain: Optional[QemuDiskImageOnOff]
|
||||
adapter_type: Optional[QemuDiskImageAdapterType]
|
||||
|
||||
|
||||
class QemuDiskImageCreate(QemuDiskImageBase):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class QemuDiskImageUpdate(QemuDiskImageBase):
|
||||
|
||||
format: Optional[QemuDiskImageFormat] = Field(None, description="Image format type")
|
||||
size: Optional[int] = Field(None, description="Image size in Megabytes")
|
||||
extend: Optional[int] = Field(None, description="Number of Megabytes to extend the image")
|
||||
Reference in new issue
Block a user