saltext.incus.utils.incus¶
Client seam for Incus: the single place the extension runs the incus CLI.
Every execution and state function reaches Incus through these helpers rather
than shelling out directly, so a REST backend can later replace the CLI calls
here without touching callers. Reads use incus query (JSON over the REST
path); writes use incus subcommands. Commands are argument lists run without
a shell.
- depends:
incus binary
- saltext.incus.utils.incus.query(path, project=None, ignore_retcode=False)[source]¶
Issue
incus queryagainst a RESTpathand return the parsed JSON.Returns
Nonewhen the query fails andignore_retcodeis set.
- saltext.incus.utils.incus.query_instance(name, project=None)[source]¶
Return the instance dict for
nameorNoneif it does not exist.The dict carries
config,devices,profiles,statusand the expanded variants, exactly as the REST API reports them.
- saltext.incus.utils.incus.list_instances(project=None)[source]¶
Return a list of instance dicts for the project.
- saltext.incus.utils.incus.create_instance(name, image, profiles=None, config=None, devices=None, ephemeral=False, project=None)[source]¶
Create (but do not start) an instance from
image.configis applied at creation;devicesare added afterwards, one per device. Withprofiles=Nonethe Incus default profile applies.
- saltext.incus.utils.incus.delete_instance(name, force=True, project=None)[source]¶
Delete an instance.
forceis required to delete a running instance.
- saltext.incus.utils.incus.stop_instance(name, timeout=30, force=False, project=None)[source]¶
Stop an instance.
forcekills it immediately; otherwisetimeoutseconds are allowed for a clean shutdown.
- saltext.incus.utils.incus.restart_instance(name, timeout=30, force=False, project=None)[source]¶
Restart an instance.
- saltext.incus.utils.incus.set_config(name, key, value, project=None)[source]¶
Set a single instance config key.
- saltext.incus.utils.incus.unset_config(name, key, project=None)[source]¶
Unset a single instance config key.
- saltext.incus.utils.incus.add_device(name, device_name, device_type, options=None, project=None)[source]¶
Add a device to an instance.
optionsis a mapping of the device’s properties (everything other thantype), for example{"source": "/srv/data", "path": "/data"}for a disk device.
- saltext.incus.utils.incus.remove_device(name, device_name, project=None)[source]¶
Remove a device from an instance.
- saltext.incus.utils.incus.exec_in(name, argv, project=None, environment=None, cwd=None, stdin=None)[source]¶
Run
argvinside the instance and return acmd.run_all-style dict.The return code is surfaced, not raised, so callers can inspect it. Runs as the instance’s root user.
- saltext.incus.utils.incus.push_file(name, local_path, remote_path, mode='0600', uid=0, gid=0, recursive=False, create_dirs=True, project=None)[source]¶
Push a file or directory into the instance.
Defaults are deliberately locked down:
0600and root ownership. The target is addressed as<instance><absolute-remote-path>which is how the Incus CLI maps a push onto an instance path.