Merge "Adds support for custom image formats in scenarios"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 247f6d1..29f80bd 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -933,8 +933,15 @@
 # Directory containing image files (string value)
 #img_dir=/opt/stack/new/devstack/files/images/cirros-0.3.1-x86_64-uec
 
-# QCOW2 image file name (string value)
-#qcow2_img_file=cirros-0.3.1-x86_64-disk.img
+# Image file name (string value)
+# Deprecated group/name - [DEFAULT]/qcow2_img_file
+#img_file=cirros-0.3.1-x86_64-disk.img
+
+# Image disk format (string value)
+#img_disk_format=qcow2
+
+# Image container format (string value)
+#img_container_format=bare
 
 # AMI image file name (string value)
 #ami_img_file=cirros-0.3.1-x86_64-blank.img
diff --git a/tempest/config.py b/tempest/config.py
index 4836c63..af45ba5 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -855,9 +855,15 @@
                default='/opt/stack/new/devstack/files/images/'
                'cirros-0.3.1-x86_64-uec',
                help='Directory containing image files'),
-    cfg.StrOpt('qcow2_img_file',
+    cfg.StrOpt('img_file', deprecated_name='qcow2_img_file',
                default='cirros-0.3.1-x86_64-disk.img',
-               help='QCOW2 image file name'),
+               help='Image file name'),
+    cfg.StrOpt('img_disk_format',
+               default='qcow2',
+               help='Image disk format'),
+    cfg.StrOpt('img_container_format',
+               default='bare',
+               help='Image container format'),
     cfg.StrOpt('ami_img_file',
                default='cirros-0.3.1-x86_64-blank.img',
                help='AMI image file name'),
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 856b751..54f0256 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -355,19 +355,22 @@
         return image['id']
 
     def glance_image_create(self):
-        qcow2_img_path = (CONF.scenario.img_dir + "/" +
-                          CONF.scenario.qcow2_img_file)
+        img_path = CONF.scenario.img_dir + "/" + CONF.scenario.img_file
         aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
         ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
         ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
-        LOG.debug("paths: img: %s, ami: %s, ari: %s, aki: %s"
-                  % (qcow2_img_path, ami_img_path, ari_img_path, aki_img_path))
+        img_container_format = CONF.scenario.img_container_format
+        img_disk_format = CONF.scenario.img_disk_format
+        LOG.debug("paths: img: %s, container_fomat: %s, disk_format: %s, "
+                  "ami: %s, ari: %s, aki: %s" %
+                  (img_path, img_container_format, img_disk_format,
+                   ami_img_path, ari_img_path, aki_img_path))
         try:
             self.image = self._image_create('scenario-img',
-                                            'bare',
-                                            qcow2_img_path,
+                                            img_container_format,
+                                            img_path,
                                             properties={'disk_format':
-                                                        'qcow2'})
+                                                        img_disk_format})
         except IOError:
             LOG.debug("A qcow2 image was not found. Try to get a uec image.")
             kernel = self._image_create('scenario-aki', 'aki', aki_img_path)
@@ -886,19 +889,22 @@
         return image.id
 
     def glance_image_create(self):
-        qcow2_img_path = (CONF.scenario.img_dir + "/" +
-                          CONF.scenario.qcow2_img_file)
+        img_path = CONF.scenario.img_dir + "/" + CONF.scenario.img_file
         aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
         ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
         ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
-        LOG.debug("paths: img: %s, ami: %s, ari: %s, aki: %s"
-                  % (qcow2_img_path, ami_img_path, ari_img_path, aki_img_path))
+        img_container_format = CONF.scenario.img_container_format
+        img_disk_format = CONF.scenario.img_disk_format
+        LOG.debug("paths: img: %s, container_fomat: %s, disk_format: %s, "
+                  "ami: %s, ari: %s, aki: %s" %
+                  (img_path, img_container_format, img_disk_format,
+                   ami_img_path, ari_img_path, aki_img_path))
         try:
             self.image = self._image_create('scenario-img',
-                                            'bare',
-                                            qcow2_img_path,
+                                            img_container_format,
+                                            img_path,
                                             properties={'disk_format':
-                                                        'qcow2'})
+                                                        img_disk_format})
         except IOError:
             LOG.debug("A qcow2 image was not found. Try to get a uec image.")
             kernel = self._image_create('scenario-aki', 'aki', aki_img_path)