2024-10-09 12:28:01 +02:00
|
|
|
from typing import List
|
|
|
|
from pydantic import UUID4, BaseModel, ConfigDict, Field
|
|
|
|
|
2024-10-09 12:47:06 +02:00
|
|
|
from deevirt_schema.libvirt.dom import config as configDom
|
2024-10-09 12:28:01 +02:00
|
|
|
|
|
|
|
class VMHardDisk(BaseModel):
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
|
|
vm_id:UUID4
|
|
|
|
storage_block:UUID4 = Field(alias="storage_block_rbd_id")
|
|
|
|
|
|
|
|
class Storage(BaseModel):
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
|
|
id:UUID4 = Field()
|
|
|
|
name:str = Field()
|
|
|
|
|
|
|
|
class StoragePool(BaseModel):
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
|
|
id:UUID4 = Field()
|
|
|
|
name:str = Field()
|
|
|
|
|
|
|
|
class StorageBlock(BaseModel):
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
|
|
id:UUID4 = Field()
|
|
|
|
name:str = Field()
|
|
|
|
size:int = Field()
|
|
|
|
vm_hard_disk:List[VMHardDisk] = Field()
|
|
|
|
|
2024-10-09 12:47:06 +02:00
|
|
|
class DiskDriver(configDom.DevicesDiskDriver):
|
2024-10-09 12:28:01 +02:00
|
|
|
name:str = Field(default="qemu")
|
2024-10-09 12:47:06 +02:00
|
|
|
type:configDom.DevicesDiskDriver.enumType = Field(default=configDom.DevicesDiskDriver.enumType.raw)
|
2024-10-09 12:28:01 +02:00
|
|
|
|
2024-10-09 12:47:06 +02:00
|
|
|
class DiskAuthSecret(configDom.DevicesDiskAuthSecret):
|
|
|
|
type:configDom.DevicesDiskAuthSecret.enumType = Field(default=configDom.DevicesDiskAuthSecret.enumType.ceph)
|
2024-10-09 12:28:01 +02:00
|
|
|
|
2024-10-09 12:47:06 +02:00
|
|
|
class DiskAuth(configDom.DevicesDiskAuth):
|
2024-10-09 12:28:01 +02:00
|
|
|
secret:DiskAuthSecret = Field(default=DiskAuthSecret())
|
|
|
|
|
2024-10-09 12:47:06 +02:00
|
|
|
class DiskSourceHost(configDom.DevicesDiskSourceHost):
|
2024-10-09 12:28:01 +02:00
|
|
|
port:int = Field(default=6689)
|
|
|
|
|
2024-10-09 12:47:06 +02:00
|
|
|
class DiskSource(configDom.DevicesDiskSource):
|
|
|
|
protocol:configDom.DevicesDiskSource.enumProtocol = Field(default=configDom.DevicesDiskSource.enumProtocol.rbd)
|
2024-10-09 12:28:01 +02:00
|
|
|
|
2024-10-09 12:47:06 +02:00
|
|
|
class DiskTarget(configDom.DevicesDiskTarget):
|
2024-10-09 12:28:01 +02:00
|
|
|
bus:str = Field(default="virtio")
|
|
|
|
|
2024-10-09 12:47:06 +02:00
|
|
|
class Disk(configDom.DevicesDisk):
|
|
|
|
type:configDom.DevicesDisk.enumType = Field(default=configDom.DevicesDisk.enumType.network)
|
2024-10-09 12:28:01 +02:00
|
|
|
device:str = Field(default="disk")
|
|
|
|
driver:DiskDriver = Field(default=DiskDriver())
|
|
|
|
source:DiskSource = Field(default=DiskSource())
|
|
|
|
target:DiskTarget = Field(default=DiskTarget())
|
|
|
|
size:int = Field(default=0)
|
|
|
|
|
|
|
|
class DiskCreate(Disk):
|
|
|
|
size:int = Field()
|
|
|
|
order:int = Field(default=0, json_schema_extra={"hidden": True})
|
|
|
|
|
|
|
|
class DiskAttached(BaseModel):
|
|
|
|
order:int = Field()
|
|
|
|
|
|
|
|
class BlockCreate(BaseModel):
|
|
|
|
size:int = Field()
|
|
|
|
|