craft_providers.lxd.lxd_provider module

LXD Provider class.

class craft_providers.lxd.lxd_provider.LXDProvider(*, lxc=<craft_providers.lxd.lxc.LXC object>, lxd_project='default', lxd_remote='local')[source]

Bases: craft_providers.provider.Provider

LXD build environment provider.

This class is not stable and is likely to change. This class will be stable and recommended for use in the release of craft-providers 2.0.

Parameters
  • lxc (LXC) – Optional lxc client to use.

  • lxd_project (str) – LXD project to use (default is default).

  • lxd_remote (str) – LXD remote to use (default is local).

create_environment(*, instance_name)[source]

Create a bare environment for specified base.

No initializing, launching, or cleaning up of the environment occurs.

Parameters

instance_name (str) – Name of the instance.

Return type

Executor

classmethod ensure_provider_is_available()[source]

Ensure provider is available and ready, installing if required.

Raises
Return type

None

classmethod is_provider_installed()[source]

Check if provider is installed.

Return type

bool

Returns

True if installed.

launched_environment(*, project_name, project_path, base_configuration, build_base, instance_name)[source]

Configure and launch environment for specified base.

When this method loses context, all directories are unmounted and the environment is stopped. For more control of environment setup and teardown, use create_environment() instead.

Parameters
  • project_name (str) – Name of project.

  • project_path (Path) – Path to project.

  • base_configuration (Base) – Base configuration to apply to instance.

  • build_base (str) – Base to build from.

  • instance_name (str) – Name of the instance to launch.

Raises

LXDError – if instance cannot be configured and launched

Return type

Generator[Executor, None, None]