Change-Id: I56a45b956f46d7ac1b431bc66f839a10c3fbe512
2.1 KiB
Create a Legacy Client Object
All of the legacy client objects can be constructed the same way -
the only difference is the first argument to make_client
.
The examples will use compute
to get a nova client, but
neutron can be accessed instead by replacing compute
with
network
.
To use the legacy python-novaclient
with a Compute
endpoint, instantiate a novaclient.v2.client.Client
object using os-client-config
:
import os_client_config
= os_client_config.make_client(
nova 'compute',
='https://example.com',
auth_url='example-openstack-user',
username='example-password',
password='example-project-name',
project_name='example-region-name') region_name
If you desire a specific micro-version of the Nova API, you can pass
that as the version
parameter:
import os_client_config
= os_client_config.make_client(
nova 'compute',
='2.10',
version='https://example.com',
auth_url='example-openstack-user',
username='example-password',
password='example-project-name',
project_name='example-region-name') region_name
If you authenticate against an endpoint that uses a custom
authentication back end, you must provide the name of the plugin in the
auth_type
parameter.
For instance, the Rackspace public cloud is an OpenStack deployment that has an optional custom authentication back end. While normal keystone password authentication works perfectly well, you may want to use the custom Rackspace keystoneauth API Key plugin found in rackspace-keystoneauth-plugin.
= os_client_config.make_client(
nova 'compute',
='rackspace_apikey',
auth_type='https://example.com',
auth_url='example-openstack-user',
username='example-apikey',
api_key='example-project-name',
project_name='example-region-name') region_name