diff options
author | Scott Moser <smoser@ubuntu.com> | 2010-08-31 14:35:36 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2010-08-31 14:35:36 -0400 |
commit | 3cfdf654f65882ae3d618b6e7d17d03bf08f9fcb (patch) | |
tree | 4aa8e1226be79ee6a743515dab6597138605477f /cloudinit/util.py | |
parent | 961b1a53ade1d502cfb8fbe393abba4556008d18 (diff) | |
download | vyos-cloud-init-3cfdf654f65882ae3d618b6e7d17d03bf08f9fcb.tar.gz vyos-cloud-init-3cfdf654f65882ae3d618b6e7d17d03bf08f9fcb.zip |
append to apt_sources filenames rather than truncating.
Previously,
apt_sources:
- source: source1
- source: source2
resulted in source1 being written to
/etc/apt/sources.list.d/cloud_config_sources.list , and then
that being overwritten by source2.
This definitely is not expected.
Instead, in all cases now, (including 'filename:' cases), just append.
LP: #627597
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index be84bfdc..c1b4fd2d 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -76,15 +76,16 @@ def mergedict(src,cand): src[k] = mergedict(src[k],v) return src -def write_file(file,content,mode=0644): +def write_file(file,content,mode=0644,omode="wb"): try: os.makedirs(os.path.dirname(file)) except OSError as e: if e.errno != errno.EEXIST: raise e - f=open(file,"wb") - os.chmod(file,mode) + f=open(file,omode) + if mode != None: + os.chmod(file,mode) f.write(content) f.close() |