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
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"""Operations on the ports of a virtual network."""
|
|
2
|
+
|
|
3
|
+
from functools import partial
|
|
4
|
+
|
|
5
|
+
from libvirtpy.client.operations._common import (
|
|
6
|
+
as_handle,
|
|
7
|
+
as_xml,
|
|
8
|
+
fetch_model,
|
|
9
|
+
fetch_models,
|
|
10
|
+
many_handles,
|
|
11
|
+
on_network_port,
|
|
12
|
+
on_object,
|
|
13
|
+
one_handle,
|
|
14
|
+
read_parameters,
|
|
15
|
+
)
|
|
16
|
+
from libvirtpy.client.references import (
|
|
17
|
+
NetworkPortRef,
|
|
18
|
+
NetworkRef,
|
|
19
|
+
network_lookup,
|
|
20
|
+
network_port_lookup,
|
|
21
|
+
)
|
|
22
|
+
from libvirtpy.client.transport import Operation, Request
|
|
23
|
+
from libvirtpy.rpc.typed_params import TypedValue, to_wire
|
|
24
|
+
from libvirtpy.xml.network import NetworkPort
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"create_network_port",
|
|
28
|
+
"delete_network_port",
|
|
29
|
+
"get_network_port_parameters",
|
|
30
|
+
"list_network_ports",
|
|
31
|
+
"lookup_network_port",
|
|
32
|
+
"set_network_port_parameters",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def list_network_ports(
|
|
37
|
+
network: NetworkRef, *, flags: int = 0
|
|
38
|
+
) -> Operation[list[NetworkPort]]:
|
|
39
|
+
"""Return the ports of a network.
|
|
40
|
+
|
|
41
|
+
:param network: the network.
|
|
42
|
+
:param flags: reserved, 0.
|
|
43
|
+
:returns: the ports.
|
|
44
|
+
"""
|
|
45
|
+
handle = yield from one_handle(network_lookup(network))
|
|
46
|
+
ports = yield from many_handles(
|
|
47
|
+
Request(
|
|
48
|
+
"network_list_all_ports",
|
|
49
|
+
{"network": handle, "need_results": 1, "flags": flags},
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
return (yield from fetch_models("network_port_get_xml_desc", ports, NetworkPort))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def lookup_network_port(
|
|
56
|
+
network: NetworkRef, port: NetworkPortRef
|
|
57
|
+
) -> Operation[NetworkPort]:
|
|
58
|
+
"""Return one port of a network.
|
|
59
|
+
|
|
60
|
+
:param network: the network.
|
|
61
|
+
:param port: the port's UUID, or a ``NetworkPort`` model.
|
|
62
|
+
:returns: the port.
|
|
63
|
+
:raises NoNetworkPortError: if there is no such port.
|
|
64
|
+
"""
|
|
65
|
+
network_handle = yield from one_handle(network_lookup(network))
|
|
66
|
+
found = yield from one_handle(network_port_lookup(network_handle, port))
|
|
67
|
+
return (yield from fetch_model("network_port_get_xml_desc", found, NetworkPort))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def create_network_port(
|
|
71
|
+
network: NetworkRef, port: NetworkPort | str, *, flags: int = 0
|
|
72
|
+
) -> Operation[NetworkPort]:
|
|
73
|
+
"""Create a port on a network.
|
|
74
|
+
|
|
75
|
+
:param network: the network.
|
|
76
|
+
:param port: the port description, as a model or XML.
|
|
77
|
+
:param flags: ``virNetworkPortCreateFlags``: 1 validate.
|
|
78
|
+
:returns: the port as the daemon created it.
|
|
79
|
+
"""
|
|
80
|
+
created = yield from as_handle(
|
|
81
|
+
on_object(
|
|
82
|
+
network_lookup(network),
|
|
83
|
+
"network",
|
|
84
|
+
"network_port_create_xml",
|
|
85
|
+
{"xml": as_xml(port), "flags": flags},
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
return (yield from fetch_model("network_port_get_xml_desc", created, NetworkPort))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def delete_network_port(
|
|
92
|
+
network: NetworkRef, port: NetworkPortRef, *, flags: int = 0
|
|
93
|
+
) -> Operation[None]:
|
|
94
|
+
"""Delete a port of a network.
|
|
95
|
+
|
|
96
|
+
:param network: the network.
|
|
97
|
+
:param port: the port's UUID, or a ``NetworkPort`` model.
|
|
98
|
+
:param flags: reserved, 0.
|
|
99
|
+
"""
|
|
100
|
+
yield from on_network_port(network, port, "network_port_delete", flags=flags)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def get_network_port_parameters(
|
|
104
|
+
network: NetworkRef, port: NetworkPortRef, *, flags: int = 0
|
|
105
|
+
) -> Operation[dict[str, TypedValue]]:
|
|
106
|
+
"""Return the bandwidth limits of a port.
|
|
107
|
+
|
|
108
|
+
:param network: the network.
|
|
109
|
+
:param port: the port's UUID, or a ``NetworkPort`` model.
|
|
110
|
+
:param flags: reserved, 0.
|
|
111
|
+
:returns: ``inbound.average``, ``outbound.peak``, ...
|
|
112
|
+
"""
|
|
113
|
+
return (
|
|
114
|
+
yield from read_parameters(
|
|
115
|
+
partial(on_network_port, network, port),
|
|
116
|
+
"network_port_get_parameters",
|
|
117
|
+
flags,
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def set_network_port_parameters(
|
|
123
|
+
network: NetworkRef,
|
|
124
|
+
port: NetworkPortRef,
|
|
125
|
+
parameters: dict[str, TypedValue],
|
|
126
|
+
*,
|
|
127
|
+
flags: int = 0,
|
|
128
|
+
) -> Operation[None]:
|
|
129
|
+
"""Change the bandwidth limits of a port.
|
|
130
|
+
|
|
131
|
+
:param network: the network.
|
|
132
|
+
:param port: the port's UUID, or a ``NetworkPort`` model.
|
|
133
|
+
:param parameters: e.g. ``{"inbound.average": 1000}``.
|
|
134
|
+
:param flags: reserved, 0.
|
|
135
|
+
"""
|
|
136
|
+
yield from on_network_port(
|
|
137
|
+
network,
|
|
138
|
+
port,
|
|
139
|
+
"network_port_set_parameters",
|
|
140
|
+
params=to_wire(parameters),
|
|
141
|
+
flags=flags,
|
|
142
|
+
)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Operations on the devices of the host."""
|
|
2
|
+
|
|
3
|
+
from libvirtpy.client.operations._common import (
|
|
4
|
+
as_xml,
|
|
5
|
+
fetch_model,
|
|
6
|
+
fetch_models,
|
|
7
|
+
many_handles,
|
|
8
|
+
one_handle,
|
|
9
|
+
)
|
|
10
|
+
from libvirtpy.client.references import (
|
|
11
|
+
NodeDeviceRef,
|
|
12
|
+
node_device_lookup,
|
|
13
|
+
)
|
|
14
|
+
from libvirtpy.client.transport import Operation, Request
|
|
15
|
+
from libvirtpy.xml.nodedev import Device
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"create_node_device",
|
|
19
|
+
"destroy_node_device",
|
|
20
|
+
"list_node_devices",
|
|
21
|
+
"lookup_node_device",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def lookup_node_device(device: NodeDeviceRef) -> Operation[Device]:
|
|
26
|
+
"""Return a device of the host.
|
|
27
|
+
|
|
28
|
+
:param device: the device name (``pci_0000_00_1f_2``) or a ``Device`` model.
|
|
29
|
+
:returns: the device and its capabilities.
|
|
30
|
+
:raises NoNodeDeviceError: if there is no such device.
|
|
31
|
+
"""
|
|
32
|
+
handle = yield from one_handle(node_device_lookup(device))
|
|
33
|
+
return (yield from fetch_model("node_device_get_xml_desc", handle, Device))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def list_node_devices(*, capability: str | None = None) -> Operation[list[Device]]:
|
|
37
|
+
"""Return the devices of the host.
|
|
38
|
+
|
|
39
|
+
:param capability: only devices with this capability type (``pci``, ``net``...).
|
|
40
|
+
:returns: the devices.
|
|
41
|
+
"""
|
|
42
|
+
arguments = {"need_results": 1, "flags": 0}
|
|
43
|
+
handles = yield from many_handles(
|
|
44
|
+
Request("connect_list_all_node_devices", arguments)
|
|
45
|
+
)
|
|
46
|
+
devices = yield from fetch_models("node_device_get_xml_desc", handles, Device)
|
|
47
|
+
if capability is None:
|
|
48
|
+
return devices
|
|
49
|
+
return [
|
|
50
|
+
device
|
|
51
|
+
for device in devices
|
|
52
|
+
if any(found.type == capability for found in device.capabilities)
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def create_node_device(device: Device | str, *, flags: int = 0) -> Operation[Device]:
|
|
57
|
+
"""Create a virtual device on the host (an NPIV vport, a mediated device).
|
|
58
|
+
|
|
59
|
+
:param device: the device description, as a model or XML text.
|
|
60
|
+
:param flags: reserved, ``0``.
|
|
61
|
+
:returns: the created device.
|
|
62
|
+
"""
|
|
63
|
+
xml = as_xml(device)
|
|
64
|
+
handle = yield from one_handle(
|
|
65
|
+
Request("node_device_create_xml", {"xml_desc": xml, "flags": flags})
|
|
66
|
+
)
|
|
67
|
+
return (yield from fetch_model("node_device_get_xml_desc", handle, Device))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def destroy_node_device(device: NodeDeviceRef) -> Operation[None]:
|
|
71
|
+
"""Remove a virtual device created with ``create_node_device``.
|
|
72
|
+
|
|
73
|
+
:param device: the device.
|
|
74
|
+
"""
|
|
75
|
+
handle = yield from one_handle(node_device_lookup(device))
|
|
76
|
+
yield Request("node_device_destroy", {"name": handle.name})
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"""Operations on host devices beyond listing and creating them."""
|
|
2
|
+
|
|
3
|
+
from libvirtpy.client.operations._common import (
|
|
4
|
+
as_bool,
|
|
5
|
+
as_list,
|
|
6
|
+
as_text,
|
|
7
|
+
as_xml,
|
|
8
|
+
fetch_model,
|
|
9
|
+
on_node_device,
|
|
10
|
+
one_handle,
|
|
11
|
+
)
|
|
12
|
+
from libvirtpy.client.references import NodeDeviceRef
|
|
13
|
+
from libvirtpy.client.transport import Operation, Request
|
|
14
|
+
from libvirtpy.xml.nodedev import Device
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"define_node_device",
|
|
18
|
+
"detach_node_device",
|
|
19
|
+
"get_node_device_autostart",
|
|
20
|
+
"get_node_device_parent",
|
|
21
|
+
"is_node_device_active",
|
|
22
|
+
"is_node_device_persistent",
|
|
23
|
+
"list_node_device_capabilities",
|
|
24
|
+
"lookup_node_device_scsi_host_by_wwn",
|
|
25
|
+
"reattach_node_device",
|
|
26
|
+
"reset_node_device",
|
|
27
|
+
"set_node_device_autostart",
|
|
28
|
+
"start_node_device",
|
|
29
|
+
"undefine_node_device",
|
|
30
|
+
"update_node_device",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def get_node_device_parent(device: NodeDeviceRef) -> Operation[str | None]:
|
|
35
|
+
"""Return the name of the parent of a host device.
|
|
36
|
+
|
|
37
|
+
:param device: the device.
|
|
38
|
+
:returns: the parent's name, or ``None`` if it has none.
|
|
39
|
+
"""
|
|
40
|
+
reply = yield from on_node_device(device, "node_device_get_parent")
|
|
41
|
+
return None if reply is None else as_text(reply)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def list_node_device_capabilities(
|
|
45
|
+
device: NodeDeviceRef, *, max_names: int = 256
|
|
46
|
+
) -> Operation[list[str]]:
|
|
47
|
+
"""List the capabilities of a host device.
|
|
48
|
+
|
|
49
|
+
:param device: the device.
|
|
50
|
+
:param max_names: how many names to ask for at most.
|
|
51
|
+
:returns: the capability names, e.g. ``pci``, ``net``.
|
|
52
|
+
"""
|
|
53
|
+
reply = yield from on_node_device(
|
|
54
|
+
device, "node_device_list_caps", maxnames=max_names
|
|
55
|
+
)
|
|
56
|
+
return [as_text(name) for name in as_list(reply)]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def detach_node_device(
|
|
60
|
+
device: NodeDeviceRef, driver: str | None = None, *, flags: int = 0
|
|
61
|
+
) -> Operation[None]:
|
|
62
|
+
"""Detach a device from its host driver, to give it to a guest.
|
|
63
|
+
|
|
64
|
+
:param device: the device.
|
|
65
|
+
:param driver: the driver to bind it to (``vfio``); ``None`` for the default.
|
|
66
|
+
:param flags: reserved, 0.
|
|
67
|
+
"""
|
|
68
|
+
yield from on_node_device(
|
|
69
|
+
device, "node_device_detach_flags", driver_name=driver, flags=flags
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def reattach_node_device(device: NodeDeviceRef) -> Operation[None]:
|
|
74
|
+
"""Give a device back to its host driver.
|
|
75
|
+
|
|
76
|
+
:param device: the device.
|
|
77
|
+
"""
|
|
78
|
+
yield from on_node_device(device, "node_device_re_attach")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def reset_node_device(device: NodeDeviceRef) -> Operation[None]:
|
|
82
|
+
"""Reset a host device.
|
|
83
|
+
|
|
84
|
+
:param device: the device.
|
|
85
|
+
"""
|
|
86
|
+
yield from on_node_device(device, "node_device_reset")
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def lookup_node_device_scsi_host_by_wwn(
|
|
90
|
+
wwnn: str, wwpn: str, *, flags: int = 0
|
|
91
|
+
) -> Operation[Device]:
|
|
92
|
+
"""Find a SCSI host device by its world wide names.
|
|
93
|
+
|
|
94
|
+
:param wwnn: the world wide node name.
|
|
95
|
+
:param wwpn: the world wide port name.
|
|
96
|
+
:param flags: reserved, 0.
|
|
97
|
+
:returns: the device.
|
|
98
|
+
:raises NoNodeDeviceError: if there is none.
|
|
99
|
+
"""
|
|
100
|
+
found = yield from one_handle(
|
|
101
|
+
Request(
|
|
102
|
+
"node_device_lookup_scsi_host_by_wwn",
|
|
103
|
+
{"wwnn": wwnn, "wwpn": wwpn, "flags": flags},
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
return (yield from fetch_model("node_device_get_xml_desc", found, Device))
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def define_node_device(device: Device | str, *, flags: int = 0) -> Operation[Device]:
|
|
110
|
+
"""Define a persistent mediated device (stored, not yet started).
|
|
111
|
+
|
|
112
|
+
:param device: the device description, as a model or XML.
|
|
113
|
+
:param flags: reserved, 0.
|
|
114
|
+
:returns: the device as the daemon stored it.
|
|
115
|
+
"""
|
|
116
|
+
created = yield from one_handle(
|
|
117
|
+
Request("node_device_define_xml", {"xml_desc": as_xml(device), "flags": flags})
|
|
118
|
+
)
|
|
119
|
+
return (yield from fetch_model("node_device_get_xml_desc", created, Device))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def undefine_node_device(device: NodeDeviceRef, *, flags: int = 0) -> Operation[None]:
|
|
123
|
+
"""Remove the stored definition of a mediated device.
|
|
124
|
+
|
|
125
|
+
:param device: the device.
|
|
126
|
+
:param flags: reserved, 0.
|
|
127
|
+
"""
|
|
128
|
+
yield from on_node_device(device, "node_device_undefine", flags=flags)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def start_node_device(device: NodeDeviceRef, *, flags: int = 0) -> Operation[None]:
|
|
132
|
+
"""Start a defined mediated device.
|
|
133
|
+
|
|
134
|
+
:param device: the device.
|
|
135
|
+
:param flags: reserved, 0.
|
|
136
|
+
"""
|
|
137
|
+
yield from on_node_device(device, "node_device_create", flags=flags)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def get_node_device_autostart(device: NodeDeviceRef) -> Operation[bool]:
|
|
141
|
+
"""Tell whether a mediated device starts at host boot.
|
|
142
|
+
|
|
143
|
+
:param device: the device.
|
|
144
|
+
:returns: ``True`` if it does.
|
|
145
|
+
"""
|
|
146
|
+
return as_bool((yield from on_node_device(device, "node_device_get_autostart")))
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def set_node_device_autostart(device: NodeDeviceRef, enabled: bool) -> Operation[None]:
|
|
150
|
+
"""Choose whether a mediated device starts at host boot.
|
|
151
|
+
|
|
152
|
+
:param device: the device.
|
|
153
|
+
:param enabled: ``True`` to start it at boot.
|
|
154
|
+
"""
|
|
155
|
+
yield from on_node_device(
|
|
156
|
+
device, "node_device_set_autostart", autostart=int(enabled)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def is_node_device_active(device: NodeDeviceRef) -> Operation[bool]:
|
|
161
|
+
"""Tell whether a mediated device is started.
|
|
162
|
+
|
|
163
|
+
:param device: the device.
|
|
164
|
+
:returns: ``True`` if it is active.
|
|
165
|
+
"""
|
|
166
|
+
return as_bool((yield from on_node_device(device, "node_device_is_active")))
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def is_node_device_persistent(device: NodeDeviceRef) -> Operation[bool]:
|
|
170
|
+
"""Tell whether a mediated device has a stored definition.
|
|
171
|
+
|
|
172
|
+
:param device: the device.
|
|
173
|
+
:returns: ``True`` if persistent.
|
|
174
|
+
"""
|
|
175
|
+
return as_bool((yield from on_node_device(device, "node_device_is_persistent")))
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def update_node_device(
|
|
179
|
+
device: NodeDeviceRef, definition: Device | str, *, flags: int = 0
|
|
180
|
+
) -> Operation[None]:
|
|
181
|
+
"""Change the definition of a mediated device.
|
|
182
|
+
|
|
183
|
+
:param device: the device.
|
|
184
|
+
:param definition: the new description, as a model or XML.
|
|
185
|
+
:param flags: ``virNodeDeviceUpdateFlags``: 1 affect the running device.
|
|
186
|
+
"""
|
|
187
|
+
yield from on_node_device(
|
|
188
|
+
device, "node_device_update", xml_desc=as_xml(definition), flags=flags
|
|
189
|
+
)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Operations on network filters."""
|
|
2
|
+
|
|
3
|
+
from libvirtpy.client.operations._common import (
|
|
4
|
+
as_xml,
|
|
5
|
+
fetch_model,
|
|
6
|
+
fetch_models,
|
|
7
|
+
many_handles,
|
|
8
|
+
one_handle,
|
|
9
|
+
)
|
|
10
|
+
from libvirtpy.client.references import (
|
|
11
|
+
NwFilterRef,
|
|
12
|
+
nwfilter_lookup,
|
|
13
|
+
)
|
|
14
|
+
from libvirtpy.client.transport import Operation, Request
|
|
15
|
+
from libvirtpy.xml.nwfilter import Filter
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"define_nwfilter",
|
|
19
|
+
"list_nwfilters",
|
|
20
|
+
"lookup_nwfilter",
|
|
21
|
+
"undefine_nwfilter",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def lookup_nwfilter(nwfilter: NwFilterRef) -> Operation[Filter]:
|
|
26
|
+
"""Return a network filter.
|
|
27
|
+
|
|
28
|
+
:param nwfilter: a name, UUID or ``Filter`` model.
|
|
29
|
+
:returns: the filter.
|
|
30
|
+
:raises NoFilterError: if there is no such filter.
|
|
31
|
+
"""
|
|
32
|
+
handle = yield from one_handle(nwfilter_lookup(nwfilter))
|
|
33
|
+
return (yield from fetch_model("nwfilter_get_xml_desc", handle, Filter))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def list_nwfilters() -> Operation[list[Filter]]:
|
|
37
|
+
"""Return the network filters.
|
|
38
|
+
|
|
39
|
+
:returns: the filters.
|
|
40
|
+
"""
|
|
41
|
+
handles = yield from many_handles(
|
|
42
|
+
Request("connect_list_all_nwfilters", {"need_results": 1, "flags": 0})
|
|
43
|
+
)
|
|
44
|
+
return (yield from fetch_models("nwfilter_get_xml_desc", handles, Filter))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def define_nwfilter(nwfilter: Filter | str, *, flags: int = 0) -> Operation[Filter]:
|
|
48
|
+
"""Define (or redefine) a network filter.
|
|
49
|
+
|
|
50
|
+
:param nwfilter: the filter, as a model or XML text.
|
|
51
|
+
:param flags: ``virNWFilterDefineFlags``.
|
|
52
|
+
:returns: the stored filter.
|
|
53
|
+
"""
|
|
54
|
+
xml = as_xml(nwfilter)
|
|
55
|
+
handle = yield from one_handle(
|
|
56
|
+
Request("nwfilter_define_xml_flags", {"xml": xml, "flags": flags})
|
|
57
|
+
)
|
|
58
|
+
return (yield from fetch_model("nwfilter_get_xml_desc", handle, Filter))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def undefine_nwfilter(nwfilter: NwFilterRef) -> Operation[None]:
|
|
62
|
+
"""Remove a network filter.
|
|
63
|
+
|
|
64
|
+
:param nwfilter: the filter.
|
|
65
|
+
"""
|
|
66
|
+
handle = yield from one_handle(nwfilter_lookup(nwfilter))
|
|
67
|
+
yield Request("nwfilter_undefine", {"nwfilter": handle})
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Operations on network filter bindings (a filter attached to a port device)."""
|
|
2
|
+
|
|
3
|
+
from libvirtpy.client.operations._common import (
|
|
4
|
+
as_xml,
|
|
5
|
+
fetch_model,
|
|
6
|
+
fetch_models,
|
|
7
|
+
many_handles,
|
|
8
|
+
on_nwfilter_binding,
|
|
9
|
+
one_handle,
|
|
10
|
+
)
|
|
11
|
+
from libvirtpy.client.references import NwFilterBindingRef, nwfilter_binding_lookup
|
|
12
|
+
from libvirtpy.client.transport import Operation, Request
|
|
13
|
+
from libvirtpy.xml.nwfilter import FilterBinding
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"create_nwfilter_binding",
|
|
17
|
+
"delete_nwfilter_binding",
|
|
18
|
+
"list_nwfilter_bindings",
|
|
19
|
+
"lookup_nwfilter_binding",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def list_nwfilter_bindings(*, flags: int = 0) -> Operation[list[FilterBinding]]:
|
|
24
|
+
"""Return the network filter bindings of the host.
|
|
25
|
+
|
|
26
|
+
:param flags: reserved, 0.
|
|
27
|
+
:returns: the bindings.
|
|
28
|
+
"""
|
|
29
|
+
handles = yield from many_handles(
|
|
30
|
+
Request(
|
|
31
|
+
"connect_list_all_nwfilter_bindings", {"need_results": 1, "flags": flags}
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
return (
|
|
35
|
+
yield from fetch_models("nwfilter_binding_get_xml_desc", handles, FilterBinding)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def lookup_nwfilter_binding(binding: NwFilterBindingRef) -> Operation[FilterBinding]:
|
|
40
|
+
"""Return the binding of a port device.
|
|
41
|
+
|
|
42
|
+
:param binding: the name of the port device (``vnet0``), or a ``FilterBinding``.
|
|
43
|
+
:returns: the binding.
|
|
44
|
+
:raises NoFilterBindingError: if there is none.
|
|
45
|
+
"""
|
|
46
|
+
found = yield from one_handle(nwfilter_binding_lookup(binding))
|
|
47
|
+
return (
|
|
48
|
+
yield from fetch_model("nwfilter_binding_get_xml_desc", found, FilterBinding)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def create_nwfilter_binding(
|
|
53
|
+
binding: FilterBinding | str, *, flags: int = 0
|
|
54
|
+
) -> Operation[FilterBinding]:
|
|
55
|
+
"""Attach a network filter to a port device.
|
|
56
|
+
|
|
57
|
+
:param binding: the binding description, as a model or XML.
|
|
58
|
+
:param flags: reserved, 0.
|
|
59
|
+
:returns: the binding as the daemon created it.
|
|
60
|
+
"""
|
|
61
|
+
created = yield from one_handle(
|
|
62
|
+
Request("nwfilter_binding_create_xml", {"xml": as_xml(binding), "flags": flags})
|
|
63
|
+
)
|
|
64
|
+
return (
|
|
65
|
+
yield from fetch_model("nwfilter_binding_get_xml_desc", created, FilterBinding)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def delete_nwfilter_binding(binding: NwFilterBindingRef) -> Operation[None]:
|
|
70
|
+
"""Remove the network filter of a port device.
|
|
71
|
+
|
|
72
|
+
:param binding: the name of the port device, or a ``FilterBinding``.
|
|
73
|
+
"""
|
|
74
|
+
yield from on_nwfilter_binding(binding, "nwfilter_binding_delete")
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Operations on secrets."""
|
|
2
|
+
|
|
3
|
+
from libvirtpy.client.operations._common import (
|
|
4
|
+
as_xml,
|
|
5
|
+
fetch_model,
|
|
6
|
+
fetch_models,
|
|
7
|
+
many_handles,
|
|
8
|
+
one_handle,
|
|
9
|
+
)
|
|
10
|
+
from libvirtpy.client.references import (
|
|
11
|
+
SecretRef,
|
|
12
|
+
secret_lookup,
|
|
13
|
+
)
|
|
14
|
+
from libvirtpy.client.transport import Operation, Request
|
|
15
|
+
from libvirtpy.xml.secret import Secret
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"define_secret",
|
|
19
|
+
"get_secret_value",
|
|
20
|
+
"list_secrets",
|
|
21
|
+
"lookup_secret",
|
|
22
|
+
"set_secret_value",
|
|
23
|
+
"undefine_secret",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def lookup_secret(secret: SecretRef) -> Operation[Secret]:
|
|
28
|
+
"""Return the description of a secret (not its value).
|
|
29
|
+
|
|
30
|
+
:param secret: a UUID, as text or ``UUID``, or a ``Secret`` model.
|
|
31
|
+
:returns: the secret.
|
|
32
|
+
:raises NoSecretError: if there is no such secret.
|
|
33
|
+
"""
|
|
34
|
+
handle = yield from one_handle(secret_lookup(secret))
|
|
35
|
+
return (yield from fetch_model("secret_get_xml_desc", handle, Secret))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def list_secrets() -> Operation[list[Secret]]:
|
|
39
|
+
"""Return the secrets.
|
|
40
|
+
|
|
41
|
+
:returns: the secrets, without their values.
|
|
42
|
+
"""
|
|
43
|
+
handles = yield from many_handles(
|
|
44
|
+
Request("connect_list_all_secrets", {"need_results": 1, "flags": 0})
|
|
45
|
+
)
|
|
46
|
+
return (yield from fetch_models("secret_get_xml_desc", handles, Secret))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def define_secret(secret: Secret | str, *, flags: int = 0) -> Operation[Secret]:
|
|
50
|
+
"""Define (or redefine) a secret.
|
|
51
|
+
|
|
52
|
+
:param secret: the description, as a model or XML text.
|
|
53
|
+
:param flags: reserved, ``0``.
|
|
54
|
+
:returns: the stored description, with the UUID libvirt chose if none was given.
|
|
55
|
+
"""
|
|
56
|
+
xml = as_xml(secret)
|
|
57
|
+
handle = yield from one_handle(
|
|
58
|
+
Request("secret_define_xml", {"xml": xml, "flags": flags})
|
|
59
|
+
)
|
|
60
|
+
return (yield from fetch_model("secret_get_xml_desc", handle, Secret))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def undefine_secret(secret: SecretRef) -> Operation[None]:
|
|
64
|
+
"""Remove a secret and its value.
|
|
65
|
+
|
|
66
|
+
:param secret: the secret.
|
|
67
|
+
"""
|
|
68
|
+
handle = yield from one_handle(secret_lookup(secret))
|
|
69
|
+
yield Request("secret_undefine", {"secret": handle})
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def set_secret_value(secret: SecretRef, value: bytes) -> Operation[None]:
|
|
73
|
+
"""Store the value of a secret.
|
|
74
|
+
|
|
75
|
+
:param secret: the secret.
|
|
76
|
+
:param value: the value, e.g. a passphrase or a key.
|
|
77
|
+
"""
|
|
78
|
+
handle = yield from one_handle(secret_lookup(secret))
|
|
79
|
+
yield Request("secret_set_value", {"secret": handle, "value": value, "flags": 0})
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def get_secret_value(secret: SecretRef) -> Operation[bytes]:
|
|
83
|
+
"""Read the value of a secret.
|
|
84
|
+
|
|
85
|
+
:param secret: the secret.
|
|
86
|
+
:returns: the value.
|
|
87
|
+
:raises OperationInvalidError: if the secret is private.
|
|
88
|
+
"""
|
|
89
|
+
handle = yield from one_handle(secret_lookup(secret))
|
|
90
|
+
reply = yield Request("secret_get_value", {"secret": handle, "flags": 0})
|
|
91
|
+
if not isinstance(reply, bytes):
|
|
92
|
+
raise TypeError(f"expected bytes, got {reply!r}")
|
|
93
|
+
return reply
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Operations that find secrets by what they are used for."""
|
|
2
|
+
|
|
3
|
+
from libvirtpy.client.operations._common import fetch_model, one_handle
|
|
4
|
+
from libvirtpy.client.transport import Operation, Request
|
|
5
|
+
from libvirtpy.xml.secret import Secret
|
|
6
|
+
|
|
7
|
+
__all__ = ["lookup_secret_by_usage"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def lookup_secret_by_usage(usage_type: int, usage_id: str) -> Operation[Secret]:
|
|
11
|
+
"""Find a secret by its usage.
|
|
12
|
+
|
|
13
|
+
:param usage_type: ``virSecretUsageType``: 1 volume, 2 ceph, 3 iscsi, 4 tls,
|
|
14
|
+
5 vtpm.
|
|
15
|
+
:param usage_id: the usage identifier: a volume path, a ceph user name, ...
|
|
16
|
+
:returns: the secret.
|
|
17
|
+
:raises NoSecretError: if there is none.
|
|
18
|
+
"""
|
|
19
|
+
found = yield from one_handle(
|
|
20
|
+
Request(
|
|
21
|
+
"secret_lookup_by_usage", {"usage_type": usage_type, "usage_id": usage_id}
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
return (yield from fetch_model("secret_get_xml_desc", found, Secret))
|