Fixes ConfigDrive bug on Windows

Files must be written specifying "wb" instead of "w"
to support binary files on both Windows and Linux.

Closes-Bug: #1261585

(cherry-picked from commit 1fc9eafab4)

Change-Id: I069845136df4a11b54c931a71575ca3efb9bc6d0
This commit is contained in:
Alessandro Pilotti 2013-12-17 02:05:11 +02:00 committed by Petrut Lucian
parent 13a9f6fdf0
commit fd45b41ba3
1 changed files with 2 additions and 2 deletions

View File

@ -88,7 +88,7 @@ class ConfigDriveBuilder(object):
filepath = os.path.join(self.tempdir, path)
dirname = os.path.dirname(filepath)
fileutils.ensure_tree(dirname)
with open(filepath, 'w') as f:
with open(filepath, 'wb') as f:
f.write(data)
def add_instance_metadata(self, instance_md):
@ -122,7 +122,7 @@ class ConfigDriveBuilder(object):
def _make_vfat(self, path):
# NOTE(mikal): This is a little horrible, but I couldn't find an
# equivalent to genisoimage for vfat filesystems.
with open(path, 'w') as f:
with open(path, 'wb') as f:
f.truncate(CONFIGDRIVESIZE_BYTES)
utils.mkfs('vfat', path, label='config-2')