deevirt_schema/libvirt/dom/config.py

702 lines
21 KiB
Python

from enum import Enum
from typing import List, Optional
from uuid import uuid4
from pydantic import UUID4
from pydantic_xml import BaseXmlModel, attr, element, wrapped
from enum import Enum
class YesNoEnum(str, Enum):
YES = "yes"
NO = "no"
class OnOffEnum(str, Enum):
ON = "on"
OFF = "off"
class UnitEnum(str, Enum):
KiB = "KiB"
MiB = "MiB"
GiB = "GiB"
TiB = "TiB"
class Metadata(BaseXmlModel, search_mode='ordered'):
# wrapped("metadata", element(default=None, ns="deevirt", nsmap={'deevirt': 'https://deevirt.com/'}))
pass
class OSType(BaseXmlModel, search_mode='ordered'):
class archEnum(str, Enum):
x86 = "x86"
x86_64 = "x86_64"
arch:archEnum = attr(default=archEnum.x86_64)
machine:Optional[str] = attr(default="q35")
class OSFirmwareFeature(BaseXmlModel, search_mode='ordered'):
class nameEnum(str, Enum):
enrolled_keys = "enrolled-keys"
secure_boot = "secure-boot"
enabled:YesNoEnum = attr(default=YesNoEnum.YES)
name:nameEnum = attr()
class OSFirmware(BaseXmlModel, search_mode='ordered'):
feature:List[OSFirmwareFeature] = element(default=[
OSFirmwareFeature(
name=OSFirmwareFeature.nameEnum.enrolled_keys
),
OSFirmwareFeature(
name=OSFirmwareFeature.nameEnum.secure_boot
)
]
)
class OSLoader(BaseXmlModel, search_mode='ordered'):
class typeEnum(str, Enum):
nvram = "nvram"
pflash = "pflash"
readonly:YesNoEnum = attr(default=YesNoEnum.YES)
secure:YesNoEnum = attr(default=YesNoEnum.YES)
type:typeEnum = attr(default=typeEnum.pflash)
path:Optional[str] = ""
class OSBoot(BaseXmlModel, search_mode='ordered'):
class bootEnum(str, Enum):
hd = "hd",
network = "network",
cdrom = "cdrom"
dev:bootEnum = attr()
class OSBootMenu(BaseXmlModel, search_mode='ordered'):
enable:YesNoEnum = attr(default=YesNoEnum.NO)
timeout:int = attr(default=0)
class OSSmbios(BaseXmlModel, search_mode='ordered'):
class modeEnum(str, Enum):
sysinfo = "sysinfo"
mode:modeEnum = attr(default=modeEnum.sysinfo)
class OS(BaseXmlModel, search_mode='ordered'):
class firmwareEnum(str, Enum):
bios = "bios"
efi = "efi"
firmware:Optional[firmwareEnum] = attr(default=firmwareEnum.efi)
type:OSType = element(default=OSType())
firmware_options:OSFirmware = element(tag="firmware", default=OSFirmware())
loader:OSLoader = element(default=OSLoader())
nvram:Optional[str] = element(default="")
boot:List[OSBoot] = element(default=[
OSBoot(dev="hd"),
OSBoot(dev="cdrom"),
OSBoot(dev="network")
])
bootmenu:OSBootMenu = element(default=OSBootMenu())
smbios:OSSmbios = element(default=OSSmbios())
class SysinfoEntry(BaseXmlModel, search_mode='ordered'):
name:str = attr()
value:str
class SysinfoBIOS(BaseXmlModel, search_mode='ordered'):
entry:SysinfoEntry = element(default=None)
class SysinfoSystem(BaseXmlModel, search_mode='ordered'):
entry:List[SysinfoEntry] = element(default=[
SysinfoEntry(
name="manufacturer",
value="Celeonet"
),
SysinfoEntry(
name="product",
value="Celeonet Compute"
),
SysinfoEntry(
name="version",
value="1.0"
),
SysinfoEntry(
name="family",
value="Virtual Machine"
)
])
class SysinfoBaseBoard(BaseXmlModel, search_mode='ordered'):
entry:List[SysinfoEntry] = element(default=None)
class SysinfoChassis(BaseXmlModel, search_mode='ordered'):
entry:List[SysinfoEntry] = element(default=None)
class SysinfoOEMStrings(BaseXmlModel, search_mode='ordered'):
entry:List[SysinfoEntry] = element(default=None)
class Sysinfo(BaseXmlModel, search_mode='ordered'):
bios:SysinfoBIOS = element(default=SysinfoBIOS())
system:Optional[SysinfoSystem] = element(default=SysinfoSystem())
baseBoard:Optional[SysinfoBaseBoard] = element(default=SysinfoBaseBoard())
chassis:Optional[SysinfoChassis] = element(default=SysinfoChassis())
oemStrings:Optional[SysinfoOEMStrings] = element(default=SysinfoOEMStrings())
class VCPU(BaseXmlModel, search_mode='ordered'):
class placementEnum(str, Enum):
static = "static"
auto = "auto"
placement:placementEnum = attr(default=placementEnum.auto)
cpuset:str = attr(default=None)
current:int = attr()
max:int = None
class VCPUS(BaseXmlModel, search_mode='ordered'):
id:int = attr()
enabled:YesNoEnum = attr(default=YesNoEnum.YES)
hotpluggable:YesNoEnum = attr(default=YesNoEnum.YES)
order:int = attr()
class CPUTune(BaseXmlModel, search_mode='ordered'):
"""Not implemented"""
pass
class MaxMemory(BaseXmlModel, search_mode='ordered'):
slots:int = attr()
unit:UnitEnum = attr(default=UnitEnum.MiB)
value:int
class Memory(BaseXmlModel, search_mode='ordered'):
unit:UnitEnum = attr(default=UnitEnum.MiB)
value:int
class CurrentMemory(BaseXmlModel, search_mode='ordered'):
unit:UnitEnum = attr(default=UnitEnum.MiB)
value:int
class MemoryBacking(BaseXmlModel, search_mode='ordered'):
"""Not implemented"""
pass
class MemTune(BaseXmlModel, search_mode='ordered'):
"""Not implemented"""
pass
class NumaTuneMemory(BaseXmlModel, search_mode='ordered'):
class modeEnum(str, Enum):
interleave = "interleave"
strict = "strict"
preferred = "preferred"
restrictive = "restrictive"
mode:modeEnum = attr()
modeset:str = attr()
class NumaMemnode(BaseXmlModel, search_mode='ordered'):
cellid:int = attr()
mode:NumaTuneMemory.modeEnum = attr()
nodeset:str = attr()
class NumaTune(BaseXmlModel, search_mode='ordered'):
memory:NumaTuneMemory = element()
memnode:NumaMemnode = element()
class ResourcePartition(BaseXmlModel, search_mode='ordered'):
value:str
class Resource(BaseXmlModel, search_mode='ordered'):
partition:ResourcePartition = element()
class CPUModel(BaseXmlModel, search_mode='ordered'):
class fallbackEnum(str, Enum):
force = "force"
require = "require"
optional = "optional"
disable = "disable"
forbird = "forbid"
fallback:fallbackEnum = attr()
value:str
class CPUTopology(BaseXmlModel, search_mode='ordered'):
sockets:int = attr()
dies:Optional[int] = attr(default=None)
clusters:Optional[int] = attr(default=None)
cores:int = attr()
threads:int = attr()
class CPUCache(BaseXmlModel, search_mode='ordered'):
class modeEnum(str, Enum):
emulate = "emulate"
passthrough = "passthrough"
disable = "disable"
level:int = attr()
mode:modeEnum = attr()
class CPUMaxphysaddr(BaseXmlModel, search_mode='ordered'):
class modeEnum(str, Enum):
emulate = "emulate"
passthrough = "passthrough"
mode:modeEnum = attr()
bits:int = attr()
class CPUFeature(BaseXmlModel, search_mode='ordered'):
class policyEnum(str, Enum):
force = "force"
require = "require"
optional = "optional"
disable = "disable"
forbid = "forbid"
policy:policyEnum = attr()
name:str = attr()
class CPUDistancesSibling(BaseXmlModel, search_mode='ordered'):
id:int = attr()
value:int = attr()
class CPUDistances(BaseXmlModel, search_mode='ordered'):
sibling:Optional[List[CPUDistancesSibling]] = element(default=None)
class CPUNumaCell(BaseXmlModel, search_mode='ordered'):
class memaccessEnum(str, Enum):
shared = "shared"
private = "private"
id:Optional[int] = attr()
cpus:Optional[str] = attr()
memory:Optional[int] = attr()
unit:Optional[UnitEnum] = attr(default=UnitEnum.KiB)
discard:Optional[YesNoEnum] = attr(default=None)
memaccess:Optional[memaccessEnum] = attr(default=None)
distances:Optional[CPUDistances] = element()
class CPUNuma(BaseXmlModel, search_mode='ordered'):
cell:Optional[List[CPUNumaCell]] = element(default=[])
class CPU(BaseXmlModel, search_mode='ordered'):
class matchEnum(str, Enum):
minimum = "minimum"
exact = "exact"
strict = "strict"
class modeEnum(str, Enum):
custom = "custom"
host_model = "host-model"
class checkEnum(str, Enum):
none = "none"
partial = "partial"
full = "full"
match:Optional[matchEnum] = attr(default=None)
mode:modeEnum = attr(default=modeEnum.host_model)
check:Optional[checkEnum] = attr(default=None)
model:Optional[CPUModel] = element(default=None)
vendor:Optional[str] = element(default=None)
topology:Optional[CPUTopology] = element(default=None)
cache:Optional[CPUCache] = element(default=None)
maxphysaddr:Optional[CPUMaxphysaddr] = element(default=None)
feature:Optional[CPUFeature] = element(default=None)
numa:Optional[CPUNuma] = element(default=None)
class PMSuspendToDisk(BaseXmlModel, search_mode='ordered'):
enabled:YesNoEnum = attr(default=YesNoEnum.NO)
class PMSuspendToMem(BaseXmlModel, search_mode='ordered'):
enabled:YesNoEnum = attr(default=YesNoEnum.NO)
class PM(BaseXmlModel, search_mode='ordered'):
suspend_to_disk:PMSuspendToDisk = element(tag="suspend-to-disk", default=PMSuspendToDisk())
suspend_to_mem:PMSuspendToMem = element(tag="suspend-to-mem", default=PMSuspendToMem())
class FeaturesKVMHidden(BaseXmlModel, search_mode='ordered'):
state:OnOffEnum = attr()
class FeaturesKVMHintDedicated(BaseXmlModel, search_mode='ordered'):
state:OnOffEnum = attr()
class FeaturesKVMPollControl(BaseXmlModel, search_mode='ordered'):
state:OnOffEnum = attr()
class FeaturesKVMPvIpi(BaseXmlModel, search_mode='ordered'):
state:OnOffEnum = attr()
class FeaturesKVMDirtyRing(BaseXmlModel, search_mode='ordered'):
state:OnOffEnum = attr()
size:int = attr()
class FeaturesKVM(BaseXmlModel, search_mode='ordered'):
hidden:Optional[FeaturesKVMHidden] = element(default=None)
hint_dedicated:Optional[FeaturesKVMHintDedicated] = element(tag="hint-dedicated", default=None)
poll_control:Optional[FeaturesKVMPollControl] = element(tag="poll-control", default=None)
pv_ipi:Optional[FeaturesKVMPvIpi] = element(tag="pv-ipi", default=None)
dirty_ring:Optional[FeaturesKVMDirtyRing] = element(tag="dirty-ring", default=None)
class Features(BaseXmlModel, search_mode='ordered'):
pae:str = element(default=None)
acpi:str = element(default="enable")
apic:str = element(default="enable")
hap:str = element(default=None)
privnet:str = element(default=None)
kvm:FeaturesKVM = element(default=None)
class ClockTimerCatchup(BaseXmlModel, search_mode='ordered'):
threshold:int = attr()
slew:int = attr()
limit:int = attr()
class ClockTimer(BaseXmlModel, search_mode='ordered'):
class nameEnum(str, Enum):
kvmclock = "kvmclock"
class tickpolicyEnum(str, Enum):
delay = "delay"
catchup = "catchup"
merge = "merge"
discard = "discard"
class trackEnum(str, Enum):
boot = "boot"
guest = "guest"
wall = "wall"
name:nameEnum = attr(default=nameEnum.kvmclock)
tickpolicy:Optional[tickpolicyEnum] = attr(default=None)
track:Optional[trackEnum] = attr(default=None)
catchup:Optional[ClockTimerCatchup] = element(default=None)
class Clock(BaseXmlModel, search_mode='ordered'):
class offsetEnum(str, Enum):
utc = "utc"
localtime = "localtime"
timezone = "timezone"
variable = "variable"
absolute = "absolute"
offset:offsetEnum = attr(default=offsetEnum.localtime)
timer:ClockTimer = element(default=None)
class Perf(BaseXmlModel, search_mode='ordered'):
"""Not implemented"""
pass
class DevicesDiskDriver(BaseXmlModel, search_mode='ordered'):
class nameEnum(str, Enum):
qemu = "qemu"
class typeEnum(str, Enum):
raw = "raw"
class discardEnum(str, Enum):
ignore = "ignore"
unmap = "unmap"
name:nameEnum = attr(default=nameEnum.qemu)
type:typeEnum = attr(default=typeEnum.raw)
discard:discardEnum = attr(default=discardEnum.unmap)
class DevicesDiskAuthSecret(BaseXmlModel, search_mode='ordered'):
class typeEnum(str, Enum):
ceph = "ceph"
type:typeEnum = attr(default=typeEnum.ceph)
uuid:str = attr(default="1")
class DevicesDiskAuth(BaseXmlModel, search_mode='ordered'):
username:str = attr(default="1")
secret:DevicesDiskAuthSecret = element(default=DevicesDiskAuthSecret())
class DevicesDiskSourceHost(BaseXmlModel, search_mode='ordered'):
name:str = attr()
port:int = attr()
class DevicesDiskSource(BaseXmlModel, search_mode='ordered'):
class protocolEnum(str, Enum):
rbd = "rbd"
http = "http"
https = "https"
ftp = "ftp"
ftps = "ftps"
protocol:protocolEnum = attr(default=protocolEnum.rbd)
name:str = attr()
host:List[DevicesDiskSourceHost] = element(default=None)
class DevicesDiskTarget(BaseXmlModel, search_mode='ordered'):
class busEnum(str, Enum):
virtio = "virtio"
scsi = "scsi"
ide = "ide"
dev:str = attr()
bus:busEnum = attr(default=busEnum.virtio)
class DevicesDisk(BaseXmlModel, search_mode='ordered'):
"""
Disk: CEPH Storage only
CDROM: Network Only
"""
class typeEnum(str, Enum):
network = "network"
class deviceEnum(str, Enum):
disk = "disk"
cdrom = "cdrom"
type:typeEnum = attr(default=typeEnum.network)
device:deviceEnum = attr(default=deviceEnum.disk)
driver:DevicesDiskDriver = element(default=DevicesDiskDriver())
auth:DevicesDiskAuth = element(default=None)
source:DevicesDiskSource = element(default=None)
target:DevicesDiskTarget = element(default=None)
serial:UUID4 = element(default_factory=uuid4)
class DevicesInterfaceMAC(BaseXmlModel, search_mode='ordered'):
address:Optional[str] = attr(default=None)
class DevicesInterfaceSource(BaseXmlModel, search_mode='ordered'):
bridge:str = attr(default="br-int")
class DevicesInterfaceVirtualPortParameters(BaseXmlModel, search_mode='ordered'):
interfaceid:UUID4 = attr(default=None)
class DevicesInterfaceVirtualport(BaseXmlModel, search_mode='ordered'):
class typeEnum(str, Enum):
openvswitch = "openvswitch"
type:typeEnum = attr(default=typeEnum.openvswitch)
parameters:DevicesInterfaceVirtualPortParameters = element(default=DevicesInterfaceVirtualPortParameters())
class DevicesInterfaceModel(BaseXmlModel, search_mode='ordered'):
class typeEnum(str, Enum):
virtio = "virtio"
type:typeEnum = attr(default=typeEnum.virtio)
class DevicesInterfaceMTU(BaseXmlModel, search_mode='ordered'):
mtu:int = attr(default=1500)
class DevicesInterface(BaseXmlModel, search_mode='ordered'):
"""Openvswitch Only"""
class typeEnum(str, Enum):
bridge = "bridge"
type:typeEnum = attr(default=typeEnum.bridge)
mac:DevicesInterfaceMAC = element(default=DevicesInterfaceMAC())
source:DevicesInterfaceSource = element(default=DevicesInterfaceSource())
virtualport:DevicesInterfaceVirtualport = element(default=DevicesInterfaceVirtualport())
model:DevicesInterfaceModel = element(default=DevicesInterfaceModel())
mtu:DevicesInterfaceMTU = element(default=DevicesInterfaceMTU())
class DevicesChannelSource(BaseXmlModel, search_mode='ordered'):
class modeEnum(str, Enum):
bind = "bind"
mode:modeEnum = attr(default=modeEnum.bind)
path:str = attr(default=None)
class DevicesChannelTarget(BaseXmlModel, search_mode='ordered'):
class typeEnum(str, Enum):
virtio = "virtio"
type:typeEnum = attr(default=typeEnum.virtio)
name:str = attr(default="org.qemu.guest_agent.0")
class DevicesChannel(BaseXmlModel):
class typeEnum(str, Enum):
unix = "unix"
type:typeEnum = attr(default=typeEnum.unix)
source:DevicesChannelSource = element(default=DevicesChannelSource())
target:DevicesChannelTarget = element(default=DevicesChannelTarget())
class Graphics(BaseXmlModel, search_mode='ordered'):
class typeEnum(str, Enum):
vnc = "vnc"
class keymapEnum(str, Enum):
ar = "ar"
bepo = "bepo"
cz = "cz"
da = "da"
de = "de"
de_ch = "de-ch"
en_gb = "en-gb"
en_us = "en-us"
es = "es"
et = "et"
fi = "fi"
fo = "fo"
fr = "fr"
fr_be = "fr-be"
fr_ca = "fr-ca"
fr_ch = "fr-ch"
hr = "hr"
hu = "hu"
it = "it"
lv = "lv"
mk = "mk"
nl = "nl"
no = "no"
pl = "pl"
pt = "pt"
pt_br = "pt-br"
ru = "ru"
sl = "sl"
sv = "sv"
th = "th"
tr = "tr"
type:typeEnum = attr(default=typeEnum.vnc)
port:int = attr(default=-1)
autoport:YesNoEnum = attr(default=YesNoEnum.YES)
websocket:int = attr(default=-1)
listen:str = attr(default="0.0.0.0")
password:Optional[str] = attr(default=None)
keymap:keymapEnum = attr(default=keymapEnum.en_us)
powerControl:YesNoEnum = attr(default=YesNoEnum.YES)
class Audio(BaseXmlModel, search_mode='ordered'):
pass
class VideoModel(BaseXmlModel, search_mode='ordered'):
class typeEnum(str, Enum):
vga = "vga"
cirrus = "cirrus"
virtio = "virtio"
type:typeEnum = attr()
vram:int = attr(default=16384)
primary:YesNoEnum = attr(default=YesNoEnum.YES)
class Video(BaseXmlModel, search_mode='ordered'):
model:VideoModel = element()
class Watchdog(BaseXmlModel, search_mode='ordered'):
class modelEnum(str, Enum):
itco = "itco"
class actionEnum(str, Enum):
reset = "reset"
shutdown = "shutdown"
poweroff = "poweroff"
pause = "pause"
none = "none"
dump = "dump"
inject_nmi = "inject-nmi"
model:modelEnum = attr(default=modelEnum.itco)
action:actionEnum = attr(default=actionEnum.reset)
class TPMBackendEncryption(BaseXmlModel):
secret:UUID4 = attr()
class TPMBackend(BaseXmlModel, search_mode='ordered'):
class typeEnum(str, Enum):
emulator = "emulator"
class versionEnum(str, Enum):
v12 = "1.2"
v20 = "2.0"
type:typeEnum = attr(default=typeEnum.emulator)
version:versionEnum = attr(default=versionEnum.v20)
encryption:Optional[TPMBackendEncryption] = element(default=None)
class TPM(BaseXmlModel, search_mode='ordered'):
class modelEnum(str, Enum):
tpm_tis = "tpm-tis"
tpm_crb = "tpm-crb"
model:modelEnum = attr(default=modelEnum.tpm_tis)
backend:TPMBackend = element(default=TPMBackend())
class Devices(BaseXmlModel, search_mode='ordered'):
emulator:str = element(default="/usr/libexec/qemu-kvm")
disk:Optional[List[DevicesDisk]] = element(default=[])
interface:Optional[List[DevicesInterface]] = element(default=[])
channel:Optional[DevicesChannel] = element(default=None)
graphics:Optional[Graphics] = element(default=None)
audio:Optional[Audio] = element(default=None)
video:Optional[Video] = element(default=None)
watchdog:Optional[Watchdog] = element(default=None)
tpm:Optional[TPM] = element(default=None)
class Dom(BaseXmlModel, tag='domain', search_mode='ordered'):
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"
# General metadata
uuid:Optional[UUID4] = element(default=None)
genid:Optional[UUID4] = element(default=None)
title:Optional[str] = element(default=None)
description:Optional[str] = element(default=None)
metadata:Optional[Metadata] = element(default=None)
# Memory Allocation
maxMemory:Optional[MaxMemory] = element(default=None)
memory:Memory = element()
currentMemory:Optional[CurrentMemory] = element(default=None)
memoryBacking:Optional[MemoryBacking] = element(default=None)
memtune:Optional[MemTune] = element(default=None)
numatune:Optional[NumaTune] = element(default=None)
# CPU Allocation
vcpu:VCPU = element()
vcpus:Optional[List[VCPUS]] = element(default=None)
cputune:Optional[CPUTune] = element(default=None)
# Resource patitioning
resource:Optional[Resource] = element(default=None)
# BIOS BootLoader
os:OS = element(default=OS())
# SMBIOS System Information
sysinfo:Sysinfo = element(default=Sysinfo())
# CPU model and topology
cpu:CPU = element(default=CPU())
# Power Management
pm:PM = element(default=None)
# Hypervisor features
features:Features = element(default=Features())
# Time keeping
clock:Clock = element(default=Clock())
# Events configuration
on_poweroff:on_poweroffEnum = element(default=on_poweroffEnum.destroy)
on_reboot:on_rebootEnum = element(default=on_rebootEnum.restart)
on_crash:on_crashEnum = element(default=on_crashEnum.restart)
on_failurelock:on_failurelockEnum = element(default=on_failurelockEnum.ignore)
# Performance monitoring events
perf:Perf = element(default=None)
# Devices
devices:Devices = element(default=Devices())