summaryrefslogtreecommitdiffstats
path: root/doctor_tests/user.py
diff options
context:
space:
mode:
Diffstat (limited to 'doctor_tests/user.py')
-rw-r--r--doctor_tests/user.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/doctor_tests/user.py b/doctor_tests/user.py
index b5637d93..fee3e1fb 100644
--- a/doctor_tests/user.py
+++ b/doctor_tests/user.py
@@ -13,6 +13,7 @@ from oslo_config import cfg
from doctor_tests.identity_auth import get_session
from doctor_tests.os_clients import keystone_client
from doctor_tests.os_clients import nova_client
+from keystoneclient import exceptions as ks_exceptions
OPTS = [
@@ -140,12 +141,15 @@ class User(object):
roles_for_user = self.roles_for_admin \
if is_admin else self.roles_for_user
- if not self.keystone.roles.check(role, user=user, project=project):
+ try:
+ self.keystone.roles.check(role, user=user, project=project)
+ self.log.info('Already grant a role:%s to user: %s on'
+ ' project: %s'
+ % (role_name, user_name,
+ self.conf.doctor_project))
+ except ks_exceptions.NotFound:
self.keystone.roles.grant(role, user=user, project=project)
roles_for_user[role_name] = role
- else:
- self.log.info('Already grant a role:%s to user: %s on project: %s'
- % (role_name, user_name, self.conf.doctor_project))
def delete(self):
"""delete the test user, project and role"""