summaryrefslogtreecommitdiffstats
path: root/doctor_tests/user.py
diff options
context:
space:
mode:
authorTomi Juvonen <tomi.juvonen@nokia.com>2018-01-09 04:22:55 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-01-09 04:22:55 +0000
commitd767217e4ed267c585aa94fbbd3001ec0d59de8c (patch)
treedaa5f7767572c84fa440942b0c50037ae319d0c3 /doctor_tests/user.py
parent3e882aeb6b55ceef3bd3c20155f0014a7b8c058e (diff)
parent46991f69c81249b60e40b71964dde3223a59ddd8 (diff)
Merge "fix the CI error"
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 5598a2d5..a6f58d9a 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 = [
@@ -136,12 +137,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"""