The AsyncOpenStackClient is a rest wrapper for the OpenStack API. It provides very raw functionality; however, it has a nice abstraction for authetication. For method specification, see the official OpenStack documentation: https://docs.openstack.org/queens/api/.
Use pip:
pip install AsyncOpenStackClient
As mentioned above, this is a "raw" library, so you must handle params and/or body and the response.
from asyncopenstackclient import NovaClient, GlanceClient, AuthPassword
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'
)
nova = NovaClient(session=auth)
glance = GlanceClient(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()
servers = await nova.api.servers.list(params={'name': 'testvm'})
vm = await nova.api.servers.get(id)
body = {
"server": {
"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.api.servers.create(body=body)
print(response.body)- Nova (https://developer.openstack.org/api-ref/compute)
- servers.list(params) # params optional
- servers.get(id)
- servers.create(body)
- servers.force_delete(id)
- flavors.list()
- Glance (https://developer.openstack.org/api-ref/image/v2/index.html)
- images.list()
