LXD Client
Project description
Async python client for LXD REST API (currently under heavy development).
Usage
Installation
pip install lxd
Initialize client
import asyncio
from pathlib import Path
from yarl import URL
from lxd.client import lxd_client
async def main():
client = lxd_client(
URL('https://mylxd:8443/'),
cert_path=Path('~/.config/lxc/client.crt'),
key_path=Path('~/.config/lxc/client.key'),
endpoint_cert_path=Path('~/.config/lxc/servercerts/mylxd.crt'),
)
await client.authenticate(
cert_path=Path('~/.config/lxc/client.crt'),
password='your-trust-password'
)
asyncio.run(main())
Example usages
# Recursion 0 returns only links to objects,
# you can resolve them by awaiting
instance_links = await client.instances.list(recursion=0)
instance = await instance_links[0]
# Recursion 1 returns only some fields
instances = await client.instances.list(recursion=1)
# Recursion 2 returns all possible information
instances = await client.instances.list(recursion=2)
Change instance state
from lxd.entities.instances import InstanceAction
instances = await client.instances.list()
operation = await client.instances.update_state(
instances[0].name, action=InstanceAction.STOP
)
await client.operations.wait(operation.id) # wait as long as possible
await client.operations.wait(operation.id, timeout=30) # 30s
Available Endpoints
Server
client.server.get
client.server.get_resources
client.update_configuration
client.partial_update_configuration
Certificates
client.certificates.list
client.certificates.add
client.certificates.get
client.certificates.update
client.certificates.partial_update
client.certificates.delete
Instances
client.instances.list
client.instances.get
client.instances.create
client.instances.delete
client.instances.get_state
client.instances.update_state
Operations
client.operations.list
client.operations.get
client.operations.wait
client.operations.cancel
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lxd-0.2.0.tar.gz
(8.0 kB
view details)
File details
Details for the file lxd-0.2.0.tar.gz
.
File metadata
- Download URL: lxd-0.2.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10dd9170e735155732ff9607a2e24817b42e07a01252aec174c289246d899191 |
|
MD5 | c92d3d4d6d63d8f9fa219e4621778b7d |
|
BLAKE2b-256 | 539b952f532cab0557aef2c3748c60e8256aec43a887cff476d6238f071b8853 |