from typing import List from pydantic_xml import element, attr from pydantic import UUID4, BaseModel, ConfigDict, Field from deevirt_common.lib.virt import vm as vmVirt 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() class DiskDriver(vmVirt.DiskDriver): name:str = Field(default="qemu") type:vmVirt.DiskDriver.enumType = Field(default=vmVirt.DiskDriver.enumType.raw) class DiskAuthSecret(vmVirt.DiskAuthSecret): type:vmVirt.DiskAuthSecret.enumType = Field(default=vmVirt.DiskAuthSecret.enumType.ceph) class DiskAuth(vmVirt.DiskAuth): secret:DiskAuthSecret = Field(default=DiskAuthSecret()) class DiskSourceHost(vmVirt.DiskSourceHost): port:int = Field(default=6689) class DiskSource(vmVirt.DiskSource): protocol:vmVirt.DiskSource.enumProtocol = Field(default=vmVirt.DiskSource.enumProtocol.rbd) class DiskTarget(vmVirt.DiskTarget): bus:str = Field(default="virtio") class Disk(vmVirt.Disk): type:vmVirt.Disk.enumType = Field(default=vmVirt.Disk.enumType.network) 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()