[Openstack] Glance API semantics when image sizes aren't known

Ewan Mellor Ewan.Mellor at eu.citrix.com
Tue Nov 15 22:26:41 UTC 2011


> From: Ewan Mellor
> > From: Jay Pipes [mailto:jaypipes at gmail.com]
> > > From: Ewan Mellor
> > > ~ # cat test_glance.py
> > > import sys
> > > import glance.client
> > >
> > > client = glance.client.Client('localhost', 9292,
> > auth_tok="999888777666")
> > > print client.add_image({}, sys.stdin)
> > > ~ # echo a | python26 ./test_glance.py
> > > {u'status': u'active', u'name': None, u'deleted': False,
> > u'container_format': None, u'created_at': u'2011-11-15T21:44:21',
> > u'disk_format': None, u'updated_at': u'2011-11-15T21:44:22', u'id':
> 6,
> > u'owner': u'Administrator', u'location':
> > u'swift+http://root:password@localhost:5000/v1.0/glance/6',
> u'min_ram':
> > 0, u'checksum': u'60b725f10c9c85c70d97880dfe8191b3', u'min_disk': 0,
> > u'is_public': False, u'deleted_at': None, u'properties': {}, u'size':
> > 0}
> > >
> > > Note that size is returned as 0, not 1.
> >
> > Yes, indeed. That is because the client is not designed to be used
> > that way [snip]
> 
> But it could perfectly well be used this way, modulo the bug above, and
> this is a very useful thing to be able to do (stdin here could be a
> decompression or decryption pipeline, or a read from a remote socket,
> or
> whatever.
> 
> With the bug in the Swift backend fixed, I think it will work just fine
> to stream through a glance client in this way.

Erm, well it will until we hit the 5GB Swift chunking limit, anyway.

Do you know what this means (glance/store/swift.py +347)?
Why can't we stream from body_file?

            else:
                # Write the image into Swift in chunks. We cannot
                # stream chunks of the webob.Request.body_file, unfortunately,
                # so we must write chunks of the body_file into a temporary
                # disk buffer, and then pass this disk buffer to Swift.

Thanks,

Ewan.



More information about the Openstack mailing list