[glance] Question about container_format and disk_format

Andre Florath andre at florath.net
Thu Jan 3 08:07:45 UTC 2019


After digging through the source code, I'd answer my own question:

image disk_format and container_format are

(A) the formats of the image file that is passed in.


Glance's so called flows use those parameters as input
like ovf_process.py [1]:

        if image.container_format == 'ova':

When there is a conversion done in the flow, the target
format is the one from the configuration (like [2]):

        target_format = CONF.image_conversion.output_format

After a possible conversion, the new disk and container formats are
set (e.g. [3]):

        image.disk_format = target_format
        image.container_format = 'bare'

(At some points instead of using the disk and container format
parameters, a call to 'qemu-img info' is done to extract those
information from the image - like in [4]:

        stdout, stderr = putils.trycmd("qemu-img", "info",
                                       "--output=json", ...
        metadata = json.loads(stdout)
        source_format = metadata.get('format')

So it looks that the idea is, that the disk_format and
container_format should always reflect the current format of the

Can anybody please confirm / comment?

Kind regards


[1] https://git.openstack.org/cgit/openstack/glance/tree/glance/async_/flows/ovf_process.py#n87
[2] https://git.openstack.org/cgit/openstack/glance/tree/glance/async_/flows/plugins/image_conversion.py#n78
[3] https://git.openstack.org/cgit/openstack/glance/tree/glance/async_/flows/plugins/image_conversion.py#n129
[4] https://git.openstack.org/cgit/openstack/glance/tree/glance/async_/flows/plugins/image_conversion.py#n87

On 12/18/18 11:07 AM, Andre Florath wrote:
> Hello!
> I do not completely understand the parameters 'container_format'
> and 'disk_format' as described in [1]. The documentation always
> uses 'the format' but IMHO there might be two formats involved.
> Are those formats either
> (A) the formats of the image file that is passed in.
>     Like (from the official documentation [2])
>     $ openstack image create --disk-format qcow2 --container-format bare \
>          --public --file ./centos63.qcow2 centos63-image
>     qcow2 / bare are the formats of the passed in image.
> or
> (B) the formats that are used internally to store the image
>     Like
>     $ openstack image create --disk-format vmdk --container-format ova \
>          --public --file ./centos63.qcow2 centos63-image
>     vmdk / ova are formats that are used internally in OpenStack glance
>     to store the image.
>     In this case there must be an auto-detection of the image file format
>     that is passed in and an automatic conversion into the new format.
> Kind regards
> Andre
> [1] https://developer.openstack.org/api-ref/image/v2/index.html?expanded=create-image-detail#create-image
> [2] https://docs.openstack.org/glance/pike/admin/manage-images.html

More information about the openstack-discuss mailing list