diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-07-13 22:14:13 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-07-13 22:14:13 -0400 |
commit | e1d68c11c44ab11acf3f7b234a1db45d85ae19de (patch) | |
tree | 9b7c46af243ebf14590eb711f05f243d8ba56cf8 /cloudinit | |
parent | 2a8dc75a5b8ab42ca805f2ec6b97dc7a074e82f3 (diff) | |
parent | b3193a4b5204d12825d8317bf0f8c3577c1d8153 (diff) | |
download | vyos-cloud-init-e1d68c11c44ab11acf3f7b234a1db45d85ae19de.tar.gz vyos-cloud-init-e1d68c11c44ab11acf3f7b234a1db45d85ae19de.zip |
merge with trunk
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_write_files.py | 2 | ||||
-rw-r--r-- | cloudinit/distros/debian.py | 3 | ||||
-rw-r--r-- | cloudinit/sources/__init__.py | 3 | ||||
-rw-r--r-- | cloudinit/user_data.py | 28 |
4 files changed, 21 insertions, 15 deletions
diff --git a/cloudinit/config/cc_write_files.py b/cloudinit/config/cc_write_files.py index 351cfc8c..b1096b9b 100644 --- a/cloudinit/config/cc_write_files.py +++ b/cloudinit/config/cc_write_files.py @@ -79,6 +79,8 @@ def write_files(name, files, log): def decode_perms(perm, default, log): + if perm is None: + return default try: if isinstance(perm, six.integer_types + (float,)): # Just 'downcast' it (if a float) diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py index 5ae9a509..f9b3b92e 100644 --- a/cloudinit/distros/debian.py +++ b/cloudinit/distros/debian.py @@ -55,7 +55,6 @@ class Distro(distros.Distro): hostname_conf_fn = "/etc/hostname" locale_conf_fn = "/etc/default/locale" network_conf_fn = "/etc/network/interfaces.d/50-cloud-init.cfg" - links_prefix = "/etc/systemd/network/50-cloud-init-" def __init__(self, name, cfg, paths): distros.Distro.__init__(self, name, cfg, paths) @@ -67,7 +66,7 @@ class Distro(distros.Distro): self._net_renderer = eni.Renderer({ 'eni_path': self.network_conf_fn, 'eni_header': ENI_HEADER, - 'links_prefix_path': None, + 'links_path_prefix': None, 'netrules_path': None, }) diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index 2a6b8d90..87b8e524 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -55,6 +55,8 @@ class DataSourceNotFoundException(Exception): @six.add_metaclass(abc.ABCMeta) class DataSource(object): + dsmode = DSMODE_NETWORK + def __init__(self, sys_cfg, distro, paths, ud_proc=None): self.sys_cfg = sys_cfg self.distro = distro @@ -64,7 +66,6 @@ class DataSource(object): self.userdata_raw = None self.vendordata = None self.vendordata_raw = None - self.dsmode = DSMODE_NETWORK # find the datasource config name. # remove 'DataSource' from classname on front, and remove 'Net' on end. diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py index f0631906..393bf0bb 100644 --- a/cloudinit/user_data.py +++ b/cloudinit/user_data.py @@ -334,19 +334,23 @@ def is_skippable(part): # Coverts a raw string into a mime message -def convert_string(raw_data, headers=None): +def convert_string(raw_data, content_type=NOT_MULTIPART_TYPE): if not raw_data: raw_data = '' - if not headers: - headers = {} - data = util.decode_binary(util.decomp_gzip(raw_data)) - if "mime-version:" in data[0:4096].lower(): - msg = util.message_from_string(data) - for (key, val) in headers.items(): - _replace_header(msg, key, val) - else: - mtype = headers.get(CONTENT_TYPE, NOT_MULTIPART_TYPE) - maintype, subtype = mtype.split("/", 1) - msg = MIMEBase(maintype, subtype, *headers) + + def create_binmsg(data, content_type): + maintype, subtype = content_type.split("/", 1) + msg = MIMEBase(maintype, subtype) msg.set_payload(data) + return msg + + try: + data = util.decode_binary(util.decomp_gzip(raw_data)) + if "mime-version:" in data[0:4096].lower(): + msg = util.message_from_string(data) + else: + msg = create_binmsg(data, content_type) + except UnicodeDecodeError: + msg = create_binmsg(raw_data, content_type) + return msg |