Use only one image in heat_ims
[functest.git] / functest / core / tenantnetwork.py
index 286aef6..b9b0770 100644 (file)
@@ -9,10 +9,11 @@
 
 """Ease deploying tenant networks
 
-It offers a simple way to create all tenant network ressources required by a
+It offers a simple way to create all tenant network resources required by a
 testcase (including all Functest ones):
+
   - TenantNetwork1 selects the user and the project set as env vars
-  - TenantNetwork2 creates a user and project to isolate the same ressources
+  - TenantNetwork2 creates a user and project to isolate the same resources
 
 This classes could be reused by more complexed scenarios (Single VM)
 """
@@ -35,7 +36,6 @@ 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
@@ -48,6 +48,7 @@ class NewProject(object):
         self.domain = None
         self.role = None
         self.role_name = None
+        self.default_member = env.get('NEW_USER_ROLE')
 
     def create(self):
         """Create projects/users"""
@@ -106,14 +107,14 @@ class NewProject(object):
             if self.role:
                 self.orig_cloud.delete_role(self.role.id)
         except Exception:  # pylint: disable=broad-except
-            self.__logger.exception("Cannot clean all ressources")
+            self.__logger.exception("Cannot clean all resources")
 
 
 class TenantNetwork1(testcase.TestCase):
     # pylint: disable=too-many-instance-attributes
     """Create a tenant network (scenario1)
 
-    It creates and configures all tenant network ressources required by
+    It creates and configures all tenant network resources required by
     advanced testcases (subnet, network and router).
 
     It ensures that all testcases inheriting from TenantNetwork1 could work
@@ -122,7 +123,7 @@ class TenantNetwork1(testcase.TestCase):
     """
 
     __logger = logging.getLogger(__name__)
-    cidr = '192.168.0.0/24'
+    cidr = '192.168.120.0/24'
     shared_network = False
 
     def __init__(self, **kwargs):
@@ -175,7 +176,23 @@ class TenantNetwork1(testcase.TestCase):
             role = cloud.get_role(member.lower())
         return role
 
-    def _create_network_ressources(self):
+    @staticmethod
+    def get_public_auth_url(cloud):
+        """Get Keystone public endpoint"""
+        keystone_id = cloud.search_services('keystone')[0].id
+        endpoint = cloud.search_endpoints(
+            filters={'interface': 'public',
+                     'service_id': keystone_id})[0].url
+        return endpoint
+
+    def create_network_resources(self):
+        """Create all tenant network resources
+
+        It creates a router which gateway is the external network detected.
+        The new subnet is attached to that router.
+
+        Raises: expection on error
+        """
         assert self.cloud
         assert self.ext_net
         provider = {}
@@ -215,7 +232,7 @@ class TenantNetwork1(testcase.TestCase):
         try:
             assert self.cloud
             self.start_time = time.time()
-            self._create_network_ressources()
+            self.create_network_resources()
             self.result = 100
             status = testcase.TestCase.EX_OK
         except Exception:  # pylint: disable=broad-except
@@ -237,14 +254,14 @@ class TenantNetwork1(testcase.TestCase):
             if self.network:
                 self.cloud.delete_network(self.network.id)
         except Exception:  # pylint: disable=broad-except
-            self.__logger.exception("cannot clean all ressources")
+            self.__logger.exception("cannot clean all resources")
 
 
 class TenantNetwork2(TenantNetwork1):
     """Create a tenant network (scenario2)
 
     It creates new user/project before creating and configuring all tenant
-    network ressources required by a testcase (subnet, network and router).
+    network resources required by a testcase (subnet, network and router).
 
     It ensures that all testcases inheriting from TenantNetwork2 could work
     without network specific configurations (or at least read the same config
@@ -274,4 +291,4 @@ class TenantNetwork2(TenantNetwork1):
             assert self.project
             self.project.clean()
         except Exception:  # pylint: disable=broad-except
-            self.__logger.exception("Cannot clean all ressources")
+            self.__logger.exception("Cannot clean all resources")