LXD REST API的异步客户端库
项目描述
asyncLXD是一个基于asyncio的LXD REST API客户端库。
它提供了一个高级API,用于与LXD服务器上的资源交互,例如容器、镜像、网络、配置文件和存储。
LXD服务器可通过asynclxd.remote.Remote类访问,该类公开服务器细节和配置,以及资源集合的访问权限。
集合(如containers、images、profiles、networks等)允许创建和检索资源,这些资源可以进行修改、更新或删除。
例如
from pprint import pprint
from asynclxd import lxc
# get all remotes defined in the client config
remotes = lxc.get_remotes()
async with remotes['local'] as remote:
# fetch all images and print their details
resp = await remote.images.read()
for image in resp:
resp = await image.read()
pprint(resp.metadata)
# image details have been read, now they're also cached (same
# output as above)
pprint(image.details())
# fetch a single container by name
container = await remote.containers.get('c')
pprint(container.details())
# rename it
await container.rename('new-c')
# change some details
await container.update({'description': 'foo'})
# and now delete it
await container.delete()