From b84da5e84ef92e653084faed402bcac6271f1dfc Mon Sep 17 00:00:00 2001 From: Michal Arbet <michal.arbet@ultimum.io> Date: Wed, 30 May 2018 10:56:47 +0000 Subject: [PATCH] Fix issue with uploading image to glance on Python3 It was unable to upload image when horizon was running on python3, there was a problem with closed file in new thread. This commit is fixing this issue with added if clause whether horizon running on python2 or python3 and correctly call close_called on file when running on python3. Change-Id: Ice178f6269ac527ba62b26d86976b5336987c922 Closes-Bug: #1773935 --- openstack_dashboard/api/glance.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openstack_dashboard/api/glance.py b/openstack_dashboard/api/glance.py index 29c064a12b..5ee121730d 100644 --- a/openstack_dashboard/api/glance.py +++ b/openstack_dashboard/api/glance.py @@ -525,7 +525,10 @@ def image_create(request, **kwargs): return ExternallyUploadedImage(image, request) elif isinstance(data, TemporaryUploadedFile): # Hack to fool Django, so we can keep file open in the new thread. - data.file.close_called = True + if six.PY2: + data.file.close_called = True + else: + data.file._closer.close_called = True elif isinstance(data, InMemoryUploadedFile): # Clone a new file for InMemeoryUploadedFile. # Because the old one will be closed by Django.