update
This commit is contained in:
parent
c63fe1f517
commit
9b9617540c
57
api/vm.py
57
api/vm.py
|
@ -1,17 +1,7 @@
|
||||||
from typing import List, Tuple, Optional
|
from typing import List, Optional
|
||||||
from enum import Enum, IntEnum
|
from uuid import uuid4
|
||||||
from uuid import UUID, uuid4
|
from pydantic import UUID4, Field, ConfigDict
|
||||||
from pydantic_xml import element, attr, wrapped
|
|
||||||
from pydantic import UUID4, Field, field_serializer, ConfigDict, ValidationInfo, field_validator
|
|
||||||
from pydantic import BaseModel as _BaseModel
|
from pydantic import BaseModel as _BaseModel
|
||||||
from pydantic_core import core_schema as cs
|
|
||||||
|
|
||||||
|
|
||||||
from pydantic_core import core_schema
|
|
||||||
from pydantic.json_schema import GetJsonSchemaHandler, JsonSchemaValue
|
|
||||||
|
|
||||||
#from deevirt_common.lib.virt import vm as domain
|
|
||||||
#from deevirt_common.schemas import datacenter_schema, storage_schema, network_schema, configDom
|
|
||||||
|
|
||||||
from deevirt_schema.libvirt.dom import config as configDom
|
from deevirt_schema.libvirt.dom import config as configDom
|
||||||
|
|
||||||
|
@ -25,8 +15,7 @@ class BaseModel(_BaseModel):
|
||||||
props[k] = v
|
props[k] = v
|
||||||
schema["properties"] = props
|
schema["properties"] = props
|
||||||
|
|
||||||
|
"""Common"""
|
||||||
""" Common """
|
|
||||||
class Resource(BaseModel):
|
class Resource(BaseModel):
|
||||||
"""Experimental"""
|
"""Experimental"""
|
||||||
name:Optional[str] = Field(default=None, description="Nom du pool")
|
name:Optional[str] = Field(default=None, description="Nom du pool")
|
||||||
|
@ -67,30 +56,10 @@ class Clock(BaseModel):
|
||||||
offset:configDom.Clock.offsetEnum = Field(default=configDom.Clock.offsetEnum.utc, description="Sélection de l'offset ?")
|
offset:configDom.Clock.offsetEnum = Field(default=configDom.Clock.offsetEnum.utc, description="Sélection de l'offset ?")
|
||||||
|
|
||||||
class Event(BaseModel):
|
class Event(BaseModel):
|
||||||
class on_poweroffEnum(str, Enum):
|
|
||||||
destroy = "destroy"
|
|
||||||
restart = "restart"
|
|
||||||
preserve = "preverse"
|
|
||||||
|
|
||||||
class on_rebootEnum(str, Enum):
|
|
||||||
restart = "restart"
|
|
||||||
preserve = "preverse"
|
|
||||||
|
|
||||||
class on_crashEnum(str, Enum):
|
|
||||||
destroy = "destroy"
|
|
||||||
restart = "restart"
|
|
||||||
preserve = "preverse"
|
|
||||||
|
|
||||||
class on_failurelockEnum(str, Enum):
|
|
||||||
poweroff = "poweroff"
|
|
||||||
restart = "restart"
|
|
||||||
pause = "pause"
|
|
||||||
ignore = "ignore"
|
|
||||||
|
|
||||||
on_poweroff:configDom.Dom.on_poweroffEnum = Field(default=configDom.Dom.on_poweroffEnum.destroy, description="Action lors d'un poweroff")
|
on_poweroff:configDom.Dom.on_poweroffEnum = Field(default=configDom.Dom.on_poweroffEnum.destroy, description="Action lors d'un poweroff")
|
||||||
on_reboot:configDom.Dom.on_rebootEnum = Field(default=configDom.Dom.on_rebootEnum.restart, description="Action lors d'un redémarrage")
|
on_reboot:configDom.Dom.on_rebootEnum = Field(default=configDom.Dom.on_rebootEnum.restart, description="Action lors d'un redémarrage")
|
||||||
on_crash:configDom.Dom.on_crashEnum = Field(default=configDom.Dom.on_crashEnum.restart, description="Action lors d'un crash de la VM")
|
on_crash:configDom.Dom.on_crashEnum = Field(default=configDom.Dom.on_crashEnum.restart, description="Action lors d'un crash de la VM")
|
||||||
on_failurelock:configDom.Dom.on_failurelockEnum = element(default=configDom.Dom.on_failurelockEnum.ignore, description="A tester")
|
on_failurelock:configDom.Dom.on_failurelockEnum = Field(default=configDom.Dom.on_failurelockEnum.ignore, description="A tester")
|
||||||
|
|
||||||
class DevicesDisk(BaseModel):
|
class DevicesDisk(BaseModel):
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
@ -102,20 +71,14 @@ class DevicesDisk(BaseModel):
|
||||||
bus:configDom.DevicesDiskTarget.busEnum = Field(default=configDom.DevicesDiskTarget.busEnum.scsi)
|
bus:configDom.DevicesDiskTarget.busEnum = Field(default=configDom.DevicesDiskTarget.busEnum.scsi)
|
||||||
|
|
||||||
class DevicesCDROMSource(BaseModel):
|
class DevicesCDROMSource(BaseModel):
|
||||||
class protocolEnum(str, Enum):
|
protocol:configDom.DevicesDiskSource.protocolEnum = Field(default=configDom.DevicesDiskSource.protocolEnum.https)
|
||||||
http = "http"
|
name:str = Field()
|
||||||
https = "https"
|
|
||||||
ftp = "ftp"
|
|
||||||
ftps = "ftps"
|
|
||||||
|
|
||||||
protocol:protocolEnum = attr(default=protocolEnum.https)
|
|
||||||
name:str = attr()
|
|
||||||
|
|
||||||
class DevicesCDROM(BaseModel):
|
class DevicesCDROM(BaseModel):
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
device:configDom.DevicesDisk.deviceEnum = Field(default=configDom.DevicesDisk.deviceEnum.cdrom, json_schema_extra={"hidden": True})
|
device:configDom.DevicesDisk.deviceEnum = Field(default=configDom.DevicesDisk.deviceEnum.cdrom, json_schema_extra={"hidden": True})
|
||||||
source:DevicesCDROMSource = element(default=None)
|
source:DevicesCDROMSource = Field(default=None)
|
||||||
|
|
||||||
class DevicesInterfaceGuest(BaseModel):
|
class DevicesInterfaceGuest(BaseModel):
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
@ -146,14 +109,14 @@ class VideoModel(BaseModel):
|
||||||
primary:configDom.YesNoEnum = Field(default=configDom.YesNoEnum.YES)
|
primary:configDom.YesNoEnum = Field(default=configDom.YesNoEnum.YES)
|
||||||
|
|
||||||
class Video(BaseModel):
|
class Video(BaseModel):
|
||||||
model:VideoModel = element()
|
model:VideoModel = Field()
|
||||||
|
|
||||||
class Watchdog(BaseModel):
|
class Watchdog(BaseModel):
|
||||||
model:configDom.Watchdog.modelEnum = Field(default=configDom.Watchdog.modelEnum.itco)
|
model:configDom.Watchdog.modelEnum = Field(default=configDom.Watchdog.modelEnum.itco)
|
||||||
action:configDom.Watchdog.actionEnum = Field(default=configDom.Watchdog.actionEnum.reset)
|
action:configDom.Watchdog.actionEnum = Field(default=configDom.Watchdog.actionEnum.reset)
|
||||||
|
|
||||||
class TPM(BaseModel):
|
class TPM(BaseModel):
|
||||||
model:configDom.TPM.modelEnum = attr(default=configDom.TPM.modelEnum.tpm_tis)
|
model:configDom.TPM.modelEnum = Field(default=configDom.TPM.modelEnum.tpm_tis)
|
||||||
version:configDom.TPMBackend.versionEnum = Field(default=configDom.TPMBackend.versionEnum.v20)
|
version:configDom.TPMBackend.versionEnum = Field(default=configDom.TPMBackend.versionEnum.v20)
|
||||||
|
|
||||||
class Devices(BaseModel):
|
class Devices(BaseModel):
|
||||||
|
|
Loading…
Reference in New Issue