From 99aa842e978a6b377865cb9ca393a365bf8eb742 Mon Sep 17 00:00:00 2001 From: Nicolas Simonds Date: Thu, 22 May 2014 18:27:42 -0700 Subject: [PATCH] Image uploads should always happen in the background Sufficiently large image uploads into Glance from Horizon can cause timeout errors, since the image upload needs to complete before the view can render, and such activities can cause browser timeouts. Since the webserver already has the file, and close-to-open semantics should prevent cleanups from losing any data, just send it in a background thread, the same way as if you told Horizon to fetch it from a remote location. Change-Id: Ia056367032e0d08edf6f36a8e9f900fddba85fdf Closes-Bug: 1322399 --- openstack_dashboard/api/glance.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/openstack_dashboard/api/glance.py b/openstack_dashboard/api/glance.py index 24c5cebb03..07c7824fc4 100644 --- a/openstack_dashboard/api/glance.py +++ b/openstack_dashboard/api/glance.py @@ -90,14 +90,17 @@ def image_update(request, image_id, **kwargs): def image_create(request, **kwargs): - copy_from = None - - if kwargs.get('copy_from'): - copy_from = kwargs.pop('copy_from') + copy_from = kwargs.pop('copy_from', None) + data = kwargs.pop('data', None) image = glanceclient(request).images.create(**kwargs) - if copy_from: + if data: + thread.start_new_thread(image_update, + (request, image.id), + {'data': data, + 'purge_props': False}) + elif copy_from: thread.start_new_thread(image_update, (request, image.id), {'copy_from': copy_from,