使用asyncio的基本OpenStack异步客户端库
项目描述
AsyncOpenStackClient
简介
《AsyncOpenStackClient》是一个针对OpenStack API的异步REST包装器。它提供了对认证的优雅抽象。有关方法规范,请参阅官方OpenStack文档:https://docs.openstack.org/queens/api/。
安装
使用pip
pip install AsyncOpenStackClient
用法
from asyncopenstackclient import NovaClient, GlanceClient, CinderClient, AuthPassword
# you can either pass credentials explicitly (as shown below)
# or use environmental variables from OpenStack RC file
# https://docs.openstack.org/mitaka/cli-reference/common/cli_set_environment_variables_using_openstack_rc.html
auth = AuthPassword(
auth_url='https://keystone:5999/v3'
username='USER', password='PASS',
project_name='my-project',
user_domain_name='default',
project_domain_name='foo.bar'
)
# alternatively you can also use application_credentials to authenticate with the OpenStack Keystone API
# https://docs.openstack.org/keystone/queens/user/application_credentials.html
alternative_auth = AuthPassword(
auth_url='https://keystone:5999/v3'
application_credential_id="ID",
application_credential_secret="SECRET"
)
nova = NovaClient(session=auth)
glance = GlanceClient(session=auth)
cinder = CinderClient(session=auth)
# api url for each service will be taken from catalog,
# but you may pass `api_url` param to force custom url eg.
# nova = NovaClient(session=auth, api_url='http://my-local-nova:9876/v2/')
await nova.init_api()
await glance.init_api()
await cinder.init_api()
servers = await nova.servers.list(name='testvm')
vm = await nova.servers.get(server_id)
action_spec = {'os-stop': None}
await nova.servers.run_action(server_id, **action_spec)
specs = {
"name": 'some_name',
"flavorRef": 'flavor_id',
"imageRef": 'image_id',
"security_groups": [{'name': 'group1'}, {'name': 'group2'}]
"user_data": base64.b64encode(userdata).decode('utf-8')
}
response = await nova.servers.create(server=specs)
print(response)
volume = {"size": 200,
"imageRef": "image_id",
"name": "some_name"}
response = await cinder.volumes.create(volume=volume)
print(response)
可用函数
Nova (https://developer.openstack.org/api-ref/compute)
servers.list(optional=filter) # 可选参数
servers.get(id)
servers.create(server=server_spec)
servers.force_delete(id)
servers.run_action(id, action=action_spec)
flavors.list()
metadata.get(server_id)
metadata.set(server_id, meta=meta_spec)
metadata.get_item(server_id, item_name)
metadata.set_item(server_id, item_name, meta=meta_spec)
Glance (https://developer.openstack.org/api-ref/image/v2/index.html)
images.list()
Cinder (https://developer.openstack.org/api-ref/block-storage/v3/index.html)
volumes.list(optional=filter) # 可选参数
volumes.get(id)
volumes.create(volume=volume_spec)
volumes.force_delete(id)
许可证
变更日志
0.9.0 (2022-06-06)
修复:升级urllib3
特性:支持应用程序凭证
0.8.2 (2021-03-28)
修复:升级依赖项(aiohttp)
0.8.1 (2019-04-03)
修复:升级依赖项(urllib3:CVE-2018-20060)
0.8.0 (2018-08-19)
特性:计算API的另一部分 - 在服务器上运行操作
特性:CD配置
0.7.0 (2018-06-15)
特性:Cinder实现
错误修复:拼写错误
0.6.3 (2018-06-13)
特性:可调整请求超时,默认为60秒
0.6.2 (2018-05-18)
错误修复:在Client中初始化属性(api)以获取一些有意义的错误,而不是“递归限制达到”。
0.6.0 (2018-05-12)
特性:使用Resource/Method代理包装请求
0.5.2 (2018-05-10)
错误修复:在api_root_url末尾添加斜杠
0.5.1 (2018-04-29)
错误修复:更新README,包括元数据和环境说明
0.5.0 (2018-04-25)
特性:部分支持服务器元数据使用
0.4.1 (2018-04-25)
错误修复:无效地使用urljoin连接auth_url
0.4.0 (2018-04-16)
特性:如果存在,则使用OS_变量
0.3.0 (2018-04-13)
特性:接受传递api_url
特性:如果目录提供不完整的api_url(例如,没有版本),则确定api_url
0.2.3 (2018-04-05)
错误修复:do_not_await_sync_method
0.2.2 (2018-04-02)
更新simple-rest-client(修复日志记录)
0.2.1 (2018-03-28)
修复测试,覆盖率报告,MANIFEST.in
0.1.1 (2018-03-02)
更新MANIFEST.in
0.1.0 (2018-02-15)
为Python3构建异步OpenStack客户端库的第一个尝试
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定要选择哪个,请了解更多关于安装包的信息。
源代码发行版
AsyncOpenStackClient-0.9.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9910744b6350ab4059216a3bddb98a1eb79f591d4627164ce98ac68be919d254 |
|
MD5 | c7ec35f6ce34547ed35f5f330019f86c |
|
BLAKE2b-256 | 21992cc66cd9df159f69dbc72b56f50f977da7d8c7b4496c750b06132a22f699 |