From 9c1214fdedd1a6ee336f25f7f84079d5918c9ff5 Mon Sep 17 00:00:00 2001 From: ClaudiuNesa Date: Tue, 22 Jul 2014 18:16:15 +0300 Subject: [PATCH] Fixes Cinder volume upload to image on windows Due to fact that when uploading a volume to an image the file is opened in text mode and the different line endings style on windows glance client won't be able to upload the desired file. The solutions is to simply open the file in binary mode when performing this action. Change-Id: I51b084ce38e1aaad4ded63b75b097137dedc088c Closes-bug: 1346911 --- cinder/image/image_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cinder/image/image_utils.py b/cinder/image/image_utils.py index 6add9a8f3..1ef9e2876 100644 --- a/cinder/image/image_utils.py +++ b/cinder/image/image_utils.py @@ -240,7 +240,7 @@ def upload_volume(context, image_service, image_meta, volume_path, LOG.debug("%s was %s, no need to convert to %s" % (image_id, volume_format, image_meta['disk_format'])) if os.name == 'nt' or os.access(volume_path, os.R_OK): - with fileutils.file_open(volume_path) as image_file: + with fileutils.file_open(volume_path, 'rb') as image_file: image_service.update(context, image_id, {}, image_file) else: with utils.temporary_chown(volume_path): @@ -267,7 +267,7 @@ def upload_volume(context, image_service, image_meta, volume_path, reason=_("Converted to %(f1)s, but format is now %(f2)s") % {'f1': image_meta['disk_format'], 'f2': data.file_format}) - with fileutils.file_open(tmp) as image_file: + with fileutils.file_open(tmp, 'rb') as image_file: image_service.update(context, image_id, {}, image_file) fileutils.delete_if_exists(tmp) -- 2.45.2