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

View File

@ -104,13 +104,20 @@ 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:
if default_role == role.name.lower().strip("_"):
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." % LOG.warning("Unable to set %s role to created user." %
default_role) default_role)
return user return user