[openstack-dev] Create a tar.gz stream from a block device

Mate Lakat mate.lakat at citrix.com
Wed Aug 14 15:58:33 UTC 2013


Hi Stackers,

I would like to create a readable tar.gz stream, inside that stream I
want to see only one file, and that file's content should be read from a
device.

The virtual disk is attached to domU as a block device (/dev/xvdb)
I would like to produce a tar.gz, that contains the contents of
/dev/xvdb, file name inside the tar.gz does not matter.

Here is my current solution:
    https://review.openstack.org/41651

The main problem is, that tarfile does not support adding content
incrementaly, it only has a addfile method:
    http://docs.python.org/2/library/tarfile.html

    tfile = tarfile.open(fileobj=output, mode='w|gz')
    ...
    tfile.addfile(tinfo, fileobj=input_file)

And for the glance client, I need to provide a readable file-like:

    image_service.update(self.context, image_id, metadata,
                         image_stream, purge_props=False)

The change is solving the issue by creating a separate process to create
the targz stream, and give that process' output stream to glance.

Any other ideas?

Many thanks,
-- 
Mate Lakat



More information about the OpenStack-dev mailing list