Merge "Fix the choice of default_role"

This commit is contained in:
Jenkins 2017-04-22 10:23:46 +00:00 committed by Gerrit Code Review
commit cb8ddb49d7
1 changed files with 13 additions and 6 deletions

View File

@ -104,15 +104,22 @@ class KeystoneV3Service(service.Service, keystone_common.KeystoneMixin):
if project_id: if project_id:
# we can't setup role without project_id # we can't setup role without project_id
for role in self.list_roles(): roles = self.list_roles()
if default_role in role.name.lower(): for role in roles:
if default_role == role.name.lower():
self.add_role(role_id=role.id, self.add_role(role_id=role.id,
user_id=user.id, user_id=user.id,
project_id=project_id) project_id=project_id)
break return user
else: for role in roles:
LOG.warning("Unable to set %s role to created user." % if default_role == role.name.lower().strip("_"):
default_role) self.add_role(role_id=role.id,
user_id=user.id,
project_id=project_id)
return user
LOG.warning("Unable to set %s role to created user." %
default_role)
return user return user
@atomic.action_timer("keystone_v3.create_users") @atomic.action_timer("keystone_v3.create_users")