従来からあるクライアントのオブジェクトはいずれも同じ方法で作成できます。唯一の違いは make_client
の最初の引数です。 この例ではnova クライアントを取得するため compute
を使用しますが、 compute
を network
に変えると neutron クライアントが得られます。
従来からある python-novaclient
を Compute エンドポイントで使用するには、 os-client-config
を使って novaclient.v2.client.Client オブジェクトを作成します。
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')
Nova API の特定のマイクロバージョンを使いたい場合は、 version
パラメーターにそのバージョンを指定します。
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')
カスタマイズされた認証バックエンドを使用したエンドポイントに対して認証を行う場合は、 auth_type
パラメーターにプラグイン名を指定しなければいけません。
例えば、 Rackspace パブリッククラウドは独自の認証バックエンドを追加で使用している OpenStack 環境です。通常の keystone パスワード認証はそのまま動作しますが、 Rackspace 独自の keystoneauth API キープラグインを使いたい場合もあるでしょう。 Rackspace 独自の keystoneauth API キープラグインの説明は 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')
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.