Merge "Update docs to use Identity v3"

This commit is contained in:
Jenkins 2016-08-18 12:43:24 +00:00 committed by Gerrit Code Review
commit 96f4e0e763
2 changed files with 48 additions and 11 deletions

View File

@ -30,10 +30,23 @@ Basic Usage
-----------
In order to use the CLI, you must provide your OpenStack username, password,
tenant, and auth endpoint. Use the corresponding configuration options
(``--os-username``, ``--os-password``, ``--os-tenant-name``, and
project, domain information for both user and project, and auth endpoint. Use
the corresponding configuration options (``--os-username``, ``--os-password``,
``--os-project-name``, ``--os-user-domain-id``, ``os-project-domain-id``, and
``--os-auth-url``), but it is easier to set them in environment variables.
.. code-block:: shell
export OS_USERNAME=user
export OS_PASSWORD=pass
export OS_PROJECT_NAME=project
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_DOMAIN_ID=default
export OS_AUTH_URL=http://auth.example.com:5000/v3
If you are using Identity v2.0 API (DEPRECATED), you don't need to pass domain
information.
.. code-block:: shell
export OS_USERNAME=user

View File

@ -26,19 +26,43 @@ neutronclient Python API
Basic Usage
-----------
First create a client instance.
First create a client instance using a keystoneauth Session. For more
information on this keystoneauth API, see `Using Sessions`_.
.. _Using Sessions: http://docs.openstack.org/developer/keystoneauth/using-sessions.html
.. code-block:: python
>>> from keystoneauth1 import identity
>>> from keystoneauth1 import session
>>> from neutronclient.v2_0 import client
>>> username='adminUser'
>>> password='secretword'
>>> project_name='openstackDemo'
>>> auth_url='http://192.168.206.130:5000/v2.0'
>>> neutron = client.Client(username=username,
... password=password,
... project_name=project_name,
... auth_url=auth_url)
>>> username='username'
>>> password='password'
>>> project_name='demo'
>>> project_domain_id='default'
>>> user_domain_id='default'
>>> auth_url='http://auth.example.com:5000/v3'
>>> auth = identity.Password(auth_url=auth_url,
... username=username,
... password=password,
... project_name=project_name,
... project_domain_id=project_domain_id,
... user_domain_id=user_domain_id)
>>> sess = session.Session(auth=auth)
>>> neutron = client.Client(session=sess)
If you are using Identity v2.0 API (DEPRECATED), create an auth plugin using
the appropriate parameters and `keystoneauth1.identity` will handle Identity
API version discovery. Then you can create a Session and a Neutronclient just
like the previous example.
.. code-block:: python
>>> auth = identity.Password(auth_url=auth_url,
... username=username,
... password=password,
... project_name=project_name)
>>> # create a Session and a Neutronclient
Now you can call various methods on the client instance.