craft_providers.lxd.lxd module

LXD command-line interface helpers.

class craft_providers.lxd.lxd.LXD(*, lxd_path=PosixPath('lxd'))[source]

Bases: object

Interface to lxd command-line.

Parameters

lxd_path (Path) – Path to lxd.

Variables

minimum_required_version – Minimum lxd version required for compatibility.

init(*, auto=False, sudo=False)[source]

Initialize LXD.

Sudo is required if user is not in lxd group.

Parameters
  • auto (bool) – Use default settings.

  • sudo (bool) – Use sudo to invoke init.

Return type

None

is_supported_version()[source]

Check if LXD version is supported.

A helper to check if LXD meets minimum supported version for craft-providers (currently >= 4.0).

Return type

bool

Returns

True if installed version is supported.

minimum_required_version = '4.0'
version()[source]

Query LXD version.

The version is of the format: <major>.<minor>[.<micro>]

Version examples: - 4.13 - 4.0.5 - 2.0.12

Return type

str

Returns

Version string.

wait_ready(*, sudo=False, timeout=None)[source]

Wait until LXD is ready.

Sudo is required if user is not in lxd group.

Parameters
  • sudo (bool) – Use sudo to invoke waitready.

  • timeout (Optional[int]) – Timeout in seconds.

Return type

None