openstack-manuals/doc/user-guide/source/sdk-create-legacy-novaclient.rst
Maria Zlatkova b94d0b58d4 [user-guide] Changes underscore to hyphen in RST files
Adds the following changes:

- Renames all the RST files in the user-guide folder to use
  hyphens instead of underscores;
- Adds redirects to the renamed files to .htaccess.

Change-Id: Ic5f1a90421add35d001363cd39bada0b56a04d7f
Implements: blueprint consistency-file-rename
2016-08-10 18:00:13 +03:00

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

nova = os_client_config.make_client(
    'compute',
    auth_url='https://example.com',
    username='example-openstack-user',
    password='example-password',
    project_name='example-project-name',
    region_name='example-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

nova = os_client_config.make_client(
    'compute',
    version='2.10',
    auth_url='https://example.com',
    username='example-openstack-user',
    password='example-password',
    project_name='example-project-name',
    region_name='example-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.

nova = os_client_config.make_client(
    'compute',
    auth_type='rackspace_apikey',
    auth_url='https://example.com',
    username='example-openstack-user',
    api_key='example-apikey',
    project_name='example-project-name',
    region_name='example-region-name')