Allow not the same sequence in container_formats and disk_formats

In glance v1, If container_format is one of ['ami', 'ari', 'aki'],
then disk_format must be same with container_format, otherwise
we will get an exception:
     "Invalid mix of disk and container formats. When setting a disk
      or container format to one of 'aki', 'ari', or 'ami', the
      container and disk formats must match."

And in tempest.conf, the container_format and disk_format may be of
different item sequence, such as:
    container_formats = ami,ari,aki,bare
    disk_formats = ari,ami,aki,vhd
In this case, the testcase may fail unexpectedly, so this is to
select one in disk_formats list that is same with container_format,
to avoid the unexpected failure.

Change-Id: Ia64e9ad70c78d8f26f117f90384756f78de164d8
diff --git a/tempest/api/image/v1/test_images.py b/tempest/api/image/v1/test_images.py
index ee32f0a..0106600 100644
--- a/tempest/api/image/v1/test_images.py
+++ b/tempest/api/image/v1/test_images.py
@@ -30,13 +30,23 @@
     a_formats = ['ami', 'ari', 'aki']
 
     container_format = CONF.image.container_formats[0]
-    disk_format = CONF.image.disk_formats[0]
 
-    if container_format in a_formats and container_format != disk_format:
-        msg = ("The container format and the disk format don't match. "
-               "Container format: %(container)s, Disk format: %(disk)s." %
-               {'container': container_format, 'disk': disk_format})
-        raise exceptions.InvalidConfiguration(msg)
+    # In v1, If container_format is one of ['ami', 'ari', 'aki'], then
+    # disk_format must be same with container_format.
+    # If they are of different item sequence in tempest.conf, such as:
+    #     container_formats = ami,ari,aki,bare
+    #     disk_formats = ari,ami,aki,vhd
+    # we can select one in disk_format list that is same with container_format.
+    if container_format in a_formats:
+        if container_format in CONF.image.disk_formats:
+            disk_format = container_format
+        else:
+            msg = ("The container format and the disk format don't match. "
+                   "Container format: %(container)s, Disk format: %(disk)s." %
+                   {'container': container_format, 'disk': disk_format})
+            raise exceptions.InvalidConfiguration(msg)
+    else:
+        disk_format = CONF.image.disk_formats[0]
 
     return container_format, disk_format