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.
Files changed (154) hide show
  1. libvirtpy/__init__.py +5 -0
  2. libvirtpy/client/__init__.py +54 -0
  3. libvirtpy/client/_bases.py +326 -0
  4. libvirtpy/client/_runner.py +57 -0
  5. libvirtpy/client/aio.py +5922 -0
  6. libvirtpy/client/client.py +5695 -0
  7. libvirtpy/client/operations/__init__.py +631 -0
  8. libvirtpy/client/operations/_common.py +495 -0
  9. libvirtpy/client/operations/checkpoint.py +196 -0
  10. libvirtpy/client/operations/connection.py +93 -0
  11. libvirtpy/client/operations/connection_extra.py +256 -0
  12. libvirtpy/client/operations/domain.py +306 -0
  13. libvirtpy/client/operations/domain_agent.py +115 -0
  14. libvirtpy/client/operations/domain_block.py +368 -0
  15. libvirtpy/client/operations/domain_info.py +400 -0
  16. libvirtpy/client/operations/domain_lifecycle.py +338 -0
  17. libvirtpy/client/operations/domain_migration.py +164 -0
  18. libvirtpy/client/operations/domain_network.py +113 -0
  19. libvirtpy/client/operations/domain_tuning.py +494 -0
  20. libvirtpy/client/operations/host.py +246 -0
  21. libvirtpy/client/operations/host_interface.py +100 -0
  22. libvirtpy/client/operations/interface_extra.py +45 -0
  23. libvirtpy/client/operations/network.py +135 -0
  24. libvirtpy/client/operations/network_info.py +155 -0
  25. libvirtpy/client/operations/network_port.py +142 -0
  26. libvirtpy/client/operations/node_device.py +76 -0
  27. libvirtpy/client/operations/node_device_info.py +189 -0
  28. libvirtpy/client/operations/nwfilter.py +67 -0
  29. libvirtpy/client/operations/nwfilter_binding.py +74 -0
  30. libvirtpy/client/operations/secret.py +93 -0
  31. libvirtpy/client/operations/secret_extra.py +24 -0
  32. libvirtpy/client/operations/snapshot.py +100 -0
  33. libvirtpy/client/operations/snapshot_tree.py +114 -0
  34. libvirtpy/client/operations/storage.py +267 -0
  35. libvirtpy/client/operations/storage_info.py +188 -0
  36. libvirtpy/client/operations/streams.py +201 -0
  37. libvirtpy/client/references.py +249 -0
  38. libvirtpy/client/subscribing.py +88 -0
  39. libvirtpy/client/testing/__init__.py +24 -0
  40. libvirtpy/client/testing/_common.py +167 -0
  41. libvirtpy/client/testing/_domains.py +294 -0
  42. libvirtpy/client/testing/_objects.py +205 -0
  43. libvirtpy/client/testing/_state.py +246 -0
  44. libvirtpy/client/testing/_storage.py +171 -0
  45. libvirtpy/client/testing/async_transport.py +30 -0
  46. libvirtpy/client/testing/fake.py +81 -0
  47. libvirtpy/client/transport.py +87 -0
  48. libvirtpy/client/types.py +59 -0
  49. libvirtpy/client/wire.py +436 -0
  50. libvirtpy/client/wire_aio.py +348 -0
  51. libvirtpy/errors.py +7 -0
  52. libvirtpy/py.typed +0 -0
  53. libvirtpy/rpc/__init__.py +1 -0
  54. libvirtpy/rpc/aio.py +387 -0
  55. libvirtpy/rpc/cpumap.py +48 -0
  56. libvirtpy/rpc/errors.py +186 -0
  57. libvirtpy/rpc/events.py +259 -0
  58. libvirtpy/rpc/options.py +66 -0
  59. libvirtpy/rpc/procedure.py +27 -0
  60. libvirtpy/rpc/protocol/__init__.py +0 -0
  61. libvirtpy/rpc/protocol/procedures.py +5163 -0
  62. libvirtpy/rpc/protocol/typed_hints.py +210 -0
  63. libvirtpy/rpc/protocol/types.py +9299 -0
  64. libvirtpy/rpc/remote.py +295 -0
  65. libvirtpy/rpc/remote_aio.py +106 -0
  66. libvirtpy/rpc/sasl.py +467 -0
  67. libvirtpy/rpc/session.py +424 -0
  68. libvirtpy/rpc/sockets.py +251 -0
  69. libvirtpy/rpc/stream.py +323 -0
  70. libvirtpy/rpc/subscription.py +451 -0
  71. libvirtpy/rpc/sync.py +460 -0
  72. libvirtpy/rpc/typed_params.py +97 -0
  73. libvirtpy/rpc/uri.py +85 -0
  74. libvirtpy/rpc/xdr.py +552 -0
  75. libvirtpy/xml/__init__.py +49 -0
  76. libvirtpy/xml/_base.py +145 -0
  77. libvirtpy/xml/_shared/__init__.py +1 -0
  78. libvirtpy/xml/_shared/metadata.py +67 -0
  79. libvirtpy/xml/_shared/network.py +108 -0
  80. libvirtpy/xml/_shared/storage.py +131 -0
  81. libvirtpy/xml/_shared/sysinfo.py +83 -0
  82. libvirtpy/xml/_types.py +197 -0
  83. libvirtpy/xml/_xml_element.py +134 -0
  84. libvirtpy/xml/backup/__init__.py +25 -0
  85. libvirtpy/xml/backup/backup.py +89 -0
  86. libvirtpy/xml/backup/checkpoint.py +48 -0
  87. libvirtpy/xml/capabilities/__init__.py +43 -0
  88. libvirtpy/xml/capabilities/domain.py +436 -0
  89. libvirtpy/xml/capabilities/host.py +413 -0
  90. libvirtpy/xml/capabilities/storagepool.py +59 -0
  91. libvirtpy/xml/domain/__init__.py +493 -0
  92. libvirtpy/xml/domain/blkiotune.py +81 -0
  93. libvirtpy/xml/domain/clock.py +79 -0
  94. libvirtpy/xml/domain/cpu.py +265 -0
  95. libvirtpy/xml/domain/devices/__init__.py +495 -0
  96. libvirtpy/xml/domain/devices/address.py +152 -0
  97. libvirtpy/xml/domain/devices/audio.py +204 -0
  98. libvirtpy/xml/domain/devices/chardev.py +197 -0
  99. libvirtpy/xml/domain/devices/common.py +75 -0
  100. libvirtpy/xml/domain/devices/controller.py +262 -0
  101. libvirtpy/xml/domain/devices/devices.py +79 -0
  102. libvirtpy/xml/domain/devices/disk.py +471 -0
  103. libvirtpy/xml/domain/devices/filesystem.py +206 -0
  104. libvirtpy/xml/domain/devices/graphics.py +245 -0
  105. libvirtpy/xml/domain/devices/hostdev.py +221 -0
  106. libvirtpy/xml/domain/devices/input.py +89 -0
  107. libvirtpy/xml/domain/devices/interface.py +459 -0
  108. libvirtpy/xml/domain/devices/iommu.py +54 -0
  109. libvirtpy/xml/domain/devices/memballoon.py +42 -0
  110. libvirtpy/xml/domain/devices/memory_device.py +101 -0
  111. libvirtpy/xml/domain/devices/misc.py +169 -0
  112. libvirtpy/xml/domain/devices/nvram.py +20 -0
  113. libvirtpy/xml/domain/devices/shmem.py +46 -0
  114. libvirtpy/xml/domain/devices/sound.py +42 -0
  115. libvirtpy/xml/domain/devices/tpm.py +103 -0
  116. libvirtpy/xml/domain/devices/usb.py +86 -0
  117. libvirtpy/xml/domain/devices/video.py +101 -0
  118. libvirtpy/xml/domain/domain.py +157 -0
  119. libvirtpy/xml/domain/features.py +312 -0
  120. libvirtpy/xml/domain/iothread.py +41 -0
  121. libvirtpy/xml/domain/launch_security.py +82 -0
  122. libvirtpy/xml/domain/memory.py +149 -0
  123. libvirtpy/xml/domain/misc.py +113 -0
  124. libvirtpy/xml/domain/namespaces.py +96 -0
  125. libvirtpy/xml/domain/numa.py +140 -0
  126. libvirtpy/xml/domain/os.py +267 -0
  127. libvirtpy/xml/domain/qemu.py +102 -0
  128. libvirtpy/xml/domain/seclabel.py +29 -0
  129. libvirtpy/xml/domain/storage_source.py +466 -0
  130. libvirtpy/xml/domain/sysinfo.py +34 -0
  131. libvirtpy/xml/interface/__init__.py +17 -0
  132. libvirtpy/xml/interface/interface.py +153 -0
  133. libvirtpy/xml/network/__init__.py +101 -0
  134. libvirtpy/xml/network/network.py +311 -0
  135. libvirtpy/xml/network/port.py +84 -0
  136. libvirtpy/xml/nodedev/__init__.py +13 -0
  137. libvirtpy/xml/nodedev/nodedev.py +490 -0
  138. libvirtpy/xml/nwfilter/__init__.py +81 -0
  139. libvirtpy/xml/nwfilter/binding.py +51 -0
  140. libvirtpy/xml/nwfilter/filter.py +92 -0
  141. libvirtpy/xml/nwfilter/rules.py +534 -0
  142. libvirtpy/xml/secret/__init__.py +11 -0
  143. libvirtpy/xml/secret/secret.py +36 -0
  144. libvirtpy/xml/snapshot/__init__.py +29 -0
  145. libvirtpy/xml/snapshot/snapshot.py +136 -0
  146. libvirtpy/xml/storage/__init__.py +75 -0
  147. libvirtpy/xml/storage/pool.py +219 -0
  148. libvirtpy/xml/storage/volume.py +102 -0
  149. libvirtpy/xml/sysinfo.py +40 -0
  150. libvirtpy-0.1.0.dist-info/METADATA +109 -0
  151. libvirtpy-0.1.0.dist-info/RECORD +154 -0
  152. libvirtpy-0.1.0.dist-info/WHEEL +4 -0
  153. libvirtpy-0.1.0.dist-info/licenses/LICENSE +501 -0
  154. libvirtpy-0.1.0.dist-info/licenses/NOTICE +23 -0
@@ -0,0 +1,466 @@
1
+ """Storage sources: what a ``<disk>``, ``<backingStore>`` or ``<nvram>`` reads.
2
+
3
+ The ``<source>`` element has a different shape per ``type`` of its *parent*
4
+ (``<disk type='file'>`` has ``<source file=...>``, ``type='block'`` has
5
+ ``<source dev=...>``). The ``<source>`` itself carries no discriminator, so
6
+ parents cannot use a union of sources directly. Instead each kind of storage
7
+ is a small mixin (``FileStorage``, ``BlockStorage``, ...) that adds the parent's
8
+ ``type`` literal and the matching ``source``. A parent builds one class per
9
+ mixin and a plain union of them (see ``libvirtpy.xml.domain.devices.disk``).
10
+
11
+ All network protocols share one ``NetworkSource`` model: they differ by which
12
+ optional children they allow, which is a constraint libvirt checks, not a
13
+ different structure.
14
+
15
+ See https://libvirt.org/formatdomain.html#hard-drives-floppy-disks-cdroms
16
+ """
17
+
18
+ from typing import Literal
19
+
20
+ from pydantic import Field
21
+ from pydantic_xml import attr, element
22
+
23
+ from libvirtpy.xml._base import LibvirtXmlModel
24
+ from libvirtpy.xml._shared.storage import (
25
+ DeviceSeclabel,
26
+ StorageEncryption,
27
+ StorageSecret,
28
+ )
29
+ from libvirtpy.xml._types import HexNumber, OnOff, SizeUnit, YesNo
30
+
31
+ __all__ = [
32
+ "BlockDataStore",
33
+ "BlockSource",
34
+ "BlockStorage",
35
+ "CookieList",
36
+ "CtlDataStore",
37
+ "CtlSource",
38
+ "CtlStorage",
39
+ "DataStore",
40
+ "DeviceSeclabel",
41
+ "DirDataStore",
42
+ "DirSource",
43
+ "DirStorage",
44
+ "DiskFormat",
45
+ "FileDataStore",
46
+ "FileSource",
47
+ "FileStorage",
48
+ "MetadataCache",
49
+ "MetadataCacheMaxSize",
50
+ "NetworkAuth",
51
+ "NetworkDataStore",
52
+ "NetworkHost",
53
+ "NetworkSource",
54
+ "NetworkStorage",
55
+ "NvmeAddress",
56
+ "NvmeDataStore",
57
+ "NvmeSource",
58
+ "NvmeStorage",
59
+ "Reconnect",
60
+ "ReservationSource",
61
+ "Reservations",
62
+ "SourceSlice",
63
+ "SourceSlices",
64
+ "VhostUserDataStore",
65
+ "VhostUserSource",
66
+ "VhostUserStorage",
67
+ "VhostVdpaDataStore",
68
+ "VhostVdpaSource",
69
+ "VhostVdpaStorage",
70
+ "VolumeDataStore",
71
+ "VolumeSource",
72
+ "VolumeStorage",
73
+ ]
74
+
75
+ StartupPolicy = Literal["mandatory", "requisite", "optional"]
76
+
77
+
78
+ class SourceSlice(LibvirtXmlModel, tag="slice"):
79
+ """``<slice>``: a part of the storage the guest sees."""
80
+
81
+ type: Literal["storage"] = attr(name="type")
82
+ offset: int = attr(name="offset", ge=0)
83
+ size: int = attr(name="size", ge=1)
84
+
85
+
86
+ class SourceSlices(LibvirtXmlModel, tag="slices"):
87
+ slices: list[SourceSlice] = element(tag="slice", default_factory=list)
88
+
89
+
90
+ class Reconnect(LibvirtXmlModel, tag="reconnect"):
91
+ """``<reconnect>``: reconnection to a socket server."""
92
+
93
+ enabled: YesNo | None = attr(name="enabled", default=None)
94
+ timeout: int | None = attr(name="timeout", default=None, ge=0)
95
+ delay: int | None = attr(name="delay", default=None, ge=0)
96
+
97
+
98
+ class MetadataCacheMaxSize(LibvirtXmlModel, tag="max_size"):
99
+ """``<max_size>``: limit of the qcow2 metadata cache."""
100
+
101
+ value: int = Field(ge=0, description="Element text: the amount, in ``unit``.")
102
+ unit: SizeUnit | None = attr(name="unit", default=None)
103
+
104
+
105
+ class MetadataCache(LibvirtXmlModel, tag="metadata_cache"):
106
+ max_size: MetadataCacheMaxSize | None = element(tag="max_size", default=None)
107
+
108
+
109
+ class DiskFormat(LibvirtXmlModel, tag="format"):
110
+ """``<format>``: the image format of a storage source."""
111
+
112
+ type: str = attr(name="type", description="Image format, e.g. ``qcow2``.")
113
+ metadata_cache: MetadataCache | None = element(tag="metadata_cache", default=None)
114
+
115
+
116
+ class ReservationSource(LibvirtXmlModel, tag="source"):
117
+ """``<source>`` of ``<reservations>``: the persistent reservations helper."""
118
+
119
+ type: Literal["unix"] = attr(name="type")
120
+ path: str = attr(name="path")
121
+ mode: Literal["server", "client"] = attr(name="mode")
122
+ reconnect: Reconnect | None = element(tag="reconnect", default=None)
123
+
124
+
125
+ class Reservations(LibvirtXmlModel, tag="reservations"):
126
+ """``<reservations>``: SCSI persistent reservations. Since 4.4.0."""
127
+
128
+ managed: YesNo | None = attr(name="managed", default=None)
129
+ migration: YesNo | None = attr(name="migration", default=None)
130
+ source: ReservationSource | None = element(tag="source", default=None)
131
+
132
+
133
+ class _StorageSourceBase(LibvirtXmlModel, tag="source"):
134
+ """Attributes and children common to most ``<source>`` kinds."""
135
+
136
+ index: int | None = attr(
137
+ name="index", default=None, ge=1, description="Backing chain index."
138
+ )
139
+ startup_policy: StartupPolicy | None = attr(name="startupPolicy", default=None)
140
+ slices: SourceSlices | None = element(tag="slices", default=None)
141
+ encryption: StorageEncryption | None = element(tag="encryption", default=None)
142
+ seclabels: list[DeviceSeclabel] = element(tag="seclabel", default_factory=list)
143
+ data_store: DataStore | None = element(tag="dataStore", default=None)
144
+
145
+
146
+ class FileSource(_StorageSourceBase, tag="source"):
147
+ """``<source file=...>`` of a ``type='file'`` parent."""
148
+
149
+ file: str | None = attr(name="file", default=None)
150
+ fdgroup: str | None = attr(
151
+ name="fdgroup", default=None, description="Passed file descriptors."
152
+ )
153
+
154
+
155
+ class BlockSource(_StorageSourceBase, tag="source"):
156
+ """``<source dev=...>`` of a ``type='block'`` parent."""
157
+
158
+ dev: str | None = attr(name="dev", default=None)
159
+ reservations: Reservations | None = element(tag="reservations", default=None)
160
+
161
+
162
+ class DirSource(_StorageSourceBase, tag="source"):
163
+ """``<source dir=...>`` of a ``type='dir'`` parent."""
164
+
165
+ dir: str = attr(name="dir")
166
+
167
+
168
+ class VolumeSource(_StorageSourceBase, tag="source"):
169
+ """``<source pool=... volume=...>`` of a ``type='volume'`` parent."""
170
+
171
+ pool: str = attr(name="pool")
172
+ volume: str = attr(name="volume")
173
+ mode: Literal["host", "direct"] | None = attr(name="mode", default=None)
174
+
175
+
176
+ class NvmeAddress(LibvirtXmlModel, tag="address"):
177
+ """``<address>`` of an NVMe source: a PCI address without a ``type``."""
178
+
179
+ domain: HexNumber | None = attr(name="domain", default=None)
180
+ bus: HexNumber | None = attr(name="bus", default=None)
181
+ slot: HexNumber | None = attr(name="slot", default=None)
182
+ function: HexNumber | None = attr(name="function", default=None)
183
+ multifunction: OnOff | None = attr(name="multifunction", default=None)
184
+
185
+
186
+ class NvmeSource(_StorageSourceBase, tag="source"):
187
+ """``<source type='pci' ...>`` of a ``type='nvme'`` parent. Since 6.0.0."""
188
+
189
+ type: Literal["pci"] = attr(name="type")
190
+ namespace: int = attr(name="namespace", ge=0)
191
+ managed: YesNo | None = attr(name="managed", default=None)
192
+ address: NvmeAddress = element(tag="address")
193
+
194
+
195
+ class VhostUserSource(LibvirtXmlModel, tag="source"):
196
+ """``<source type='unix' ...>`` of a ``type='vhostuser'`` parent."""
197
+
198
+ type: Literal["unix"] = attr(name="type")
199
+ path: str = attr(name="path")
200
+ reconnect: Reconnect | None = element(tag="reconnect", default=None)
201
+
202
+
203
+ class VhostVdpaSource(LibvirtXmlModel, tag="source"):
204
+ """``<source dev=...>`` of a ``type='vhostvdpa'`` parent."""
205
+
206
+ dev: str = attr(name="dev")
207
+
208
+
209
+ class CtlSource(LibvirtXmlModel, tag="source"):
210
+ """``<source dev=...>`` of a ``type='ctl'`` parent."""
211
+
212
+ dev: str = attr(name="dev")
213
+
214
+
215
+ class NetworkHost(LibvirtXmlModel, tag="host"):
216
+ """``<host>``: a server of a network disk."""
217
+
218
+ transport: Literal["tcp", "rdma", "unix"] | None = attr(
219
+ name="transport", default=None
220
+ )
221
+ name: str | None = attr(name="name", default=None)
222
+ port: int | None = attr(name="port", default=None, ge=0)
223
+ socket: str | None = attr(name="socket", default=None, description="Unix only.")
224
+
225
+
226
+ class NetworkAuth(LibvirtXmlModel, tag="auth"):
227
+ """``<auth>``: credentials for a network disk."""
228
+
229
+ username: str = attr(name="username")
230
+ secret: StorageSecret = element(tag="secret")
231
+
232
+
233
+ class SnapshotName(LibvirtXmlModel, tag="snapshot"):
234
+ name: str = attr(name="name")
235
+
236
+
237
+ class ConfigFile(LibvirtXmlModel, tag="config"):
238
+ file: str = attr(name="file")
239
+
240
+
241
+ class InitiatorIqn(LibvirtXmlModel, tag="iqn"):
242
+ name: str = attr(name="name")
243
+
244
+
245
+ class Initiator(LibvirtXmlModel, tag="initiator"):
246
+ """``<initiator>``: the iSCSI initiator name."""
247
+
248
+ iqn: InitiatorIqn = element(tag="iqn")
249
+
250
+
251
+ class Cookie(LibvirtXmlModel, tag="cookie"):
252
+ value: str = Field(description="Element text: the cookie value.")
253
+ name: str = attr(name="name")
254
+
255
+
256
+ class CookieList(LibvirtXmlModel, tag="cookies"):
257
+ cookies: list[Cookie] = element(tag="cookie", default_factory=list)
258
+
259
+
260
+ class Readahead(LibvirtXmlModel, tag="readahead"):
261
+ size: int = attr(name="size", ge=1)
262
+
263
+
264
+ class NetworkTimeout(LibvirtXmlModel, tag="timeout"):
265
+ seconds: int = attr(name="seconds", ge=1)
266
+
267
+
268
+ class SslVerify(LibvirtXmlModel, tag="ssl"):
269
+ verify: YesNo = attr(name="verify")
270
+
271
+
272
+ class KnownHosts(LibvirtXmlModel, tag="knownHosts"):
273
+ path: str = attr(name="path")
274
+
275
+
276
+ class NetworkIdentity(LibvirtXmlModel, tag="identity"):
277
+ """``<identity>``: SSH credentials, or the user and group of an NFS disk."""
278
+
279
+ username: str | None = attr(name="username", default=None)
280
+ keyfile: str | None = attr(name="keyfile", default=None)
281
+ agentsock: str | None = attr(name="agentsock", default=None)
282
+ user: str | None = attr(name="user", default=None)
283
+ group: str | None = attr(name="group", default=None)
284
+
285
+
286
+ class NetworkSource(_StorageSourceBase, tag="source"):
287
+ """``<source protocol=...>`` of a ``type='network'`` parent."""
288
+
289
+ protocol: Literal[
290
+ "nbd",
291
+ "gluster",
292
+ "rbd",
293
+ "iscsi",
294
+ "http",
295
+ "https",
296
+ "ftps",
297
+ "ftp",
298
+ "ssh",
299
+ "sheepdog",
300
+ "tftp",
301
+ "vxhs",
302
+ "nfs",
303
+ ] = attr(name="protocol")
304
+ name: str | None = attr(name="name", default=None)
305
+ query: str | None = attr(name="query", default=None)
306
+ tls: YesNo | None = attr(name="tls", default=None)
307
+ tls_hostname: str | None = attr(name="tlsHostname", default=None)
308
+ hosts: list[NetworkHost] = element(tag="host", default_factory=list)
309
+ reconnect: Reconnect | None = element(tag="reconnect", default=None)
310
+ snapshot: SnapshotName | None = element(tag="snapshot", default=None)
311
+ config: ConfigFile | None = element(tag="config", default=None)
312
+ auth: NetworkAuth | None = element(tag="auth", default=None)
313
+ initiator: Initiator | None = element(tag="initiator", default=None)
314
+ cookies: CookieList | None = element(tag="cookies", default=None)
315
+ ssl: SslVerify | None = element(tag="ssl", default=None)
316
+ readahead: Readahead | None = element(tag="readahead", default=None)
317
+ timeout: NetworkTimeout | None = element(tag="timeout", default=None)
318
+ known_hosts: KnownHosts | None = element(tag="knownHosts", default=None)
319
+ identity: NetworkIdentity | None = element(tag="identity", default=None)
320
+
321
+
322
+ class FileStorage(LibvirtXmlModel):
323
+ """Mixin: ``type='file'``, which is also the default when ``type`` is missing."""
324
+
325
+ type: Literal["file"] | None = attr(name="type", default=None)
326
+ source: FileSource | None = element(tag="source", default=None)
327
+
328
+
329
+ class BlockStorage(LibvirtXmlModel):
330
+ """Mixin: ``type='block'``."""
331
+
332
+ type: Literal["block"] = attr(name="type")
333
+ source: BlockSource | None = element(tag="source", default=None)
334
+
335
+
336
+ class DirStorage(LibvirtXmlModel):
337
+ """Mixin: ``type='dir'``."""
338
+
339
+ type: Literal["dir"] = attr(name="type")
340
+ source: DirSource | None = element(tag="source", default=None)
341
+
342
+
343
+ class NetworkStorage(LibvirtXmlModel):
344
+ """Mixin: ``type='network'``."""
345
+
346
+ type: Literal["network"] = attr(name="type")
347
+ source: NetworkSource | None = element(tag="source", default=None)
348
+
349
+
350
+ class VolumeStorage(LibvirtXmlModel):
351
+ """Mixin: ``type='volume'``."""
352
+
353
+ type: Literal["volume"] = attr(name="type")
354
+ source: VolumeSource | None = element(tag="source", default=None)
355
+
356
+
357
+ class NvmeStorage(LibvirtXmlModel):
358
+ """Mixin: ``type='nvme'``."""
359
+
360
+ type: Literal["nvme"] = attr(name="type")
361
+ source: NvmeSource | None = element(tag="source", default=None)
362
+
363
+
364
+ class VhostUserStorage(LibvirtXmlModel):
365
+ """Mixin: ``type='vhostuser'``."""
366
+
367
+ type: Literal["vhostuser"] = attr(name="type")
368
+ source: VhostUserSource | None = element(tag="source", default=None)
369
+
370
+
371
+ class VhostVdpaStorage(LibvirtXmlModel):
372
+ """Mixin: ``type='vhostvdpa'``."""
373
+
374
+ type: Literal["vhostvdpa"] = attr(name="type")
375
+ source: VhostVdpaSource | None = element(tag="source", default=None)
376
+
377
+
378
+ class CtlStorage(LibvirtXmlModel):
379
+ """Mixin: ``type='ctl'``."""
380
+
381
+ type: Literal["ctl"] = attr(name="type")
382
+ source: CtlSource | None = element(tag="source", default=None)
383
+
384
+
385
+ class _DataStoreBase(LibvirtXmlModel, tag="dataStore"):
386
+ """``<dataStore>``: where the guest data of a qcow2 image is stored."""
387
+
388
+ format_info: DiskFormat | None = element(tag="format", default=None)
389
+
390
+
391
+ class FileDataStore(_DataStoreBase, FileStorage, tag="dataStore"):
392
+ """A ``<dataStore>`` that is a file."""
393
+
394
+
395
+ class BlockDataStore(_DataStoreBase, BlockStorage, tag="dataStore"):
396
+ """A ``<dataStore type='block'>``."""
397
+
398
+
399
+ class DirDataStore(_DataStoreBase, DirStorage, tag="dataStore"):
400
+ """A ``<dataStore type='dir'>``."""
401
+
402
+
403
+ class NetworkDataStore(_DataStoreBase, NetworkStorage, tag="dataStore"):
404
+ """A ``<dataStore type='network'>``."""
405
+
406
+
407
+ class VolumeDataStore(_DataStoreBase, VolumeStorage, tag="dataStore"):
408
+ """A ``<dataStore type='volume'>``."""
409
+
410
+
411
+ class NvmeDataStore(_DataStoreBase, NvmeStorage, tag="dataStore"):
412
+ """A ``<dataStore type='nvme'>``."""
413
+
414
+
415
+ class VhostUserDataStore(_DataStoreBase, VhostUserStorage, tag="dataStore"):
416
+ """A ``<dataStore type='vhostuser'>``."""
417
+
418
+
419
+ class VhostVdpaDataStore(_DataStoreBase, VhostVdpaStorage, tag="dataStore"):
420
+ """A ``<dataStore type='vhostvdpa'>``."""
421
+
422
+
423
+ class CtlDataStore(_DataStoreBase, CtlStorage, tag="dataStore"):
424
+ """A ``<dataStore type='ctl'>``."""
425
+
426
+
427
+ DataStore = (
428
+ FileDataStore
429
+ | BlockDataStore
430
+ | DirDataStore
431
+ | NetworkDataStore
432
+ | VolumeDataStore
433
+ | NvmeDataStore
434
+ | VhostUserDataStore
435
+ | VhostVdpaDataStore
436
+ | CtlDataStore
437
+ )
438
+ """Any ``<dataStore>``; the variant is chosen by its ``type`` attribute."""
439
+
440
+ # The sources refer to ``DataStore``, which is defined after them and uses them
441
+ # through the mixins: every class of this cycle has to be rebuilt once all of
442
+ # them exist, or pydantic-xml leaves their serializers unbuilt.
443
+ FileSource.model_rebuild()
444
+ BlockSource.model_rebuild()
445
+ DirSource.model_rebuild()
446
+ VolumeSource.model_rebuild()
447
+ NvmeSource.model_rebuild()
448
+ NetworkSource.model_rebuild()
449
+ FileStorage.model_rebuild()
450
+ BlockStorage.model_rebuild()
451
+ DirStorage.model_rebuild()
452
+ NetworkStorage.model_rebuild()
453
+ VolumeStorage.model_rebuild()
454
+ NvmeStorage.model_rebuild()
455
+ VhostUserStorage.model_rebuild()
456
+ VhostVdpaStorage.model_rebuild()
457
+ CtlStorage.model_rebuild()
458
+ FileDataStore.model_rebuild()
459
+ BlockDataStore.model_rebuild()
460
+ DirDataStore.model_rebuild()
461
+ NetworkDataStore.model_rebuild()
462
+ VolumeDataStore.model_rebuild()
463
+ NvmeDataStore.model_rebuild()
464
+ VhostUserDataStore.model_rebuild()
465
+ VhostVdpaDataStore.model_rebuild()
466
+ CtlDataStore.model_rebuild()
@@ -0,0 +1,34 @@
1
+ """``<sysinfo>`` of a domain: SMBIOS data or firmware configuration entries.
2
+
3
+ The standalone host ``<sysinfo>`` document is ``libvirtpy.xml.sysinfo``.
4
+
5
+ See https://libvirt.org/formatdomain.html#smbios-system-information
6
+ """
7
+
8
+ from typing import Literal
9
+
10
+ from pydantic_xml import attr, element
11
+
12
+ from libvirtpy.xml._base import LibvirtXmlModel
13
+ from libvirtpy.xml._shared.sysinfo import (
14
+ FwcfgEntry,
15
+ SysinfoBaseBoard,
16
+ SysinfoBios,
17
+ SysinfoChassis,
18
+ SysinfoOemStrings,
19
+ SysinfoSystem,
20
+ )
21
+
22
+ __all__ = ["Sysinfo"]
23
+
24
+
25
+ class Sysinfo(LibvirtXmlModel, tag="sysinfo"):
26
+ """``<sysinfo>``: ``type='smbios'`` groups, or ``type='fwcfg'`` entries."""
27
+
28
+ type: Literal["smbios", "fwcfg"] = attr(name="type")
29
+ bios: SysinfoBios | None = element(tag="bios", default=None)
30
+ system: SysinfoSystem | None = element(tag="system", default=None)
31
+ base_boards: list[SysinfoBaseBoard] = element(tag="baseBoard", default_factory=list)
32
+ chassis: SysinfoChassis | None = element(tag="chassis", default=None)
33
+ oem_strings: SysinfoOemStrings | None = element(tag="oemStrings", default=None)
34
+ entries: list[FwcfgEntry] = element(tag="entry", default_factory=list)
@@ -0,0 +1,17 @@
1
+ """Models for host ``<interface>`` XML. See https://libvirt.org/formatinterface.html"""
2
+
3
+ from libvirtpy.xml.interface.interface import (
4
+ HostInterface,
5
+ HostInterfaceBond,
6
+ HostInterfaceBridge,
7
+ HostInterfaceVlan,
8
+ InterfaceProtocol,
9
+ )
10
+
11
+ __all__ = [
12
+ "HostInterface",
13
+ "HostInterfaceBond",
14
+ "HostInterfaceBridge",
15
+ "HostInterfaceVlan",
16
+ "InterfaceProtocol",
17
+ ]
@@ -0,0 +1,153 @@
1
+ """``<interface>`` as a host network interface (``virsh iface-*``).
2
+
3
+ Not to be confused with a domain's ``<interface>`` device
4
+ (``libvirtpy.xml.domain.devices.interface``).
5
+
6
+ One model covers the ``ethernet``, ``bridge``, ``bond`` and ``vlan`` types: a
7
+ bridge or bond holds other interfaces, which are the same element, so the
8
+ model refers to itself.
9
+
10
+ See https://libvirt.org/formatinterface.html
11
+ """
12
+
13
+ from typing import Literal
14
+
15
+ from pydantic_xml import attr, element
16
+
17
+ from libvirtpy.xml._base import LibvirtXmlModel
18
+ from libvirtpy.xml._types import OnOff, PresenceFlag, YesNo
19
+
20
+ __all__ = [
21
+ "HostInterface",
22
+ "HostInterfaceBond",
23
+ "HostInterfaceBridge",
24
+ "HostInterfaceVlan",
25
+ "InterfaceProtocol",
26
+ ]
27
+
28
+
29
+ class InterfaceStart(LibvirtXmlModel, tag="start"):
30
+ mode: Literal["onboot", "none", "hotplug"] = attr(name="mode")
31
+
32
+
33
+ class InterfaceMac(LibvirtXmlModel, tag="mac"):
34
+ address: str = attr(name="address")
35
+
36
+
37
+ class InterfaceLink(LibvirtXmlModel, tag="link"):
38
+ speed: int | None = attr(name="speed", default=None, ge=0)
39
+ state: (
40
+ Literal[
41
+ "unknown",
42
+ "notpresent",
43
+ "down",
44
+ "lowerlayerdown",
45
+ "testing",
46
+ "dormant",
47
+ "up",
48
+ ]
49
+ | None
50
+ ) = attr(name="state", default=None)
51
+
52
+
53
+ class InterfaceMtu(LibvirtXmlModel, tag="mtu"):
54
+ size: int = attr(name="size", ge=0)
55
+
56
+
57
+ class ProtocolDhcp(LibvirtXmlModel, tag="dhcp"):
58
+ peerdns: YesNo | None = attr(name="peerdns", default=None)
59
+
60
+
61
+ class ProtocolIp(LibvirtXmlModel, tag="ip"):
62
+ address: str = attr(name="address")
63
+ prefix: int | None = attr(name="prefix", default=None, ge=0)
64
+
65
+
66
+ class ProtocolRoute(LibvirtXmlModel, tag="route"):
67
+ gateway: str = attr(name="gateway")
68
+
69
+
70
+ class InterfaceProtocol(LibvirtXmlModel, tag="protocol"):
71
+ """``<protocol>``: the IPv4 or IPv6 configuration of the interface."""
72
+
73
+ family: Literal["ipv4", "ipv6"] = attr(name="family")
74
+ autoconf: PresenceFlag | None = element(tag="autoconf", default=None)
75
+ dhcp: ProtocolDhcp | None = element(tag="dhcp", default=None)
76
+ ips: list[ProtocolIp] = element(tag="ip", default_factory=list)
77
+ route: ProtocolRoute | None = element(tag="route", default=None)
78
+
79
+
80
+ class HostInterfaceBridge(LibvirtXmlModel, tag="bridge"):
81
+ """``<bridge>``: the ports of a bridge interface."""
82
+
83
+ stp: OnOff | None = attr(name="stp", default=None)
84
+ delay: str | None = attr(
85
+ name="delay", default=None, description="Seconds, a decimal number as text."
86
+ )
87
+ interfaces: list[HostInterface] = element(tag="interface", default_factory=list)
88
+
89
+
90
+ class BondMiimon(LibvirtXmlModel, tag="miimon"):
91
+ freq: int = attr(name="freq", ge=0)
92
+ downdelay: int | None = attr(name="downdelay", default=None, ge=0)
93
+ updelay: int | None = attr(name="updelay", default=None, ge=0)
94
+ carrier: Literal["ioctl", "netif"] | None = attr(name="carrier", default=None)
95
+
96
+
97
+ class BondArpmon(LibvirtXmlModel, tag="arpmon"):
98
+ interval: int = attr(name="interval", ge=0)
99
+ target: str = attr(name="target")
100
+ validate_: Literal["none", "active", "backup", "all"] | None = attr(
101
+ name="validate", default=None
102
+ )
103
+
104
+
105
+ class HostInterfaceBond(LibvirtXmlModel, tag="bond"):
106
+ """``<bond>``: the slaves and link monitoring of a bond interface."""
107
+
108
+ mode: (
109
+ Literal[
110
+ "balance-rr",
111
+ "active-backup",
112
+ "balance-xor",
113
+ "broadcast",
114
+ "802.3ad",
115
+ "balance-tlb",
116
+ "balance-alb",
117
+ ]
118
+ | None
119
+ ) = attr(name="mode", default=None)
120
+ miimon: BondMiimon | None = element(tag="miimon", default=None)
121
+ arpmon: BondArpmon | None = element(tag="arpmon", default=None)
122
+ interfaces: list[HostInterface] = element(tag="interface", default_factory=list)
123
+
124
+
125
+ class VlanDevice(LibvirtXmlModel, tag="interface"):
126
+ name: str = attr(name="name")
127
+
128
+
129
+ class HostInterfaceVlan(LibvirtXmlModel, tag="vlan"):
130
+ """``<vlan>``: the tag and parent device of a VLAN interface."""
131
+
132
+ tag: int = attr(name="tag", ge=0, le=4095)
133
+ interface: VlanDevice = element(tag="interface")
134
+
135
+
136
+ class HostInterface(LibvirtXmlModel, tag="interface"):
137
+ """``<interface>``: a host network interface."""
138
+
139
+ type: Literal["ethernet", "bridge", "bond", "vlan"] = attr(name="type")
140
+ name: str | None = attr(name="name", default=None)
141
+ start: InterfaceStart | None = element(tag="start", default=None)
142
+ mac: InterfaceMac | None = element(tag="mac", default=None)
143
+ link: InterfaceLink | None = element(tag="link", default=None)
144
+ mtu: InterfaceMtu | None = element(tag="mtu", default=None)
145
+ protocols: list[InterfaceProtocol] = element(tag="protocol", default_factory=list)
146
+ bridge: HostInterfaceBridge | None = element(tag="bridge", default=None)
147
+ bond: HostInterfaceBond | None = element(tag="bond", default=None)
148
+ vlan: HostInterfaceVlan | None = element(tag="vlan", default=None)
149
+
150
+
151
+ # The bridge and the bond hold ``HostInterface``, which is defined after them.
152
+ HostInterfaceBridge.model_rebuild()
153
+ HostInterfaceBond.model_rebuild()