Fix cron keystone calls when token is available

When a token_id is present we get

Failed to process cron trigger CronTrigger
AuthorizationFailure: Authentication cannot be scoped to multiple targets.
Pick one of: project, domain, trust or unscoped

We have a test to do that if CONF.keystone_authtoken.auth_type is not None
but a change was needed when it was none.

Change-Id: I636873c0db4b3dbf66a0c5a856fee4dcb644ac3c
Closes-bug: #1711069
This commit is contained in:
Adriano Petrich 2017-08-14 14:51:07 +01:00
parent 3f62afd8fb
commit d08479ff0c

View File

@ -96,11 +96,17 @@ def get_session_and_auth(context, **kwargs):
def _admin_client(trust_id=None):
if CONF.keystone_authtoken.auth_type is None:
auth_url = CONF.keystone_authtoken.auth_uri
project_name = CONF.keystone_authtoken.admin_tenant_name
# You can't use trust and project together
if trust_id:
project_name = None
cl = ks_client.Client(
username=CONF.keystone_authtoken.admin_user,
password=CONF.keystone_authtoken.admin_password,
project_name=CONF.keystone_authtoken.admin_tenant_name,
project_name=project_name,
auth_url=auth_url,
trust_id=trust_id
)