summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-02-24 16:19:02 -0500
committerScott Moser <smoser@ubuntu.com>2015-02-24 16:19:02 -0500
commite2fea567772f3d178072607aee617c3792185db0 (patch)
treeee847a8178edc1706b2b16671f042c948c3f3d76 /cloudinit
parent4770c61cf1a114348c763094c4cfd3d007894b0d (diff)
downloadvyos-cloud-init-e2fea567772f3d178072607aee617c3792185db0.tar.gz
vyos-cloud-init-e2fea567772f3d178072607aee617c3792185db0.zip
further fixing of non-text user-data.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/stages.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index c5b1ded0..94fcf4cc 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -327,16 +327,26 @@ class Init(object):
self._store_vendordata()
def _store_userdata(self):
- raw_ud = "%s" % (self.datasource.get_userdata_raw())
+ raw_ud = self.datasource.get_userdata_raw()
+ if raw_ud is None:
+ raw_ud = b''
util.write_file(self._get_ipath('userdata_raw'), raw_ud, 0o600)
- processed_ud = "%s" % (self.datasource.get_userdata())
- util.write_file(self._get_ipath('userdata'), processed_ud, 0o600)
+ # processed userdata is a Mime message, so write it as string.
+ processed_ud = self.datasource.get_userdata()
+ if processed_ud is None:
+ raw_ud = ''
+ util.write_file(self._get_ipath('userdata'), str(processed_ud), 0o600)
def _store_vendordata(self):
- raw_vd = "%s" % (self.datasource.get_vendordata_raw())
+ raw_vd = self.datasource.get_vendordata_raw()
+ if raw_vd is None:
+ raw_vd = b''
util.write_file(self._get_ipath('vendordata_raw'), raw_vd, 0o600)
- processed_vd = "%s" % (self.datasource.get_vendordata())
- util.write_file(self._get_ipath('vendordata'), processed_vd, 0o600)
+ # processed vendor data is a Mime message, so write it as string.
+ processed_vd = str(self.datasource.get_vendordata())
+ if processed_vd is None:
+ processed_vd = ''
+ util.write_file(self._get_ipath('vendordata'), str(processed_vd), 0o600)
def _default_handlers(self, opts=None):
if opts is None: