From 1222e8c0f3699c5d74c54df11e5cdf00fd468b59 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Wed, 11 Jul 2018 20:58:04 +0200 Subject: Reuse the right detected role name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- functest/core/tenantnetwork.py | 12 ++++++++---- 1 file 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[ -- cgit 1.2.3-korg