aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-07-11 20:58:04 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-07-11 21:25:43 +0200
commit1222e8c0f3699c5d74c54df11e5cdf00fd468b59 (patch)
treee38ff1809e964e86bdf243e0982c8a1aad8d6fa2
parentbf39607ee1128f6a9b46c37c0a8ac1e582d39ea5 (diff)
Reuse the right detected role name
It completes "Try to get Member or member role" [1][2]. [1] https://gerrit.opnfv.org/gerrit/#/c/59661/ [2] https://build.opnfv.org/ci/view/functest/job/functest-apex-baremetal-daily-master/144/console Change-Id: Ib38b513906b08d6f85834e03f5415e83b66b733b Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r--functest/core/tenantnetwork.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/functest/core/tenantnetwork.py b/functest/core/tenantnetwork.py
index 05c14c2d4..348ef7d92 100644
--- a/functest/core/tenantnetwork.py
+++ b/functest/core/tenantnetwork.py
@@ -47,6 +47,7 @@ class NewProject(object):
self.password = None
self.domain = None
self.role = None
+ self.role_name = None
def create(self):
"""Create projects/users"""
@@ -68,16 +69,19 @@ class NewProject(object):
domain_id=self.domain.id)
self.__logger.debug("user: %s", self.user)
try:
- if not self.orig_cloud.get_role(
- self.default_member) and not self.orig_cloud.get_role(
- self.default_member.lower()):
+ if self.orig_cloud.get_role(self.default_member):
+ self.role_name = self.default_member
+ elif self.orig_cloud.get_role(self.default_member.lower()):
+ self.role_name = self.default_member.lower()
+ else:
raise Exception("Cannot detect {}".format(self.default_member))
except Exception: # pylint: disable=broad-except
self.__logger.info("Creating default role %s", self.default_member)
self.role = self.orig_cloud.create_role(self.default_member)
+ self.role_name = self.role.name
self.__logger.debug("role: %s", self.role)
self.orig_cloud.grant_role(
- self.default_member, user=self.user.id, project=self.project.id,
+ self.role_name, user=self.user.id, project=self.project.id,
domain=self.domain.id)
osconfig = os_client_config.config.OpenStackConfig()
osconfig.cloud_config[