Merge "Fixes Keystone v3 401 authentication failures"

This commit is contained in:
Jenkins 2017-03-08 15:47:39 +00:00 committed by Gerrit Code Review
commit 50ac27de70
3 changed files with 36 additions and 24 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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()