From 46991f69c81249b60e40b71964dde3223a59ddd8 Mon Sep 17 00:00:00 2001 From: dongwenjuan Date: Mon, 8 Jan 2018 14:42:03 +0800 Subject: fix the CI error Change-Id: I0b60e6f1e15cbe556c7555186352d28490b98acc Signed-off-by: dongwenjuan --- doctor_tests/user.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'doctor_tests') 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""" -- cgit 1.2.3-korg