summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2018-01-08 14:42:03 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2018-01-09 09:45:55 +0800
commit46991f69c81249b60e40b71964dde3223a59ddd8 (patch)
tree385576e8db110682d877ecba03d484e2c764459b
parentbdbd22904733af311225a3315555bb39ea12ed55 (diff)
fix the CI error
Change-Id: I0b60e6f1e15cbe556c7555186352d28490b98acc Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
-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"""