Merge "Create image directly in 'copy_from' and 'location' case"

This commit is contained in:
Jenkins 2015-07-28 10:00:34 +00:00 committed by Gerrit Code Review
commit f08f3fa370
1 changed files with 15 additions and 12 deletions

View File

@ -126,9 +126,22 @@ def image_update(request, image_id, **kwargs):
def image_create(request, **kwargs):
copy_from = kwargs.pop('copy_from', None)
"""Create image.
Keyword arguments:
copy_from -- URL from which Glance server should immediately copy
the data and store it in its configured image store.
data -- Form data posted from client.
location -- URL where the data for this image already resides.
In the case of 'copy_from' and 'location' the Glance server
will give us a immediate response from create and handle the data
asynchronously.
In the case of 'data' the process of uploading the data may take
some time and is handed off to a seperate thread.
"""
data = kwargs.pop('data', None)
location = kwargs.pop('location', None)
image = glanceclient(request).images.create(**kwargs)
@ -146,16 +159,6 @@ def image_create(request, **kwargs):
(request, image.id),
{'data': data,
'purge_props': False})
elif copy_from:
thread.start_new_thread(image_update,
(request, image.id),
{'copy_from': copy_from,
'purge_props': False})
elif location:
thread.start_new_thread(image_update,
(request, image.id),
{'location': location,
'purge_props': False})
return image