From 3cfdf654f65882ae3d618b6e7d17d03bf08f9fcb Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 31 Aug 2010 14:35:36 -0400 Subject: 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 --- cloudinit/util.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cloudinit/util.py') 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() -- cgit v1.2.3