Add qcow2 image support

This commit adds qcow2 image format for some scenario test. Because
qcow2 disk image format is nicer than uec format.

Change-Id: I4c812176ed1800052c3192110067b1ae7fb04b85
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 0e11b90..5d396a4 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -664,6 +664,9 @@
 # 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
+
 # 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 49d65f9..37c18c8 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -625,6 +625,9 @@
                default='/opt/stack/new/devstack/files/images/'
                'cirros-0.3.1-x86_64-uec',
                help='Directory containing image files'),
+    cfg.StrOpt('qcow2_img_file',
+               default='cirros-0.3.1-x86_64-disk.img',
+               help='QCOW2 image file name'),
     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 f5dd53a..dc6b686 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -561,19 +561,30 @@
         return image.id
 
     def glance_image_create(self):
+        qcow2_img_path = (CONF.scenario.img_dir + "/" +
+                          CONF.scenario.qcow2_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: ami: %s, ari: %s, aki: %s"
-                  % (ami_img_path, ari_img_path, aki_img_path))
-        kernel_id = self._image_create('scenario-aki', 'aki', aki_img_path)
-        ramdisk_id = self._image_create('scenario-ari', 'ari', ari_img_path)
-        properties = {
-            'properties': {'kernel_id': kernel_id, 'ramdisk_id': ramdisk_id}
-        }
-        self.image = self._image_create('scenario-ami', 'ami',
-                                        path=ami_img_path,
-                                        properties=properties)
+        LOG.debug("paths: img: %s, ami: %s, ari: %s, aki: %s"
+                  % (qcow2_img_path, ami_img_path, ari_img_path, aki_img_path))
+        try:
+            self.image = self._image_create('scenario-img',
+                                            'bare',
+                                            qcow2_img_path,
+                                            properties={'disk_format':
+                                                        'qcow2'})
+        except IOError:
+            LOG.debug("A qcow2 image was not got. Try to get a uec image.")
+            kernel = self._image_create('scenario-aki', 'aki', aki_img_path)
+            ramdisk = self._image_create('scenario-ari', 'ari', ari_img_path)
+            properties = {
+                'properties': {'kernel_id': kernel, 'ramdisk_id': ramdisk}
+            }
+            self.image = self._image_create('scenario-ami', 'ami',
+                                            path=ami_img_path,
+                                            properties=properties)
+        LOG.debug("image:%s" % self.image)
 
 
 class NetworkScenarioTest(OfficialClientTest):