]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes Cinder volume upload to image on windows
authorClaudiuNesa <cnesa@cloudbasesolutions.com>
Tue, 22 Jul 2014 15:16:15 +0000 (18:16 +0300)
committerClaudiuNesa <cnesa@cloudbasesolutions.com>
Wed, 23 Jul 2014 17:54:36 +0000 (20:54 +0300)
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

index 6add9a8f30e6ed2678b8adcf339537692fdd8881..1ef9e287662937407210a0a88c3a08281fb2af47 100644 (file)
@@ -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)