lxd module¶
LxdContainer
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The container's name. |
|
status |
The container's status ( |
|
type |
The instance type ( |
|
ipv4 |
The container's IPv4 address, empty when unassigned. |
|
ipv6 |
The container's IPv6 address, empty when unassigned. |
|
snapshots |
The number of snapshots the container holds. |
LxdContainers
¶
The fast listing of LXD containers on the local daemon.
Commands:
lxc list --format json --fast
Returns:
list[LxdContainer]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_containers.py.
LxdImage
¶
Attributes:
| Name | Type | Description |
|---|---|---|
fingerprint |
The image's full SHA-256 fingerprint (64 hex chars). |
|
aliases |
The aliases pointing at the image, each a dict with
|
|
filename |
The original image file name, empty for copies. |
|
size |
The image size in bytes. |
|
type |
The instance type the image creates ( |
|
public |
Whether the image is publicly readable. |
|
auto_update |
Whether the image auto-updates from its source. |
|
properties |
The image properties ( |
|
update_source |
The remote the image updates from, when auto-update is enabled. |
|
created_at |
The image build timestamp (RFC 3339). |
|
uploaded_at |
The local cache timestamp (RFC 3339). |
|
expires_at |
The expiry timestamp (RFC 3339). |
|
cached |
Whether the image is a cached remote copy. |
|
profiles |
The profiles baked into the image. |
LxdImageAlias
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The alias name, e.g. |
|
description |
The alias description, empty when unset. |
|
target |
The fingerprint the alias points at. |
|
type |
The alias target type (always |
LxdImageAliases
¶
The image aliases and the fingerprints they point at.
Commands:
lxc image alias list [<remote>:] --format json [--project <project>]
Returns:
list[LxdImageAlias]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_image_aliases.py.
LxdImages
¶
The images cached in the local (or a remote) image store.
Commands:
lxc image list [<remote>:] --format json [--project <project>]
Returns:
list[LxdImage]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_images.py.
LxdInstance
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The instance name. |
|
description |
The instance description, empty when unset. |
|
status |
The instance status ( |
|
status_code |
The LXD numeric status code (103 Running, 102 Stopped, 110 Frozen, ...). |
|
type |
The instance type ( |
|
architecture |
The instance architecture, e.g. |
|
ephemeral |
Whether the instance is deleted when it stops. |
|
stateful |
Whether the instance's state was saved at stop. |
|
location |
The cluster member hosting the instance ( |
|
created_at |
The creation timestamp (RFC 3339). |
|
last_used_at |
The last-start timestamp (RFC 3339). |
|
config |
The instance's OWN configuration keys, including the
|
|
devices |
The instance's OWN devices, keyed by device name,
each a dict with a |
|
expanded_config |
The configuration with profile inheritance applied (present on full listings and expanded reads). |
|
expanded_devices |
The devices with profile inheritance applied. |
|
profiles |
The profile names applied to the instance, in order. |
LxdInstanceConfig
¶
One instance's configuration, with profile inheritance expanded.
Commands:
lxc config show <remote>:<instance> --expanded --format json [--project <project>] 2>/dev/null || true
Returns:
LxdInstance | None
Raises:
HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_instance_config.py.
LxdInstanceSnapshots
¶
The snapshots of one LXD instance.
Commands:
lxc info <remote>:<instance> --format json [--project <project>] 2>/dev/null || true
Returns:
list[LxdSnapshot]
Raises:
HostConnectionError
Examples:
Examples can be found in
examples/modules/lxd/lxd_lxd_instance_snapshots.py.
LxdInstanceState
¶
One instance's runtime state: status, PID, memory and network.
Commands:
lxc info <remote>:<instance> --format json [--project <project>] 2>/dev/null || true
Returns:
LxdInstanceStateData | None
Raises:
HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_instance_state.py.
LxdInstanceStateData
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The instance name. |
|
status |
The runtime status ( |
|
type |
The instance type ( |
|
architecture |
The instance architecture. |
|
pid |
The init process ID; absent or 0 when stopped. |
|
processes |
The number of processes; absent when stopped. |
|
cpu |
CPU usage counters ( |
|
memory |
Memory usage gauges ( |
|
network |
Per-interface runtime state keyed by interface name,
each with |
|
disk |
Per-disk usage gauges keyed by device name; absent when stopped. |
|
snapshots |
The instance's snapshots (the same entries
|
LxdInstances
¶
All LXD instances (containers and VMs) with full metadata.
Commands:
lxc list [<remote>:] --format json [--project <project>]
Returns:
list[LxdInstance]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_instances.py.
LxdNetwork
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The network name, e.g. |
|
description |
The network description, empty when unset. |
|
type |
The network type ( |
|
managed |
Whether LXD manages the network (an unmanaged entry is a host interface LXD merely knows about). |
|
status |
The network status ( |
|
config |
The network configuration ( |
|
locations |
The cluster members the network exists on
( |
LxdNetworks
¶
The networks LXD knows about, managed and unmanaged.
Commands:
lxc network list [<remote>:] --format json [--project <project>]
Returns:
list[LxdNetwork]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_networks.py.
LxdOperation
¶
Attributes:
| Name | Type | Description |
|---|---|---|
id |
The operation UUID. |
|
description |
The human-readable description, e.g.
|
|
status |
The operation status ( |
|
status_code |
The LXD numeric status code (103 Running, 200 Success, 400 Failure, ...). |
|
created_at |
The creation timestamp (RFC 3339). |
|
updated_at |
The last-update timestamp (RFC 3339). |
|
resources |
The resources the operation touches, keyed by
resource type ( |
|
may_cancel |
Whether the operation can be cancelled. |
|
err |
The error message, empty unless the operation failed. |
LxdOperations
¶
The background operations currently registered on the daemon.
Commands:
lxc operation list [<remote>:] --format json
Returns:
list[LxdOperation]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_operations.py.
LxdProfile
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The profile name, e.g. |
|
description |
The profile description, empty when unset. |
|
config |
The profile's configuration keys (limits, security policies, ...). |
|
devices |
The profile's devices keyed by device name, each a
dict with a |
|
used_by |
The instance URLs applying the profile (present on some server versions). |
LxdProfiles
¶
The configuration profiles with their config and devices.
Commands:
lxc profile list [<remote>:] --format json [--project <project>]
Returns:
list[LxdProfile]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_profiles.py.
LxdProject
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The project name, e.g. |
|
description |
The project description, empty when unset. |
|
config |
The project configuration ( |
|
used_by |
The resource URLs living in the project. |
LxdProjectConfig
¶
One project's configuration document.
Commands:
lxc project show <remote>:<project> --format json 2>/dev/null || true
Returns:
LxdProject | None
Raises:
HostConnectionError
Examples:
Examples can be found in
examples/modules/lxd/lxd_lxd_project_config.py.
LxdProjects
¶
The projects defined on the LXD server.
Commands:
lxc project list [<remote>:] --format json
Returns:
list[LxdProject]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_projects.py.
LxdServerInfo
¶
The LXD daemon's metadata, environment and API extensions.
Commands:
lxc info [<remote>:] --format json
Returns:
LxdServerInfoData
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_server_info.py.
LxdServerInfoData
¶
Attributes:
| Name | Type | Description |
|---|---|---|
server |
The server implementation name ( |
|
server_name |
The server's host name. |
|
server_version |
The server version string, e.g. |
|
server_pid |
The daemon's process ID. |
|
server_clustered |
Whether the server is part of a cluster. |
|
server_lts |
Whether the server is an LTS release. |
|
server_event_mode |
The cluster event distribution mode. |
|
api_version |
The REST API version, e.g. |
|
api_status |
The API stability status ( |
|
api_extensions |
The supported API extension names -- the feature-gating list operations and playbooks check before using extension-dependent features. |
|
auth |
The caller's authentication state ( |
|
auth_user_name |
The authenticated user name. |
|
auth_user_method |
The authentication method ( |
|
public |
Whether the server is exposed publicly. |
|
config |
The daemon's configuration keys. |
|
environment |
The server environment (kernel, OS, storage driver, LXC version, addresses, ...); dynamic keys keep a plain dict. |
LxdServerResources
¶
The hardware resources of the LXD host: CPU, memory, GPU, disks.
Commands:
lxc info [<remote>:] --resources --format json
Returns:
LxdServerResourcesData
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in
examples/modules/lxd/lxd_lxd_server_resources.py.
LxdServerResourcesData
¶
Attributes:
| Name | Type | Description |
|---|---|---|
cpu |
The CPU topology ( |
|
memory |
The memory gauges ( |
|
gpu |
The graphics cards ( |
|
network |
The network interfaces ( |
|
storage |
The storage devices ( |
|
system |
The system identity (vendor, product, UUID, firmware, chassis, motherboard). |
|
usb |
The USB devices ( |
|
pci |
The PCI devices ( |
LxdSnapshot
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The snapshot name (the part after |
|
description |
The snapshot description, empty when unset. |
|
created_at |
The creation timestamp (RFC 3339). |
|
expires_at |
The expiry timestamp (RFC 3339); the zero time when the snapshot never expires. |
|
stateful |
Whether the snapshot includes the runtime state. |
LxdStoragePool
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The pool name, e.g. |
|
description |
The pool description, empty when unset. |
|
driver |
The storage driver ( |
|
status |
The pool status ( |
|
config |
The pool configuration ( |
|
locations |
The cluster members the pool exists on
( |
LxdStoragePools
¶
The storage pools configured on the LXD server.
Commands:
lxc storage list [<remote>:] --format json
Returns:
list[LxdStoragePool]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_lxd_storage_pools.py.
LxdStorageVolume
¶
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The volume name. |
|
description |
The volume description, empty when unset. |
|
type |
The volume type ( |
|
content_type |
The content type ( |
|
config |
The volume configuration ( |
|
location |
The cluster member holding the volume. |
|
created_at |
The creation timestamp (RFC 3339). |
|
used_by |
The instance URLs attaching the volume. |
LxdStorageVolumes
¶
The volumes in one storage pool, custom and instance-managed.
Commands:
lxc storage volume list <remote>:<pool> --format json [--project <project>] 2>/dev/null || true
Returns:
list[LxdStorageVolume]
Raises:
HostConnectionError
Examples:
Examples can be found in
examples/modules/lxd/lxd_lxd_storage_volumes.py.
container
async
¶
container(
ctx: OpContext,
id: str,
present: bool = True,
image: str = "ubuntu:16.04",
**kwargs: Any,
) -> AsyncGenerator[Command]
Add or remove an LXD container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
id
|
str
|
Name/identifier for the container. |
required |
present
|
bool
|
Whether the container should exist. Defaults to True. |
True
|
image
|
str
|
Image to base the container on. Defaults to "ubuntu:16.04". |
'ubuntu:16.04'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD container commands. |
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/lxd/lxd_container.py.
image
async
¶
image(
ctx: OpContext,
image: str,
present: bool = True,
source: str = "",
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Cache an LXD image locally or remove it from the image store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
image
|
str
|
The image alias (e.g. |
required |
present
|
bool
|
Whether the image should be cached. Defaults to True. |
True
|
source
|
str
|
The remote image reference to copy
from when caching, e.g. |
''
|
remote
|
str
|
The configured lxc remote whose image store to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project whose image store to manage. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD image commands. |
Raises:
CommandNotFoundError, HostConnectionError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_image.py.
image_alias
async
¶
image_alias(
ctx: OpContext,
alias: str,
fingerprint: str = "",
present: bool = True,
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Point an LXD image alias at a fingerprint, or remove the alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
alias
|
str
|
The alias name to manage, e.g. |
required |
fingerprint
|
str
|
The image fingerprint the alias should target; required when present=True. Defaults to "". |
''
|
present
|
bool
|
Whether the alias should exist. Defaults to True. |
True
|
remote
|
str
|
The configured lxc remote whose alias to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project whose alias to manage. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD image alias commands. |
Raises:
CommandNotFoundError, HostConnectionError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_image_alias.py.
instance
async
¶
instance(
ctx: OpContext,
instance: str,
present: bool = True,
image: str = "images:ubuntu/24.04",
instance_type: str = "container",
profiles: tuple[str, ...] = (),
config: tuple[str, ...] = (),
devices: tuple[
tuple[str, str, tuple[str, ...]], ...
] = (),
ephemeral: bool = False,
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Ensure an LXD container or VM exists with the desired configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
instance
|
str
|
The instance name to manage. |
required |
present
|
bool
|
Whether the instance should exist. Defaults to True. |
True
|
image
|
str
|
The image reference to launch from,
e.g. |
'images:ubuntu/24.04'
|
instance_type
|
str
|
|
'container'
|
profiles
|
tuple[str, ...]
|
The profiles to apply, in order; empty leaves the project default. Defaults to (). |
()
|
config
|
tuple[str, ...]
|
Configuration entries as
|
()
|
devices
|
tuple[tuple[str, str, tuple[str, ...]], ...]
|
Devices as |
()
|
ephemeral
|
bool
|
Whether the instance is deleted when it stops (creation-only). Defaults to False. |
False
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project to manage the instance in. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD instance commands. |
Raises:
CommandNotFoundError, HostConnectionError, OperationError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_instance.py.
instance_config
async
¶
instance_config(
ctx: OpContext,
instance: str,
config: tuple[str, ...] = (),
devices: tuple[
tuple[str, str, tuple[str, ...]], ...
] = (),
profiles: tuple[str, ...] | None = None,
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Update an existing LXD instance's config, devices and profiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
instance
|
str
|
The instance to update (must already exist). |
required |
config
|
tuple[str, ...]
|
Configuration entries as
|
()
|
devices
|
tuple[tuple[str, str, tuple[str, ...]], ...]
|
Devices as |
()
|
profiles
|
tuple[str, ...] | None
|
The profile list to assign in order; None leaves the current list alone. Defaults to None. |
None
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project the instance lives in. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD instance configuration commands. |
Raises:
HostConnectionError, OperationError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_instance_config.py.
instance_copy
async
¶
instance_copy(
ctx: OpContext,
instance: str,
dest_instance: str,
dest_remote: str = "",
instance_only: bool = False,
stateless: bool = False,
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Copy an LXD instance to a new name, locally or to another remote.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
instance
|
str
|
The source instance name (must already exist). |
required |
dest_instance
|
str
|
The destination instance name. |
required |
dest_remote
|
str
|
The configured lxc remote to copy to; empty means the same daemon as the source. Defaults to "". |
''
|
instance_only
|
bool
|
Copy without the snapshots. Defaults to False. |
False
|
stateless
|
bool
|
Copy without the source's runtime state. Defaults to False. |
False
|
remote
|
str
|
The configured lxc remote holding the source; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project the source lives in. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD copy commands. |
Raises:
CommandNotFoundError, HostConnectionError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_instance_copy.py.
instance_snapshot
async
¶
instance_snapshot(
ctx: OpContext,
instance: str,
snapshot: str,
present: bool = True,
stateful: bool = False,
restore: bool = False,
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Create, delete or restore an LXD instance snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
instance
|
str
|
The instance to snapshot. |
required |
snapshot
|
str
|
The snapshot name. |
required |
present
|
bool
|
Whether the snapshot should exist. Defaults to True. |
True
|
stateful
|
bool
|
Include the runtime state in the snapshot (or restore it). Defaults to False. |
False
|
restore
|
bool
|
Restore the instance to this snapshot instead of managing its existence; always runs (a restore is an action, not a desired state). Defaults to False. |
False
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project the instance lives in. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD snapshot commands. |
Raises:
HostConnectionError, ValueError
Examples:
Examples can be found in
examples/modules/lxd/lxd_instance_snapshot.py.
instance_state
async
¶
instance_state(
ctx: OpContext,
instance: str,
state: str = "started",
force: bool = False,
timeout: int | None = None,
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Drive an LXD instance's lifecycle state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
instance
|
str
|
The instance to manage (must already exist). |
required |
state
|
str
|
The desired state: |
'started'
|
force
|
bool
|
Force the action (kill on stop, unfreeze on start). Defaults to False. |
False
|
timeout
|
int | None
|
Seconds to wait for a clean shutdown before killing (stop only); None uses the daemon default. Defaults to None. |
None
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project the instance lives in. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD instance state commands. |
Raises:
HostConnectionError, OperationError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_instance_state.py.
network
async
¶
network(
ctx: OpContext,
network: str,
present: bool = True,
network_type: str = "bridge",
config: tuple[str, ...] = (),
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Create, configure or delete an LXD managed network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
network
|
str
|
The network name to manage, e.g. |
required |
present
|
bool
|
Whether the network should exist. Defaults to True. |
True
|
network_type
|
str
|
The network type ( |
'bridge'
|
config
|
tuple[str, ...]
|
Configuration entries as
|
()
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project to manage the network in. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD network commands. |
Raises:
CommandNotFoundError, HostConnectionError, OperationError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_network.py.
operation
async
¶
operation(
ctx: OpContext,
operation_id: str,
cancel: bool = False,
wait: bool = True,
timeout: float = 300.0,
interval: float = 5.0,
remote: str = "",
**kwargs: Any,
) -> AsyncGenerator[Command]
Wait on or cancel an LXD background operation by id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
operation_id
|
str
|
The background operation's UUID. |
required |
cancel
|
bool
|
Cancel the operation if it is still registered. Defaults to False. |
False
|
wait
|
bool
|
Wait for the operation to finish (after cancelling, when both are set). Defaults to True. |
True
|
timeout
|
float
|
Seconds to keep polling before
raising |
300.0
|
interval
|
float
|
Seconds between polls. Defaults to 5.0. |
5.0
|
remote
|
str
|
The configured lxc remote holding the operation; empty means the local daemon. Defaults to "". |
''
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD operation commands. |
Raises:
CommandNotFoundError, HostConnectionError, ValueError, WaitTimeoutError
Examples:
Examples can be found in examples/modules/lxd/lxd_operation.py.
profile
async
¶
profile(
ctx: OpContext,
profile: str,
present: bool = True,
config: tuple[str, ...] = (),
devices: tuple[
tuple[str, str, tuple[str, ...]], ...
] = (),
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Create, update or delete an LXD configuration profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
profile
|
str
|
The profile name to manage. |
required |
present
|
bool
|
Whether the profile should exist. Defaults to True. |
True
|
config
|
tuple[str, ...]
|
Configuration entries as
|
()
|
devices
|
tuple[tuple[str, str, tuple[str, ...]], ...]
|
Devices as |
()
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project to manage the profile in. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD profile commands. |
Raises:
CommandNotFoundError, HostConnectionError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_profile.py.
project
async
¶
project(
ctx: OpContext,
project: str,
present: bool = True,
config: tuple[str, ...] = (),
remote: str = "",
**kwargs: Any,
) -> AsyncGenerator[Command]
Create, configure or delete an LXD project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
project
|
str
|
The project name to manage. |
required |
present
|
bool
|
Whether the project should exist. Defaults to True. |
True
|
config
|
tuple[str, ...]
|
Configuration entries as
|
()
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD project commands. |
Raises:
CommandNotFoundError, HostConnectionError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_project.py.
storage_pool
async
¶
storage_pool(
ctx: OpContext,
pool: str,
present: bool = True,
driver: str = "dir",
config: tuple[str, ...] = (),
remote: str = "",
**kwargs: Any,
) -> AsyncGenerator[Command]
Create, configure or delete an LXD storage pool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
pool
|
str
|
The pool name to manage. |
required |
present
|
bool
|
Whether the pool should exist. Defaults to True. |
True
|
driver
|
str
|
The storage driver ( |
'dir'
|
config
|
tuple[str, ...]
|
Configuration entries as
|
()
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD storage pool commands. |
Raises:
CommandNotFoundError, HostConnectionError, OperationError, ValueError
Examples:
Examples can be found in examples/modules/lxd/lxd_storage_pool.py.
storage_volume
async
¶
storage_volume(
ctx: OpContext,
pool: str,
volume: str,
present: bool = True,
config: tuple[str, ...] = (),
remote: str = "",
project: str = "default",
**kwargs: Any,
) -> AsyncGenerator[Command]
Create or delete a custom LXD storage volume in a pool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
pool
|
str
|
The storage pool holding the volume (must already exist). |
required |
volume
|
str
|
The custom volume name to manage. |
required |
present
|
bool
|
Whether the volume should exist. Defaults to True. |
True
|
config
|
tuple[str, ...]
|
Configuration entries as
|
()
|
remote
|
str
|
The configured lxc remote to manage; empty means the local daemon. Defaults to "". |
''
|
project
|
str
|
The project to manage the volume in. Defaults to "default". |
'default'
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
Generated LXD storage volume commands. |
Raises:
HostConnectionError, OperationError, ValueError
Examples:
Examples can be found in
examples/modules/lxd/lxd_storage_volume.py.