diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-07-01 11:11:33 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-07-01 11:41:36 +0200 |
commit | b3916af1754e02bb952b431a36c70b0c3aee9a0a (patch) | |
tree | 49e28dfe430416af97423b67fe2031b6cdcfc2df | |
parent | d97c57931002895f2af45e521fb8fc20a11e82ca (diff) |
Create Member role if required
It seems there is no common role configuration between OPNFV
installers. Then it creates/removes the expected role if required.
Change-Id: I38a92e2522a401f46a59813b9e9443a11d6c7060
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r-- | functest/core/tenantnetwork.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/functest/core/tenantnetwork.py b/functest/core/tenantnetwork.py index bf14f4126..ea69fcba6 100644 --- a/functest/core/tenantnetwork.py +++ b/functest/core/tenantnetwork.py @@ -36,6 +36,7 @@ class NewProject(object): # pylint: disable=too-many-instance-attributes __logger = logging.getLogger(__name__) + default_member = "Member" def __init__(self, cloud, case_name, guid): self.cloud = None @@ -46,6 +47,7 @@ class NewProject(object): self.user = None self.password = None self.domain = None + self.role = None def create(self): """Create projects/users""" @@ -66,8 +68,14 @@ class NewProject(object): password=self.password, domain_id=self.domain.id) self.__logger.debug("user: %s", self.user) + try: + assert self.orig_cloud.get_role(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.__logger.debug("role: %s", self.role) self.orig_cloud.grant_role( - "Member", user=self.user.id, project=self.project.id, + self.default_member, user=self.user.id, project=self.project.id, domain=self.domain.id) osconfig = os_client_config.config.OpenStackConfig() osconfig.cloud_config[ @@ -87,6 +95,8 @@ class NewProject(object): assert self.project.id self.orig_cloud.delete_user(self.user.id) self.orig_cloud.delete_project(self.project.id) + if self.role: + self.orig_cloud.delete_role(self.role.id) except Exception: # pylint: disable=broad-except self.__logger.exception("Cannot clean all ressources") |