From 0c7d70eb2d17b664fbeca42f5dd5c2de901f585a Mon Sep 17 00:00:00 2001 From: "j.gohier" Date: Tue, 15 Oct 2024 13:54:41 +0200 Subject: [PATCH] modification sur NETWORK Schema --- api/storage.py | 13 ++++++++----- api/vm.py | 14 +++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/api/storage.py b/api/storage.py index 628286e..11004ce 100644 --- a/api/storage.py +++ b/api/storage.py @@ -1,7 +1,8 @@ from typing import List from pydantic import UUID4, BaseModel, ConfigDict, Field +from pydantic_xml import attr -from deevirt_schema.libvirt.dom import config as configDom +from ..libvirt.dom import config as configDom class VMHardDisk(BaseModel): model_config = ConfigDict(from_attributes=True) @@ -31,10 +32,10 @@ class StorageBlock(BaseModel): class DiskDriver(configDom.DevicesDiskDriver): name:str = Field(default="qemu") - type:configDom.DevicesDiskDriver.enumType = Field(default=configDom.DevicesDiskDriver.enumType.raw) + type:configDom.DevicesDiskDriver.typeEnum = Field(default=configDom.DevicesDiskDriver.typeEnum.raw) class DiskAuthSecret(configDom.DevicesDiskAuthSecret): - type:configDom.DevicesDiskAuthSecret.enumType = Field(default=configDom.DevicesDiskAuthSecret.enumType.ceph) + type:configDom.DevicesDiskAuthSecret.typeEnum = Field(default=configDom.DevicesDiskAuthSecret.typeEnum.ceph) class DiskAuth(configDom.DevicesDiskAuth): secret:DiskAuthSecret = Field(default=DiskAuthSecret()) @@ -43,13 +44,15 @@ class DiskSourceHost(configDom.DevicesDiskSourceHost): port:int = Field(default=6689) class DiskSource(configDom.DevicesDiskSource): - protocol:configDom.DevicesDiskSource.enumProtocol = Field(default=configDom.DevicesDiskSource.enumProtocol.rbd) + name:str = Field(default="source") + protocol:configDom.DevicesDiskSource.protocolEnum = Field(default=configDom.DevicesDiskSource.protocolEnum.rbd) class DiskTarget(configDom.DevicesDiskTarget): + dev:str = Field(default="dev") bus:str = Field(default="virtio") class Disk(configDom.DevicesDisk): - type:configDom.DevicesDisk.enumType = Field(default=configDom.DevicesDisk.enumType.network) + type:configDom.DevicesDisk.typeEnum = Field(default=configDom.DevicesDisk.typeEnum.network) device:str = Field(default="disk") driver:DiskDriver = Field(default=DiskDriver()) source:DiskSource = Field(default=DiskSource()) diff --git a/api/vm.py b/api/vm.py index 9baf848..0e63d04 100644 --- a/api/vm.py +++ b/api/vm.py @@ -40,10 +40,10 @@ class OSBootOrder(BaseModel): class OSInfo(BaseModel): model_config = ConfigDict(from_attributes=True) - name:str = Field(alias="os.name") - version:str = Field(alias="os.version-id") - machine:str = Field(alias="os.machine") - kernel:str = Field(alias="os.kernel-release") + name:str = Field(alias="os.name", serialization_alias="os_name") + version:str = Field(alias="os.version-id", serialization_alias="os_version") + machine:str = Field(alias="os.machine", serialization_alias="os_machine") + kernel:str = Field(alias="os.kernel-release", serialization_alias="os_kernel_release") class OS(BaseModel): firmware:configDom.OS.firmwareEnum = Field(default=configDom.OS.firmwareEnum.bios, description="Microprogramme") @@ -124,10 +124,10 @@ class Devices(BaseModel): cdrom:Optional[DevicesCDROM] = Field(default=None, description="CDROM virtuel") interfaces:Optional[List[DevicesInterface]] = Field(default=None, description="Interfaces réseau") graphics:Optional[Graphics] = Field(default=None, description="Console VNC") - audio:Audio = Field(default=None, description="Carte Audio") - video:Video = Field(default=None, description="Carte Vidéo") + audio:Optional[Audio] = Field(default=None, description="Carte Audio") + video:Optional[Video] = Field(default=None, description="Carte Vidéo") watchdog:Watchdog = Field(default=None, description="Chien de garde") - tpm:TPM = Field(default=None, description="Puce de sécurité") + tpm:Optional[TPM] = Field(default=None, description="Puce de sécurité") class VM(BaseModel): model_config = ConfigDict(from_attributes=True)