Fix doc on keystoneauth session api usage

This fixes documentation on client creation with keystoneauth
session api.

Change-Id: I0f6bb6f4f9bbaa84b5185c0a9e9db6a4184702d4
Partial-Bug: #1646539
This commit is contained in:
rabi 2016-12-08 12:48:58 +05:30
parent 1eb72804d6
commit 3d60183120
1 changed files with 12 additions and 7 deletions

View File

@ -22,18 +22,23 @@ Once you have done so, you can use the API like so::
Alternatively, you can create a client instance using the keystoneauth session API::
>>> from keystoneauth1 import loading
>>> from keystoneauth1 import session
>>> from keystoneauth1.identity import v3
>>> from heatclient import client
>>> password = v3.PasswordMethod(username=USERNAME,
... password=PASSWORD,
... user_domain_name=DEFAULT)
>>> auth = v3.Auth(auth_url=AUTH_URL, auth_methods=[password],
... project_id=PROJECT_ID)
>>> loader = loading.get_plugin_loader('password')
>>> auth = loader.load_from_options(auth_url=AUTH_URL,
... username=USERNAME,
... password=PASSWORD,
... project_id=PROJECT_ID)
>>> sess = session.Session(auth=auth)
>>> heat = client.Client('1', endpoint=heat_url, session=sess)
>>> heat = client.Client('1', session=sess)
>>> heat.stacks.list()
If you have PROJECT_NAME instead of a PROJECT_ID, use the project_name
parameter. Similarly, if your cloud uses keystone v3 and you have a DOMAIN_NAME
or DOMAIN_ID, provide it as `user_domain_(name|id)` and if you are using a
PROJECT_NAME also provide the domain information as `project_domain_(name|id)`.
For more information on keystoneauth API, see `Using Sessions`_.
.. _Using Sessions: http://docs.openstack.org/developer/keystoneauth/using-sessions.html