From fafed7a4aa1ae90d18f4d4c40d9a45fbe9130df8 Mon Sep 17 00:00:00 2001 From: "Lucas H. Xu" Date: Wed, 23 Nov 2016 12:14:31 -0500 Subject: [PATCH] add an alternative way of authenticating client Change-Id: I8e0745e17f25e53539405cdafc45dc3646dbb1ae --- doc/source/index.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/source/index.rst b/doc/source/index.rst index a23a37048..a87f414bc 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -13,6 +13,21 @@ In order to use the python api directly, you must first obtain an auth token and [] >>>myvol.delete +Alternatively, you can create a client instance using the keystoneauth session API:: + + >>> from keystoneauth1 import loading + >>> from keystoneauth1 import session + >>> from cinderclient import client + >>> 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) + >>> cinder = client.Client(VERSION, session=sess) + >>> cinder.volumes.list() + [] + Command-line Tool ================= 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-id``, and ``--os-auth-url``) or set them in environment variables::