diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-04-05 20:43:05 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-04-05 20:43:05 -0400 |
commit | 6a660b490ee6384055d2afb07f8cac1628168ba2 (patch) | |
tree | b730249941ebcd9e6053ec2eae97b56c2224311e /cloudinit | |
parent | 35802e8866be53016779f4f1eae9f026ccd18a61 (diff) | |
download | vyos-cloud-init-6a660b490ee6384055d2afb07f8cac1628168ba2.tar.gz vyos-cloud-init-6a660b490ee6384055d2afb07f8cac1628168ba2.zip |
write_files: fix decompression of content
When provided with gzipped data, an exception would be raised
because of a conversion to string.
This fixes the issue and adds a test for write_files.
LP: #1565638
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_write_files.py | 4 | ||||
-rw-r--r-- | cloudinit/distros/__init__.py | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/cloudinit/config/cc_write_files.py b/cloudinit/config/cc_write_files.py index 4b03ea91..351cfc8c 100644 --- a/cloudinit/config/cc_write_files.py +++ b/cloudinit/config/cc_write_files.py @@ -92,10 +92,10 @@ def decode_perms(perm, default, log): def extract_contents(contents, extraction_types): - result = str(contents) + result = contents for t in extraction_types: if t == 'application/x-gzip': - result = util.decomp_gzip(result, quiet=False) + result = util.decomp_gzip(result, quiet=False, decode=False) elif t == 'application/base64': result = base64.b64decode(result) elif t == UNKNOWN_ENC: diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 418421b9..12983c0a 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -933,7 +933,10 @@ def set_etc_timezone(tz, tz_file=None, tz_conf="/etc/timezone", # This ensures that the correct tz will be used for the system if tz_local and tz_file: # use a symlink if there exists a symlink or tz_local is not present - if os.path.islink(tz_local) or not os.path.exists(tz_local): + islink = os.path.islink(tz_local) + if islink or not os.path.exists(tz_local): + if islink: + util.del_file(tz_local) os.symlink(tz_file, tz_local) else: util.copy(tz_file, tz_local) |