libvirtpy 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libvirtpy/__init__.py +5 -0
- libvirtpy/client/__init__.py +54 -0
- libvirtpy/client/_bases.py +326 -0
- libvirtpy/client/_runner.py +57 -0
- libvirtpy/client/aio.py +5922 -0
- libvirtpy/client/client.py +5695 -0
- libvirtpy/client/operations/__init__.py +631 -0
- libvirtpy/client/operations/_common.py +495 -0
- libvirtpy/client/operations/checkpoint.py +196 -0
- libvirtpy/client/operations/connection.py +93 -0
- libvirtpy/client/operations/connection_extra.py +256 -0
- libvirtpy/client/operations/domain.py +306 -0
- libvirtpy/client/operations/domain_agent.py +115 -0
- libvirtpy/client/operations/domain_block.py +368 -0
- libvirtpy/client/operations/domain_info.py +400 -0
- libvirtpy/client/operations/domain_lifecycle.py +338 -0
- libvirtpy/client/operations/domain_migration.py +164 -0
- libvirtpy/client/operations/domain_network.py +113 -0
- libvirtpy/client/operations/domain_tuning.py +494 -0
- libvirtpy/client/operations/host.py +246 -0
- libvirtpy/client/operations/host_interface.py +100 -0
- libvirtpy/client/operations/interface_extra.py +45 -0
- libvirtpy/client/operations/network.py +135 -0
- libvirtpy/client/operations/network_info.py +155 -0
- libvirtpy/client/operations/network_port.py +142 -0
- libvirtpy/client/operations/node_device.py +76 -0
- libvirtpy/client/operations/node_device_info.py +189 -0
- libvirtpy/client/operations/nwfilter.py +67 -0
- libvirtpy/client/operations/nwfilter_binding.py +74 -0
- libvirtpy/client/operations/secret.py +93 -0
- libvirtpy/client/operations/secret_extra.py +24 -0
- libvirtpy/client/operations/snapshot.py +100 -0
- libvirtpy/client/operations/snapshot_tree.py +114 -0
- libvirtpy/client/operations/storage.py +267 -0
- libvirtpy/client/operations/storage_info.py +188 -0
- libvirtpy/client/operations/streams.py +201 -0
- libvirtpy/client/references.py +249 -0
- libvirtpy/client/subscribing.py +88 -0
- libvirtpy/client/testing/__init__.py +24 -0
- libvirtpy/client/testing/_common.py +167 -0
- libvirtpy/client/testing/_domains.py +294 -0
- libvirtpy/client/testing/_objects.py +205 -0
- libvirtpy/client/testing/_state.py +246 -0
- libvirtpy/client/testing/_storage.py +171 -0
- libvirtpy/client/testing/async_transport.py +30 -0
- libvirtpy/client/testing/fake.py +81 -0
- libvirtpy/client/transport.py +87 -0
- libvirtpy/client/types.py +59 -0
- libvirtpy/client/wire.py +436 -0
- libvirtpy/client/wire_aio.py +348 -0
- libvirtpy/errors.py +7 -0
- libvirtpy/py.typed +0 -0
- libvirtpy/rpc/__init__.py +1 -0
- libvirtpy/rpc/aio.py +387 -0
- libvirtpy/rpc/cpumap.py +48 -0
- libvirtpy/rpc/errors.py +186 -0
- libvirtpy/rpc/events.py +259 -0
- libvirtpy/rpc/options.py +66 -0
- libvirtpy/rpc/procedure.py +27 -0
- libvirtpy/rpc/protocol/__init__.py +0 -0
- libvirtpy/rpc/protocol/procedures.py +5163 -0
- libvirtpy/rpc/protocol/typed_hints.py +210 -0
- libvirtpy/rpc/protocol/types.py +9299 -0
- libvirtpy/rpc/remote.py +295 -0
- libvirtpy/rpc/remote_aio.py +106 -0
- libvirtpy/rpc/sasl.py +467 -0
- libvirtpy/rpc/session.py +424 -0
- libvirtpy/rpc/sockets.py +251 -0
- libvirtpy/rpc/stream.py +323 -0
- libvirtpy/rpc/subscription.py +451 -0
- libvirtpy/rpc/sync.py +460 -0
- libvirtpy/rpc/typed_params.py +97 -0
- libvirtpy/rpc/uri.py +85 -0
- libvirtpy/rpc/xdr.py +552 -0
- libvirtpy/xml/__init__.py +49 -0
- libvirtpy/xml/_base.py +145 -0
- libvirtpy/xml/_shared/__init__.py +1 -0
- libvirtpy/xml/_shared/metadata.py +67 -0
- libvirtpy/xml/_shared/network.py +108 -0
- libvirtpy/xml/_shared/storage.py +131 -0
- libvirtpy/xml/_shared/sysinfo.py +83 -0
- libvirtpy/xml/_types.py +197 -0
- libvirtpy/xml/_xml_element.py +134 -0
- libvirtpy/xml/backup/__init__.py +25 -0
- libvirtpy/xml/backup/backup.py +89 -0
- libvirtpy/xml/backup/checkpoint.py +48 -0
- libvirtpy/xml/capabilities/__init__.py +43 -0
- libvirtpy/xml/capabilities/domain.py +436 -0
- libvirtpy/xml/capabilities/host.py +413 -0
- libvirtpy/xml/capabilities/storagepool.py +59 -0
- libvirtpy/xml/domain/__init__.py +493 -0
- libvirtpy/xml/domain/blkiotune.py +81 -0
- libvirtpy/xml/domain/clock.py +79 -0
- libvirtpy/xml/domain/cpu.py +265 -0
- libvirtpy/xml/domain/devices/__init__.py +495 -0
- libvirtpy/xml/domain/devices/address.py +152 -0
- libvirtpy/xml/domain/devices/audio.py +204 -0
- libvirtpy/xml/domain/devices/chardev.py +197 -0
- libvirtpy/xml/domain/devices/common.py +75 -0
- libvirtpy/xml/domain/devices/controller.py +262 -0
- libvirtpy/xml/domain/devices/devices.py +79 -0
- libvirtpy/xml/domain/devices/disk.py +471 -0
- libvirtpy/xml/domain/devices/filesystem.py +206 -0
- libvirtpy/xml/domain/devices/graphics.py +245 -0
- libvirtpy/xml/domain/devices/hostdev.py +221 -0
- libvirtpy/xml/domain/devices/input.py +89 -0
- libvirtpy/xml/domain/devices/interface.py +459 -0
- libvirtpy/xml/domain/devices/iommu.py +54 -0
- libvirtpy/xml/domain/devices/memballoon.py +42 -0
- libvirtpy/xml/domain/devices/memory_device.py +101 -0
- libvirtpy/xml/domain/devices/misc.py +169 -0
- libvirtpy/xml/domain/devices/nvram.py +20 -0
- libvirtpy/xml/domain/devices/shmem.py +46 -0
- libvirtpy/xml/domain/devices/sound.py +42 -0
- libvirtpy/xml/domain/devices/tpm.py +103 -0
- libvirtpy/xml/domain/devices/usb.py +86 -0
- libvirtpy/xml/domain/devices/video.py +101 -0
- libvirtpy/xml/domain/domain.py +157 -0
- libvirtpy/xml/domain/features.py +312 -0
- libvirtpy/xml/domain/iothread.py +41 -0
- libvirtpy/xml/domain/launch_security.py +82 -0
- libvirtpy/xml/domain/memory.py +149 -0
- libvirtpy/xml/domain/misc.py +113 -0
- libvirtpy/xml/domain/namespaces.py +96 -0
- libvirtpy/xml/domain/numa.py +140 -0
- libvirtpy/xml/domain/os.py +267 -0
- libvirtpy/xml/domain/qemu.py +102 -0
- libvirtpy/xml/domain/seclabel.py +29 -0
- libvirtpy/xml/domain/storage_source.py +466 -0
- libvirtpy/xml/domain/sysinfo.py +34 -0
- libvirtpy/xml/interface/__init__.py +17 -0
- libvirtpy/xml/interface/interface.py +153 -0
- libvirtpy/xml/network/__init__.py +101 -0
- libvirtpy/xml/network/network.py +311 -0
- libvirtpy/xml/network/port.py +84 -0
- libvirtpy/xml/nodedev/__init__.py +13 -0
- libvirtpy/xml/nodedev/nodedev.py +490 -0
- libvirtpy/xml/nwfilter/__init__.py +81 -0
- libvirtpy/xml/nwfilter/binding.py +51 -0
- libvirtpy/xml/nwfilter/filter.py +92 -0
- libvirtpy/xml/nwfilter/rules.py +534 -0
- libvirtpy/xml/secret/__init__.py +11 -0
- libvirtpy/xml/secret/secret.py +36 -0
- libvirtpy/xml/snapshot/__init__.py +29 -0
- libvirtpy/xml/snapshot/snapshot.py +136 -0
- libvirtpy/xml/storage/__init__.py +75 -0
- libvirtpy/xml/storage/pool.py +219 -0
- libvirtpy/xml/storage/volume.py +102 -0
- libvirtpy/xml/sysinfo.py +40 -0
- libvirtpy-0.1.0.dist-info/METADATA +109 -0
- libvirtpy-0.1.0.dist-info/RECORD +154 -0
- libvirtpy-0.1.0.dist-info/WHEEL +4 -0
- libvirtpy-0.1.0.dist-info/licenses/LICENSE +501 -0
- libvirtpy-0.1.0.dist-info/licenses/NOTICE +23 -0
libvirtpy/xml/_base.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Shared base model and XML serialization defaults."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, TypeVar, cast
|
|
4
|
+
|
|
5
|
+
from lxml import etree as lxml_etree
|
|
6
|
+
from pydantic import ConfigDict
|
|
7
|
+
from pydantic_xml import BaseXmlModel, errors
|
|
8
|
+
|
|
9
|
+
# pydantic-xml's backend alias: lxml at run time (a required dependency), but
|
|
10
|
+
# typed as the standard library's etree, which the overridden methods declare.
|
|
11
|
+
from pydantic_xml.element.native import etree
|
|
12
|
+
|
|
13
|
+
from libvirtpy.xml._xml_element import StableXmlElement
|
|
14
|
+
|
|
15
|
+
__all__ = ["LibvirtXmlModel"]
|
|
16
|
+
|
|
17
|
+
ModelT = TypeVar("ModelT", bound="LibvirtXmlModel")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class LibvirtXmlModel(BaseXmlModel, search_mode="unordered"):
|
|
21
|
+
"""Base class of every libvirtpy.xml model.
|
|
22
|
+
|
|
23
|
+
``search_mode="unordered"`` matters: libvirt does not guarantee child order,
|
|
24
|
+
and pydantic-xml's default ``strict`` mode silently drops elements that
|
|
25
|
+
appear out of declaration order.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
model_config = ConfigDict(extra="ignore", validate_assignment=True)
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def from_xml_tree(
|
|
32
|
+
cls: type[ModelT],
|
|
33
|
+
root: etree.Element,
|
|
34
|
+
# Same as pydantic-xml: a free-form validation context.
|
|
35
|
+
context: dict[str, Any] | None = None,
|
|
36
|
+
empty_as_string: bool = True,
|
|
37
|
+
) -> ModelT:
|
|
38
|
+
"""Parse an element tree, keeping sibling order and empty elements.
|
|
39
|
+
|
|
40
|
+
``empty_as_string`` keeps ``<bootloader/>`` or ``<cmdline></cmdline>``:
|
|
41
|
+
with pydantic-xml's default they read as ``None`` (absent) and are
|
|
42
|
+
lost on a round trip. Models with optional element text use
|
|
43
|
+
``OptionalText`` to turn ``""`` back into ``None``.
|
|
44
|
+
|
|
45
|
+
The tree is read through ``StableXmlElement``, which does not reorder
|
|
46
|
+
same-tag siblings (see ``libvirtpy.xml._xml_element``).
|
|
47
|
+
|
|
48
|
+
:param root: the element to read; its tag must be this model's tag.
|
|
49
|
+
:param context: validation context passed to the field validators.
|
|
50
|
+
:param empty_as_string: read an empty element as ``""`` instead of ``None``.
|
|
51
|
+
:returns: the parsed model.
|
|
52
|
+
:raises pydantic_xml.errors.ParsingError: if ``root`` is not the
|
|
53
|
+
element of this model.
|
|
54
|
+
:raises pydantic.ValidationError: if the content does not fit the model.
|
|
55
|
+
"""
|
|
56
|
+
serializer = cls.__xml_serializer__
|
|
57
|
+
assert serializer is not None, f"model {cls.__name__} is partially initialized"
|
|
58
|
+
|
|
59
|
+
if root.tag != serializer.element_name:
|
|
60
|
+
raise errors.ParsingError(
|
|
61
|
+
f"root element not found (actual: {root.tag}, "
|
|
62
|
+
f"expected: {serializer.element_name})"
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
parsed = serializer.deserialize(
|
|
66
|
+
# At run time root is an lxml element (lxml is a required dependency);
|
|
67
|
+
# pydantic-xml annotates it with the standard library's type.
|
|
68
|
+
StableXmlElement.from_native(cast(lxml_etree._Element, root)),
|
|
69
|
+
context=context,
|
|
70
|
+
sourcemap={},
|
|
71
|
+
loc=(),
|
|
72
|
+
empty_as_string=empty_as_string,
|
|
73
|
+
)
|
|
74
|
+
return cast(ModelT, parsed)
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def from_xml(
|
|
78
|
+
cls: type[ModelT],
|
|
79
|
+
source: str | bytes,
|
|
80
|
+
# Same as pydantic-xml: a free-form validation context.
|
|
81
|
+
context: dict[str, Any] | None = None,
|
|
82
|
+
empty_as_string: bool = True,
|
|
83
|
+
# Forwarded unchanged to etree.fromstring, whose options are untyped.
|
|
84
|
+
**kwargs: Any,
|
|
85
|
+
) -> ModelT:
|
|
86
|
+
"""Parse XML, reading empty elements as ``""`` (see ``from_xml_tree``).
|
|
87
|
+
|
|
88
|
+
:param source: the XML document.
|
|
89
|
+
:param context: validation context passed to the field validators.
|
|
90
|
+
:param empty_as_string: read an empty element as ``""`` instead of ``None``.
|
|
91
|
+
:param kwargs: passed to :func:`lxml.etree.fromstring`.
|
|
92
|
+
:returns: the parsed model.
|
|
93
|
+
:raises pydantic.ValidationError: if the content does not fit the model.
|
|
94
|
+
"""
|
|
95
|
+
return super().from_xml(
|
|
96
|
+
source, context=context, empty_as_string=empty_as_string, **kwargs
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
def to_xml_tree(
|
|
100
|
+
self,
|
|
101
|
+
*,
|
|
102
|
+
skip_empty: bool = False,
|
|
103
|
+
exclude_none: bool = True,
|
|
104
|
+
exclude_unset: bool = False,
|
|
105
|
+
) -> etree.Element:
|
|
106
|
+
"""Serialize to an lxml element, leaving out fields that are ``None``.
|
|
107
|
+
|
|
108
|
+
``exclude_none`` is used instead of ``skip_empty``: ``skip_empty`` also
|
|
109
|
+
drops empty elements such as ``<acpi/>`` and empty attribute values.
|
|
110
|
+
|
|
111
|
+
:param skip_empty: drop empty elements and attributes; leave it off.
|
|
112
|
+
:param exclude_none: leave out fields that are ``None``.
|
|
113
|
+
:param exclude_unset: leave out fields that were never set.
|
|
114
|
+
:returns: the root element.
|
|
115
|
+
"""
|
|
116
|
+
return super().to_xml_tree(
|
|
117
|
+
skip_empty=skip_empty,
|
|
118
|
+
exclude_none=exclude_none,
|
|
119
|
+
exclude_unset=exclude_unset,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
def to_xml(
|
|
123
|
+
self,
|
|
124
|
+
*,
|
|
125
|
+
skip_empty: bool = False,
|
|
126
|
+
exclude_none: bool = True,
|
|
127
|
+
exclude_unset: bool = False,
|
|
128
|
+
# Forwarded unchanged to etree.tostring, whose options are untyped.
|
|
129
|
+
**kwargs: Any,
|
|
130
|
+
) -> str | bytes:
|
|
131
|
+
"""Serialize to XML, leaving out fields that are ``None``.
|
|
132
|
+
|
|
133
|
+
:param skip_empty: drop empty elements and attributes; leave it off.
|
|
134
|
+
:param exclude_none: leave out fields that are ``None``.
|
|
135
|
+
:param exclude_unset: leave out fields that were never set.
|
|
136
|
+
:param kwargs: passed to :func:`lxml.etree.tostring`, for example
|
|
137
|
+
``encoding="unicode"`` to get a ``str``.
|
|
138
|
+
:returns: the XML, as ``bytes`` unless ``encoding="unicode"`` is given.
|
|
139
|
+
"""
|
|
140
|
+
return super().to_xml(
|
|
141
|
+
skip_empty=skip_empty,
|
|
142
|
+
exclude_none=exclude_none,
|
|
143
|
+
exclude_unset=exclude_unset,
|
|
144
|
+
**kwargs,
|
|
145
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Models shared by more than one document type. Private; packages re-export them."""
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""``<metadata>``: arbitrary XML that applications attach to a domain.
|
|
2
|
+
|
|
3
|
+
libvirt stores it without interpreting it, and it can contain any elements
|
|
4
|
+
from any namespace. It is therefore kept as text, one string per child
|
|
5
|
+
element, and parsed back when written. Whitespace and comments between the
|
|
6
|
+
children are not kept.
|
|
7
|
+
|
|
8
|
+
Used by ``<domain>``, ``<network>`` and the other documents that allow it.
|
|
9
|
+
|
|
10
|
+
See https://libvirt.org/formatdomain.html#general-metadata
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from lxml import etree
|
|
14
|
+
from pydantic_xml import element, xml_field_serializer, xml_field_validator
|
|
15
|
+
from pydantic_xml.element.element import XmlElementReader, XmlElementWriter
|
|
16
|
+
|
|
17
|
+
from libvirtpy.xml._base import LibvirtXmlModel
|
|
18
|
+
from libvirtpy.xml._xml_element import StableXmlElement
|
|
19
|
+
|
|
20
|
+
__all__ = ["Metadata", "RawChildren"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class RawChildren(LibvirtXmlModel):
|
|
24
|
+
"""Base of the elements whose children are arbitrary XML, kept as strings."""
|
|
25
|
+
|
|
26
|
+
# The tag is a placeholder: pydantic-xml needs a mapping to build the class,
|
|
27
|
+
# but the hooks below read and write the field themselves.
|
|
28
|
+
elements: list[str] = element(
|
|
29
|
+
tag="metadata-element",
|
|
30
|
+
default_factory=list,
|
|
31
|
+
description="One XML document fragment per child element, in order.",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
@xml_field_validator("elements")
|
|
35
|
+
@classmethod
|
|
36
|
+
def _read_elements(cls, element: XmlElementReader, field_name: str) -> list[str]:
|
|
37
|
+
"""Read every child of the element as an XML string.
|
|
38
|
+
|
|
39
|
+
:param element: the element being parsed.
|
|
40
|
+
:param field_name: the field this reader fills (``elements``).
|
|
41
|
+
:returns: one string per child, in document order.
|
|
42
|
+
"""
|
|
43
|
+
children = element.pop_elements()
|
|
44
|
+
return [
|
|
45
|
+
etree.tostring(child.to_native(), encoding="unicode", with_tail=False)
|
|
46
|
+
for child in children
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
@xml_field_serializer("elements")
|
|
50
|
+
def _write_elements(
|
|
51
|
+
self, element: XmlElementWriter, value: list[str], field_name: str
|
|
52
|
+
) -> XmlElementWriter:
|
|
53
|
+
"""Write each string back as a child element.
|
|
54
|
+
|
|
55
|
+
:param element: the element being written.
|
|
56
|
+
:param value: the XML strings to write, in order.
|
|
57
|
+
:param field_name: the field this writer serializes (``elements``).
|
|
58
|
+
:returns: ``element``, with the children appended.
|
|
59
|
+
"""
|
|
60
|
+
for text in value:
|
|
61
|
+
parsed = etree.fromstring(text)
|
|
62
|
+
element.append_element(StableXmlElement.from_native(parsed))
|
|
63
|
+
return element
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class Metadata(RawChildren, tag="metadata"):
|
|
67
|
+
"""``<metadata>``: the application elements, each as an XML string."""
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Network settings shared by ``<interface>`` and ``<network>``.
|
|
2
|
+
|
|
3
|
+
``domain`` and ``network`` must not import each other, so the structures that
|
|
4
|
+
both use live here and each package re-exports them.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Literal
|
|
8
|
+
|
|
9
|
+
from pydantic_xml import attr, element
|
|
10
|
+
|
|
11
|
+
from libvirtpy.xml._base import LibvirtXmlModel
|
|
12
|
+
from libvirtpy.xml._types import Uuid
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Bandwidth",
|
|
16
|
+
"BandwidthLimit",
|
|
17
|
+
"FilterParameter",
|
|
18
|
+
"FilterRef",
|
|
19
|
+
"Inbound",
|
|
20
|
+
"Outbound",
|
|
21
|
+
"Route",
|
|
22
|
+
"VirtualPort",
|
|
23
|
+
"VirtualPortParameters",
|
|
24
|
+
"Vlan",
|
|
25
|
+
"VlanTag",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class VirtualPortParameters(LibvirtXmlModel, tag="parameters"):
|
|
30
|
+
"""``<parameters>`` of a virtual port; which are valid depends on its type."""
|
|
31
|
+
|
|
32
|
+
managerid: int | None = attr(name="managerid", default=None, ge=0)
|
|
33
|
+
typeid: int | None = attr(name="typeid", default=None, ge=0)
|
|
34
|
+
typeidversion: int | None = attr(name="typeidversion", default=None, ge=0)
|
|
35
|
+
instanceid: Uuid | None = attr(name="instanceid", default=None)
|
|
36
|
+
profileid: str | None = attr(name="profileid", default=None)
|
|
37
|
+
interfaceid: Uuid | None = attr(name="interfaceid", default=None)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class VirtualPort(LibvirtXmlModel, tag="virtualport"):
|
|
41
|
+
"""``<virtualport>``: 802.1Qbg, 802.1Qbh, Open vSwitch or MidoNet settings."""
|
|
42
|
+
|
|
43
|
+
type: Literal["802.1Qbg", "802.1Qbh", "openvswitch", "midonet"] | None = attr(
|
|
44
|
+
name="type", default=None
|
|
45
|
+
)
|
|
46
|
+
parameters: VirtualPortParameters | None = element(tag="parameters", default=None)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class BandwidthLimit(LibvirtXmlModel):
|
|
50
|
+
"""Base of ``<inbound>`` and ``<outbound>``; rates in KiB/s, burst in KiB."""
|
|
51
|
+
|
|
52
|
+
average: int | None = attr(name="average", default=None, ge=0)
|
|
53
|
+
peak: int | None = attr(name="peak", default=None, ge=0)
|
|
54
|
+
floor: int | None = attr(name="floor", default=None, ge=0)
|
|
55
|
+
burst: int | None = attr(name="burst", default=None, ge=0)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Inbound(BandwidthLimit, tag="inbound"):
|
|
59
|
+
"""``<inbound>``: limits of incoming traffic."""
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Outbound(BandwidthLimit, tag="outbound"):
|
|
63
|
+
"""``<outbound>``: limits of outgoing traffic."""
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class Bandwidth(LibvirtXmlModel, tag="bandwidth"):
|
|
67
|
+
"""``<bandwidth>``: traffic shaping."""
|
|
68
|
+
|
|
69
|
+
class_id: int | None = attr(name="classID", default=None, ge=1)
|
|
70
|
+
inbound: Inbound | None = element(tag="inbound", default=None)
|
|
71
|
+
outbound: Outbound | None = element(tag="outbound", default=None)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class VlanTag(LibvirtXmlModel, tag="tag"):
|
|
75
|
+
id: int = attr(name="id", ge=0)
|
|
76
|
+
native_mode: Literal["tagged", "untagged"] | None = attr(
|
|
77
|
+
name="nativeMode", default=None
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class Vlan(LibvirtXmlModel, tag="vlan"):
|
|
82
|
+
"""``<vlan>``: VLAN tags."""
|
|
83
|
+
|
|
84
|
+
trunk: Literal["yes"] | None = attr(name="trunk", default=None)
|
|
85
|
+
tags: list[VlanTag] = element(tag="tag", default_factory=list)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class Route(LibvirtXmlModel, tag="route"):
|
|
89
|
+
"""``<route>``: a route (of a guest interface or of a network)."""
|
|
90
|
+
|
|
91
|
+
family: str | None = attr(name="family", default=None)
|
|
92
|
+
address: str | None = attr(name="address", default=None)
|
|
93
|
+
netmask: str | None = attr(name="netmask", default=None)
|
|
94
|
+
prefix: int | None = attr(name="prefix", default=None, ge=0)
|
|
95
|
+
gateway: str = attr(name="gateway")
|
|
96
|
+
metric: int | None = attr(name="metric", default=None, ge=0)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class FilterParameter(LibvirtXmlModel, tag="parameter"):
|
|
100
|
+
name: str = attr(name="name")
|
|
101
|
+
value: str = attr(name="value")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class FilterRef(LibvirtXmlModel, tag="filterref"):
|
|
105
|
+
"""``<filterref>``: a network filter and its parameters."""
|
|
106
|
+
|
|
107
|
+
filter: str = attr(name="filter")
|
|
108
|
+
parameters: list[FilterParameter] = element(tag="parameter", default_factory=list)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""Storage structures shared by ``<disk>`` sources, storage pools and volumes.
|
|
2
|
+
|
|
3
|
+
``domain`` and ``storage`` must not import each other, so the structures that
|
|
4
|
+
both use live here and each package re-exports them.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Literal
|
|
8
|
+
|
|
9
|
+
from pydantic_xml import attr, element
|
|
10
|
+
|
|
11
|
+
from libvirtpy.xml._base import LibvirtXmlModel
|
|
12
|
+
from libvirtpy.xml._types import HexNumber, OnOff, ScaledInteger, Uuid, YesNo
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Allocation",
|
|
16
|
+
"Capacity",
|
|
17
|
+
"DeviceSeclabel",
|
|
18
|
+
"HostPciAddress",
|
|
19
|
+
"Permissions",
|
|
20
|
+
"ScsiAdapter",
|
|
21
|
+
"ScsiParentAddress",
|
|
22
|
+
"StorageCipher",
|
|
23
|
+
"StorageEncryption",
|
|
24
|
+
"StorageIvgen",
|
|
25
|
+
"StorageSecret",
|
|
26
|
+
"Timestamps",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Capacity(ScaledInteger, tag="capacity"):
|
|
31
|
+
"""``<capacity>``: the logical size."""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Allocation(ScaledInteger, tag="allocation"):
|
|
35
|
+
"""``<allocation>``: the space actually used on the host."""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class StorageSecret(LibvirtXmlModel, tag="secret"):
|
|
39
|
+
"""``<secret>``: a libvirt secret, referenced by ``uuid`` or by ``usage``."""
|
|
40
|
+
|
|
41
|
+
type: Literal["passphrase", "ceph", "iscsi"] = attr(name="type")
|
|
42
|
+
uuid: Uuid | None = attr(name="uuid", default=None)
|
|
43
|
+
usage: str | None = attr(name="usage", default=None)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class StorageCipher(LibvirtXmlModel, tag="cipher"):
|
|
47
|
+
name: str = attr(name="name")
|
|
48
|
+
size: int = attr(name="size", ge=0)
|
|
49
|
+
mode: str | None = attr(name="mode", default=None)
|
|
50
|
+
hash: str | None = attr(name="hash", default=None)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class StorageIvgen(LibvirtXmlModel, tag="ivgen"):
|
|
54
|
+
name: str = attr(name="name")
|
|
55
|
+
hash: str | None = attr(name="hash", default=None)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class StorageEncryption(LibvirtXmlModel, tag="encryption"):
|
|
59
|
+
"""``<encryption>``: how the volume is encrypted and where the key is."""
|
|
60
|
+
|
|
61
|
+
format: Literal["default", "qcow", "luks", "luks2", "luks-any"] = attr(
|
|
62
|
+
name="format"
|
|
63
|
+
)
|
|
64
|
+
engine: Literal["qemu", "librbd"] | None = attr(name="engine", default=None)
|
|
65
|
+
secrets: list[StorageSecret] = element(tag="secret", default_factory=list)
|
|
66
|
+
cipher: StorageCipher | None = element(tag="cipher", default=None)
|
|
67
|
+
ivgen: StorageIvgen | None = element(tag="ivgen", default=None)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class HostPciAddress(LibvirtXmlModel, tag="address"):
|
|
71
|
+
"""``<address>`` of a host PCI device (no ``type`` attribute)."""
|
|
72
|
+
|
|
73
|
+
domain: HexNumber | None = attr(name="domain", default=None)
|
|
74
|
+
bus: HexNumber | None = attr(name="bus", default=None)
|
|
75
|
+
slot: HexNumber | None = attr(name="slot", default=None)
|
|
76
|
+
function: HexNumber | None = attr(name="function", default=None)
|
|
77
|
+
multifunction: OnOff | None = attr(name="multifunction", default=None)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class ScsiParentAddress(LibvirtXmlModel, tag="parentaddr"):
|
|
81
|
+
unique_id: int | None = attr(name="unique_id", default=None, ge=1)
|
|
82
|
+
address: HostPciAddress | None = element(tag="address", default=None)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class ScsiAdapter(LibvirtXmlModel, tag="adapter"):
|
|
86
|
+
"""``<adapter>``: a SCSI host (``scsi_host``) or Fibre Channel host."""
|
|
87
|
+
|
|
88
|
+
type: Literal["scsi_host", "fc_host"] | None = attr(name="type", default=None)
|
|
89
|
+
name: str | None = attr(name="name", default=None)
|
|
90
|
+
parent: str | None = attr(name="parent", default=None)
|
|
91
|
+
managed: YesNo | None = attr(name="managed", default=None)
|
|
92
|
+
parent_wwnn: str | None = attr(name="parent_wwnn", default=None)
|
|
93
|
+
parent_wwpn: str | None = attr(name="parent_wwpn", default=None)
|
|
94
|
+
parent_fabric_wwn: str | None = attr(name="parent_fabric_wwn", default=None)
|
|
95
|
+
wwnn: str | None = attr(name="wwnn", default=None)
|
|
96
|
+
wwpn: str | None = attr(name="wwpn", default=None)
|
|
97
|
+
parentaddr: ScsiParentAddress | None = element(tag="parentaddr", default=None)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class Permissions(LibvirtXmlModel, tag="permissions"):
|
|
101
|
+
"""``<permissions>``: mode and ownership of a volume or a pool's target."""
|
|
102
|
+
|
|
103
|
+
mode: str | None = element(tag="mode", default=None, description="Octal.")
|
|
104
|
+
owner: str | None = element(
|
|
105
|
+
tag="owner",
|
|
106
|
+
default=None,
|
|
107
|
+
pattern=r"^(-1|[0-9]+)$",
|
|
108
|
+
description="User ID or ``-1``; kept as written (``0744`` stays ``0744``).",
|
|
109
|
+
)
|
|
110
|
+
group: str | None = element(
|
|
111
|
+
tag="group", default=None, pattern=r"^(-1|[0-9]+)$", description="Group ID."
|
|
112
|
+
)
|
|
113
|
+
label: str | None = element(tag="label", default=None)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class Timestamps(LibvirtXmlModel, tag="timestamps"):
|
|
117
|
+
"""``<timestamps>``: access, birth, change and modification times."""
|
|
118
|
+
|
|
119
|
+
atime: str | None = element(tag="atime", default=None)
|
|
120
|
+
btime: str | None = element(tag="btime", default=None)
|
|
121
|
+
ctime: str | None = element(tag="ctime", default=None)
|
|
122
|
+
mtime: str | None = element(tag="mtime", default=None)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class DeviceSeclabel(LibvirtXmlModel, tag="seclabel"):
|
|
126
|
+
"""``<seclabel>`` of a device source: per-image security labelling."""
|
|
127
|
+
|
|
128
|
+
model: str | None = attr(name="model", default=None)
|
|
129
|
+
relabel: YesNo | None = attr(name="relabel", default=None)
|
|
130
|
+
labelskip: YesNo | None = attr(name="labelskip", default=None)
|
|
131
|
+
labels: list[str] = element(tag="label", default_factory=list)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""The ``<sysinfo>`` building blocks shared by a domain and the host document.
|
|
2
|
+
|
|
3
|
+
See https://libvirt.org/formatdomain.html#smbios-system-information
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from pydantic import Field
|
|
7
|
+
from pydantic_xml import attr, element
|
|
8
|
+
|
|
9
|
+
from libvirtpy.xml._base import LibvirtXmlModel
|
|
10
|
+
from libvirtpy.xml._types import OptionalText
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"FwcfgEntry",
|
|
14
|
+
"OemStringEntry",
|
|
15
|
+
"SmbiosEntry",
|
|
16
|
+
"SysinfoBaseBoard",
|
|
17
|
+
"SysinfoBios",
|
|
18
|
+
"SysinfoChassis",
|
|
19
|
+
"SysinfoGroup",
|
|
20
|
+
"SysinfoMemoryDevice",
|
|
21
|
+
"SysinfoOemStrings",
|
|
22
|
+
"SysinfoProcessor",
|
|
23
|
+
"SysinfoSystem",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class SmbiosEntry(LibvirtXmlModel, tag="entry"):
|
|
28
|
+
"""``<entry>`` of an SMBIOS group: one named field."""
|
|
29
|
+
|
|
30
|
+
value: str = Field(default="", description="Element text: the value.")
|
|
31
|
+
name: str = attr(name="name")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class OemStringEntry(LibvirtXmlModel, tag="entry"):
|
|
35
|
+
"""``<entry>`` of ``<oemStrings>``: one string, without a name."""
|
|
36
|
+
|
|
37
|
+
value: str = Field(default="", description="Element text: the string.")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class FwcfgEntry(LibvirtXmlModel, tag="entry"):
|
|
41
|
+
"""``<entry>`` of a ``fwcfg`` sysinfo: a named item from text or a file."""
|
|
42
|
+
|
|
43
|
+
value: OptionalText = Field(
|
|
44
|
+
default=None, description="Element text: the value (absent with ``file``)."
|
|
45
|
+
)
|
|
46
|
+
name: str = attr(name="name")
|
|
47
|
+
file: str | None = attr(name="file", default=None)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class SysinfoGroup(LibvirtXmlModel):
|
|
51
|
+
"""Base of the SMBIOS groups: a list of named ``<entry>`` elements."""
|
|
52
|
+
|
|
53
|
+
entries: list[SmbiosEntry] = element(tag="entry", default_factory=list)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class SysinfoBios(SysinfoGroup, tag="bios"):
|
|
57
|
+
"""``<bios>``: SMBIOS type 0."""
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class SysinfoSystem(SysinfoGroup, tag="system"):
|
|
61
|
+
"""``<system>``: SMBIOS type 1."""
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class SysinfoBaseBoard(SysinfoGroup, tag="baseBoard"):
|
|
65
|
+
"""``<baseBoard>``: SMBIOS type 2."""
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class SysinfoChassis(SysinfoGroup, tag="chassis"):
|
|
69
|
+
"""``<chassis>``: SMBIOS type 3."""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class SysinfoOemStrings(LibvirtXmlModel, tag="oemStrings"):
|
|
73
|
+
"""``<oemStrings>``: SMBIOS type 11."""
|
|
74
|
+
|
|
75
|
+
entries: list[OemStringEntry] = element(tag="entry", default_factory=list)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class SysinfoProcessor(SysinfoGroup, tag="processor"):
|
|
79
|
+
"""``<processor>``: SMBIOS type 4. Host document only."""
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class SysinfoMemoryDevice(SysinfoGroup, tag="memory_device"):
|
|
83
|
+
"""``<memory_device>``: SMBIOS type 17. Host document only."""
|