Fix system & domain scoped admin dynamic credential

With I8bebb5b9b6d8da62e6a5268d827787da461cc0d6 Tempest
started supporting the system and domain scope along
with project. But system and domain admin are not created
with requried scope. If admin role is requested even with
system or domain scope get_credentials() method does not pass
the requested scope to _create_creds() so it is always created
with project scope.

This commit fix this by passing the correct scope while creating
the cred.

Change-Id: Id2c9f5b304106a5be15639a69f95be424a394436
This commit is contained in:
Ghanshyam Mann 2021-01-29 13:07:23 -06:00 committed by Ghanshyam
parent 0821f9005e
commit 7f3942522a

View File

@ -376,15 +376,18 @@ class DynamicCredentialProvider(cred_provider.CredentialProvider):
elif scope and self._creds.get("%s_%s" % (scope, credential_type[0])):
credentials = self._creds["%s_%s" % (scope, credential_type[0])]
else:
if credential_type in ['primary', 'alt', 'admin']:
if scope:
if credential_type == 'admin':
credentials = self._create_creds(
admin=True, scope=scope)
else:
credentials = self._create_creds(
roles=credential_type, scope=scope)
elif credential_type in ['primary', 'alt', 'admin']:
is_admin = (credential_type == 'admin')
credentials = self._create_creds(admin=is_admin)
else:
if scope:
credentials = self._create_creds(
roles=credential_type, scope=scope)
else:
credentials = self._create_creds(roles=credential_type)
credentials = self._create_creds(roles=credential_type)
if scope:
self._creds["%s_%s" %
(scope, credential_type[0])] = credentials