Disable test_auto_allocated_topology_rbac in patrole
[functest.git] / functest / core / tenantnetwork.py
index 760dc30..9f5913c 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)
 """
@@ -58,7 +59,7 @@ class NewProject(object):
             name_or_id=self.orig_cloud.auth.get(
                 "project_domain_name", "Default"))
         self.project = self.orig_cloud.create_project(
-            name='{}-project_{}'.format(self.case_name, self.guid),
+            name='{}-project_{}'.format(self.case_name[:18], self.guid),
             description="Created by OPNFV Functest: {}".format(
                 self.case_name),
             domain_id=self.domain.id)
@@ -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
@@ -133,9 +134,10 @@ class TenantNetwork1(testcase.TestCase):
             getattr(config.CONF, 'dir_results'), self.case_name)
         try:
             cloud_config = os_client_config.get_config()
-            self.cloud = shade.OpenStackCloud(cloud_config=cloud_config)
+            self.cloud = self.orig_cloud = shade.OpenStackCloud(
+                cloud_config=cloud_config)
         except Exception:  # pylint: disable=broad-except
-            self.cloud = None
+            self.cloud = self.orig_cloud = None
             self.ext_net = None
             self.__logger.exception("Cannot connect to Cloud")
         try:
@@ -204,9 +206,15 @@ class TenantNetwork1(testcase.TestCase):
         if hasattr(config.CONF, '{}_segmentation_id'.format(self.case_name)):
             provider["segmentation_id"] = getattr(
                 config.CONF, '{}_segmentation_id'.format(self.case_name))
-        self.network = self.cloud.create_network(
+        domain = self.orig_cloud.get_domain(
+            name_or_id=self.orig_cloud.auth.get(
+                "project_domain_name", "Default"))
+        project = self.orig_cloud.get_project(
+            self.cloud.auth['project_name'],
+            domain_id=domain.id)
+        self.network = self.orig_cloud.create_network(
             '{}-net_{}'.format(self.case_name, self.guid),
-            provider=provider,
+            provider=provider, project_id=project.id,
             shared=self.shared_network)
         self.__logger.debug("network: %s", self.network)
 
@@ -253,14 +261,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
@@ -290,4 +298,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")