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 | |
| 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')
| -rw-r--r-- | cloudinit/CloudConfig/cc_apt_update_upgrade.py | 2 | ||||
| -rw-r--r-- | cloudinit/util.py | 7 | 
2 files changed, 5 insertions, 4 deletions
| diff --git a/cloudinit/CloudConfig/cc_apt_update_upgrade.py b/cloudinit/CloudConfig/cc_apt_update_upgrade.py index e1226c85..396c5e09 100644 --- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py +++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py @@ -142,7 +142,7 @@ def add_sources(srclist):              except:                  elst.append([source, "failed add key"]) -        try: util.write_file(ent['filename'], source + "\n") +        try: util.write_file(ent['filename'], source + "\n", omode="ab")          except:              elst.append([source, "failed write to file %s" % ent['filename']]) 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() | 
