Disable test_auto_allocated_topology_rbac in patrole
[functest.git] / functest / core / singlevm.py
index 846e198..71ed069 100644 (file)
@@ -9,7 +9,7 @@
 
 """Ease deploying a single VM reachable via ssh
 
 
 """Ease deploying a single VM reachable via ssh
 
-It offers a simple way to create all tenant network ressources + a VM for
+It offers a simple way to create all tenant network resources + a VM for
 advanced testcases (e.g. deploying an orchestrator).
 """
 
 advanced testcases (e.g. deploying an orchestrator).
 """
 
@@ -39,7 +39,7 @@ class VmReady1(tenantnetwork.TenantNetwork1):
     __logger = logging.getLogger(__name__)
     filename = '/home/opnfv/functest/images/cirros-0.4.0-x86_64-disk.img'
     image_format = 'qcow2'
     __logger = logging.getLogger(__name__)
     filename = '/home/opnfv/functest/images/cirros-0.4.0-x86_64-disk.img'
     image_format = 'qcow2'
-    extra_properties = None
+    extra_properties = {}
     filename_alt = filename
     image_alt_format = image_format
     extra_alt_properties = extra_properties
     filename_alt = filename
     image_alt_format = image_format
     extra_alt_properties = extra_properties
@@ -58,7 +58,6 @@ class VmReady1(tenantnetwork.TenantNetwork1):
         if "case_name" not in kwargs:
             kwargs["case_name"] = 'vmready1'
         super(VmReady1, self).__init__(**kwargs)
         if "case_name" not in kwargs:
             kwargs["case_name"] = 'vmready1'
         super(VmReady1, self).__init__(**kwargs)
-        self.orig_cloud = self.cloud
         self.image = None
         self.flavor = None
 
         self.image = None
         self.flavor = None
 
@@ -73,14 +72,16 @@ class VmReady1(tenantnetwork.TenantNetwork1):
         Raises: expection on error
         """
         assert self.cloud
         Raises: expection on error
         """
         assert self.cloud
+        extra_properties = self.extra_properties.copy()
+        extra_properties.update(
+            getattr(config.CONF, '{}_extra_properties'.format(
+                self.case_name), {}))
         image = self.cloud.create_image(
             name if name else '{}-img_{}'.format(self.case_name, self.guid),
             filename=getattr(
                 config.CONF, '{}_image'.format(self.case_name),
                 self.filename),
         image = self.cloud.create_image(
             name if name else '{}-img_{}'.format(self.case_name, self.guid),
             filename=getattr(
                 config.CONF, '{}_image'.format(self.case_name),
                 self.filename),
-            meta=getattr(
-                config.CONF, '{}_extra_properties'.format(self.case_name),
-                self.extra_properties),
+            meta=extra_properties,
             disk_format=getattr(
                 config.CONF, '{}_image_format'.format(self.case_name),
                 self.image_format),
             disk_format=getattr(
                 config.CONF, '{}_image_format'.format(self.case_name),
                 self.image_format),
@@ -102,15 +103,17 @@ class VmReady1(tenantnetwork.TenantNetwork1):
         Raises: expection on error
         """
         assert self.cloud
         Raises: expection on error
         """
         assert self.cloud
+        extra_alt_properties = self.extra_alt_properties.copy()
+        extra_alt_properties.update(
+            getattr(config.CONF, '{}_extra_alt_properties'.format(
+                self.case_name), {}))
         image = self.cloud.create_image(
             name if name else '{}-img_alt_{}'.format(
                 self.case_name, self.guid),
             filename=getattr(
                 config.CONF, '{}_image_alt'.format(self.case_name),
                 self.filename_alt),
         image = self.cloud.create_image(
             name if name else '{}-img_alt_{}'.format(
                 self.case_name, self.guid),
             filename=getattr(
                 config.CONF, '{}_image_alt'.format(self.case_name),
                 self.filename_alt),
-            meta=getattr(
-                config.CONF, '{}_extra_alt_properties'.format(self.case_name),
-                self.extra_properties),
+            meta=extra_alt_properties,
             disk_format=getattr(
                 config.CONF, '{}_image_alt_format'.format(self.case_name),
                 self.image_format),
             disk_format=getattr(
                 config.CONF, '{}_image_alt_format'.format(self.case_name),
                 self.image_format),
@@ -141,11 +144,11 @@ class VmReady1(tenantnetwork.TenantNetwork1):
             getattr(config.CONF, '{}_flavor_disk'.format(self.case_name),
                     self.flavor_disk))
         self.__logger.debug("flavor: %s", flavor)
             getattr(config.CONF, '{}_flavor_disk'.format(self.case_name),
                     self.flavor_disk))
         self.__logger.debug("flavor: %s", flavor)
-        flavor_extra_specs_updated = self.flavor_extra_specs.copy()
-        flavor_extra_specs_updated.update(
+        flavor_extra_specs = self.flavor_extra_specs.copy()
+        flavor_extra_specs.update(
             getattr(config.CONF,
                     '{}_flavor_extra_specs'.format(self.case_name), {}))
             getattr(config.CONF,
                     '{}_flavor_extra_specs'.format(self.case_name), {}))
-        self.orig_cloud.set_flavor_specs(flavor.id, flavor_extra_specs_updated)
+        self.orig_cloud.set_flavor_specs(flavor.id, flavor_extra_specs)
         return flavor
 
     def create_flavor_alt(self, name=None):
         return flavor
 
     def create_flavor_alt(self, name=None):
@@ -169,12 +172,12 @@ class VmReady1(tenantnetwork.TenantNetwork1):
             getattr(config.CONF, '{}_flavor_alt_disk'.format(self.case_name),
                     self.flavor_alt_disk))
         self.__logger.debug("flavor: %s", flavor)
             getattr(config.CONF, '{}_flavor_alt_disk'.format(self.case_name),
                     self.flavor_alt_disk))
         self.__logger.debug("flavor: %s", flavor)
-        flavor_alt_extra_specs_updated = self.flavor_alt_extra_specs.copy()
-        flavor_alt_extra_specs_updated.update(
+        flavor_alt_extra_specs = self.flavor_alt_extra_specs.copy()
+        flavor_alt_extra_specs.update(
             getattr(config.CONF,
                     '{}_flavor_alt_extra_specs'.format(self.case_name), {}))
         self.orig_cloud.set_flavor_specs(
             getattr(config.CONF,
                     '{}_flavor_alt_extra_specs'.format(self.case_name), {}))
         self.orig_cloud.set_flavor_specs(
-            flavor.id, flavor_alt_extra_specs_updated)
+            flavor.id, flavor_alt_extra_specs)
         return flavor
 
     def boot_vm(self, name=None, **kwargs):
         return flavor
 
     def boot_vm(self, name=None, **kwargs):
@@ -253,14 +256,14 @@ class VmReady1(tenantnetwork.TenantNetwork1):
             if self.flavor:
                 self.orig_cloud.delete_flavor(self.flavor.id)
         except Exception:  # pylint: disable=broad-except
             if self.flavor:
                 self.orig_cloud.delete_flavor(self.flavor.id)
         except Exception:  # pylint: disable=broad-except
-            self.__logger.exception("Cannot clean all ressources")
+            self.__logger.exception("Cannot clean all resources")
 
 
 class VmReady2(VmReady1):
     """Deploy a single VM reachable via ssh (scenario2)
 
     It creates new user/project before creating and configuring all tenant
 
 
 class VmReady2(VmReady1):
     """Deploy a single VM reachable via ssh (scenario2)
 
     It creates new user/project before creating and configuring all tenant
-    network ressources, flavors, images, etc. required by advanced testcases.
+    network resources, flavors, images, etc. required by advanced testcases.
 
     It ensures that all testcases inheriting from SingleVm2 could work
     without specific configurations (or at least read the same config data).
 
     It ensures that all testcases inheriting from SingleVm2 could work
     without specific configurations (or at least read the same config data).
@@ -289,7 +292,7 @@ class VmReady2(VmReady1):
             assert self.project
             self.project.clean()
         except Exception:  # pylint: disable=broad-except
             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")
 
 
 class SingleVm1(VmReady1):
 
 
 class SingleVm1(VmReady1):
@@ -445,14 +448,14 @@ class SingleVm1(VmReady1):
                 self.cloud.delete_keypair(self.keypair.name)
             super(SingleVm1, self).clean()
         except Exception:  # pylint: disable=broad-except
                 self.cloud.delete_keypair(self.keypair.name)
             super(SingleVm1, self).clean()
         except Exception:  # pylint: disable=broad-except
-            self.__logger.exception("Cannot clean all ressources")
+            self.__logger.exception("Cannot clean all resources")
 
 
 class SingleVm2(SingleVm1):
     """Deploy a single VM reachable via ssh (scenario2)
 
     It creates new user/project before creating and configuring all tenant
 
 
 class SingleVm2(SingleVm1):
     """Deploy a single VM reachable via ssh (scenario2)
 
     It creates new user/project before creating and configuring all tenant
-    network ressources and vms required by advanced testcases.
+    network resources and vms required by advanced testcases.
 
     It ensures that all testcases inheriting from SingleVm2 could work
     without specific configurations (or at least read the same config data).
 
     It ensures that all testcases inheriting from SingleVm2 could work
     without specific configurations (or at least read the same config data).
@@ -481,4 +484,4 @@ class SingleVm2(SingleVm1):
             assert self.project
             self.project.clean()
         except Exception:  # pylint: disable=broad-except
             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")