From a3ac46644889e460f3f9e3fe89a87296d2a4ac8a Mon Sep 17 00:00:00 2001 From: Michael Ionkin Date: Wed, 27 Jan 2016 17:14:45 +0300 Subject: [PATCH] Keystoneclient to keystoneauth migration Keystoneauth was extracted from keystoneclient so we need to migrate to keystoneauth also deleted get_projects_list method because it is not used Change-Id: I2c611d6b5ae08eacc11513e0dd2548e42b9dc828 bp: keystoneclient-to-keystoneauth --- doc/source/api.rst | 8 ++++---- requirements.txt | 1 + saharaclient/api/client.py | 20 ++++++-------------- saharaclient/shell.py | 14 +++++++------- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index 10f08384..f49e6637 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -33,8 +33,8 @@ Session object should be used for this purpose. For example: .. sourcecode:: python - from keystoneclient.auth.identity import v2 - from keystoneclient import session + from keystoneauth1.identity import v2 + from keystoneauth1 import session from saharaclient import client auth = v2.Password(auth_url=AUTH_URL, @@ -62,8 +62,8 @@ default values. .. sourcecode:: python - from keystoneclient.auth.identity import v2 - from keystoneclient import session + from keystoneauth1.identity import v2 + from keystoneauth1 import session from saharaclient import client auth = v2.Password(auth_url=AUTH_URL, diff --git a/requirements.txt b/requirements.txt index 1a87ffcd..a218e041 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ pbr>=1.6 # Apache-2.0 Babel>=1.3 # BSD cliff!=1.16.0,>=1.15.0 # Apache-2.0 +keystoneauth1>=2.1.0 # Apache-2.0 oslo.log>=1.14.0 # Apache-2.0 oslo.serialization>=1.10.0 # Apache-2.0 oslo.i18n>=2.1.0 # Apache-2.0 diff --git a/saharaclient/api/client.py b/saharaclient/api/client.py index 0343a7ce..1fd7602f 100644 --- a/saharaclient/api/client.py +++ b/saharaclient/api/client.py @@ -15,13 +15,12 @@ import warnings -from keystoneclient import adapter -from keystoneclient.auth.identity import v2 -from keystoneclient.auth.identity import v3 -from keystoneclient.auth import token_endpoint -from keystoneclient import exceptions -from keystoneclient import session as keystone_session -from keystoneclient.v2_0 import client as keystone_client_v2 +from keystoneauth1 import adapter +from keystoneauth1 import exceptions +from keystoneauth1.identity import v2 +from keystoneauth1.identity import v3 +from keystoneauth1 import session as keystone_session +from keystoneauth1 import token_endpoint from saharaclient.api import cluster_templates from saharaclient.api import clusters @@ -187,10 +186,3 @@ class Client(object): return st raise RuntimeError("Could not find Sahara endpoint in catalog") - - @staticmethod - def get_projects_list(keystone_client): - if isinstance(keystone_client, keystone_client_v2.Client): - return keystone_client.tenants - - return keystone_client.projects diff --git a/saharaclient/shell.py b/saharaclient/shell.py index 682b8085..b0236ebe 100644 --- a/saharaclient/shell.py +++ b/saharaclient/shell.py @@ -48,10 +48,10 @@ try: except ImportError: pass -from keystoneclient.auth.identity.generic import password -from keystoneclient.auth.identity.generic import token +from keystoneauth1.identity.generic import password +from keystoneauth1.identity.generic import token +from keystoneauth1.loading import session from keystoneclient.auth.identity import v3 as identity -from keystoneclient import session from oslo_utils import encodeutils from oslo_utils import strutils @@ -354,8 +354,8 @@ class OpenStackSaharaShell(object): default=cliutils.env('OS_AUTH_TOKEN'), help='Defaults to env[OS_AUTH_TOKEN].') - # Use Keystoneclient API to parse authentication arguments - session.Session.register_cli_options(parser) + # Use Keystoneclient/Keystoneauth API to parse authentication arguments + session.Session().register_argparse_arguments(parser) identity.Password.register_argparse_arguments(parser) return parser @@ -623,8 +623,8 @@ class OpenStackSaharaShell(object): project_id = args.os_project_id or args.os_tenant_id project_name = args.os_project_name or args.os_tenant_name - keystone_session = (session.Session. - load_from_cli_options(args)) + keystone_session = (session.Session(). + load_from_argparse_arguments(args)) keystone_auth = self._get_keystone_auth( keystone_session, args.os_auth_url,