diff options
| author | Jenkins <jenkins@review.openstack.org> | 2016-08-18 12:43:24 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2016-08-18 12:43:24 +0000 |
| commit | 96f4e0e763e2da3d7ada6da775ca1d4e0b0a5323 (patch) | |
| tree | 24a1973ffdbeea7297fcc2ea114d4c7825e49613 /doc/source | |
| parent | 618bc69660f33f358be70cadc9a4033880fec94e (diff) | |
| parent | 9fc1f4656d42534db30f5dabe30d4d4c052ab551 (diff) | |
| download | python-neutronclient-96f4e0e763e2da3d7ada6da775ca1d4e0b0a5323.tar.gz | |
Merge "Update docs to use Identity v3"
Diffstat (limited to 'doc/source')
| -rw-r--r-- | doc/source/usage/cli.rst | 17 | ||||
| -rw-r--r-- | doc/source/usage/library.rst | 42 |
2 files changed, 48 insertions, 11 deletions
diff --git a/doc/source/usage/cli.rst b/doc/source/usage/cli.rst index 93a5e66..4471ac3 100644 --- a/doc/source/usage/cli.rst +++ b/doc/source/usage/cli.rst @@ -30,14 +30,27 @@ 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 + export OS_PASSWORD=pass export OS_TENANT_NAME=tenant export OS_AUTH_URL=http://auth.example.com:5000/v2.0 diff --git a/doc/source/usage/library.rst b/doc/source/usage/library.rst index 481a08b..8ab601c 100644 --- a/doc/source/usage/library.rst +++ b/doc/source/usage/library.rst @@ -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. |
