Fixes Keystone v3 401 authentication failures

Change-Id: I4c3dbd1f2ce09d322a9c7eef3355b1a3c93bb667
Partially-Closes-Bug: #1669238
This commit is contained in:
Sharmin Choksey 2017-03-01 19:39:11 -08:00 committed by Vinod Pandarinathan
parent d667af67f3
commit 1d0e07b46a
3 changed files with 36 additions and 24 deletions
cloudpulseclient
openstack/common/apiclient
shell.py
v1

@ -127,6 +127,8 @@ class BaseAuthPlugin(object):
"tenant_name", "tenant_name",
"token", "token",
"auth_url", "auth_url",
"project_domain_name",
"user_domain_name",
] ]
def __init__(self, auth_system=None, **kwargs): def __init__(self, auth_system=None, **kwargs):

@ -33,6 +33,13 @@ from oslo_utils import encodeutils
from oslo_utils import strutils from oslo_utils import strutils
import six import six
from cloudpulseclient.openstack.common.apiclient import auth
from cloudpulseclient.openstack.common.apiclient import exceptions as exc
from cloudpulseclient.openstack.common import cliutils
from cloudpulseclient.v1 import client
from cloudpulseclient.v1 import shell as shell_v1
from cloudpulseclient import version
HAS_KEYRING = False HAS_KEYRING = False
all_errors = ValueError all_errors = ValueError
try: try:
@ -49,13 +56,6 @@ try:
except ImportError: except ImportError:
pass pass
from cloudpulseclient.openstack.common.apiclient import auth
from cloudpulseclient.openstack.common.apiclient import exceptions as exc
from cloudpulseclient.openstack.common import cliutils
from cloudpulseclient.v1 import client
from cloudpulseclient.v1 import shell as shell_v1
from cloudpulseclient import version
DEFAULT_API_VERSION = '1' DEFAULT_API_VERSION = '1'
DEFAULT_ENDPOINT_TYPE = 'publicURL' DEFAULT_ENDPOINT_TYPE = 'publicURL'
DEFAULT_SERVICE_TYPE = 'health' DEFAULT_SERVICE_TYPE = 'health'
@ -521,16 +521,19 @@ class OpenStackCloudPulseShell(object):
'--os-password, env[OS_PASSWORD], or ' '--os-password, env[OS_PASSWORD], or '
'prompted response') 'prompted response')
self.cs = client.Client(username=os_username, self.cs = client.Client(
api_key=os_password, username=os_username,
project_id=os_tenant_id, api_key=os_password,
project_name=os_tenant_name, project_id=os_tenant_id,
auth_url=os_auth_url, project_name=os_tenant_name,
service_type=service_type, auth_url=os_auth_url,
region_name=args.os_region_name, service_type=service_type,
cacert=cacert, region_name=args.os_region_name,
insecure=insecure, project_domain_name=args.os_project_domain_name,
cloudpulse_url=bypass_url) user_domain_name=args.os_user_domain_name,
cacert=cacert,
insecure=insecure,
cloudpulse_url=bypass_url)
args.func(self.cs, args) args.func(self.cs, args)

@ -25,18 +25,22 @@ class Client(object):
def __init__(self, username=None, api_key=None, project_id=None, def __init__(self, username=None, api_key=None, project_id=None,
project_name=None, auth_url=None, cloudpulse_url=None, project_name=None, auth_url=None, cloudpulse_url=None,
endpoint_type='publicURL', service_type='container', endpoint_type='publicURL', service_type='container',
project_domain_name=None, user_domain_name=None,
region_name=None, input_auth_token=None, insecure=False, region_name=None, input_auth_token=None, insecure=False,
cacert=None): cacert=None):
keystone = None keystone = None
if not input_auth_token: if not input_auth_token:
keystone = self.get_keystone_client(username=username, keystone = self.get_keystone_client(
api_key=api_key, username=username,
auth_url=auth_url, api_key=api_key,
project_id=project_id, auth_url=auth_url,
project_name=project_name, project_id=project_id,
insecure=insecure, project_name=project_name,
cacert=cacert) project_domain_name=project_domain_name,
user_domain_name=user_domain_name,
insecure=insecure,
cacert=cacert)
input_auth_token = keystone.auth_token input_auth_token = keystone.auth_token
if not input_auth_token: if not input_auth_token:
@ -80,6 +84,7 @@ class Client(object):
@staticmethod @staticmethod
def get_keystone_client(username=None, api_key=None, auth_url=None, def get_keystone_client(username=None, api_key=None, auth_url=None,
insecure=False, cacert=None, token=None, insecure=False, cacert=None, token=None,
project_domain_name=None, user_domain_name=None,
project_id=None, project_name=None): project_id=None, project_name=None):
if not auth_url: if not auth_url:
raise RuntimeError("No auth url specified") raise RuntimeError("No auth url specified")
@ -94,6 +99,8 @@ class Client(object):
cacert=cacert, cacert=cacert,
tenant_id=project_id, tenant_id=project_id,
tenant_name=project_name, tenant_name=project_name,
project_domain_name=project_domain_name,
user_domain_name=user_domain_name,
auth_url=auth_url, auth_url=auth_url,
endpoint=auth_url) endpoint=auth_url)
client.authenticate() client.authenticate()