summaryrefslogtreecommitdiff
path: root/bin/cloud-init
diff options
context:
space:
mode:
Diffstat (limited to 'bin/cloud-init')
-rwxr-xr-xbin/cloud-init12
1 files changed, 8 insertions, 4 deletions
diff --git a/bin/cloud-init b/bin/cloud-init
index 7f665e7e..42166580 100755
--- a/bin/cloud-init
+++ b/bin/cloud-init
@@ -435,20 +435,24 @@ def main_single(name, args):
return 0
-def atomic_write_json(path, data):
+def atomic_write_file(path, content, mode='w'):
tf = None
try:
tf = tempfile.NamedTemporaryFile(dir=os.path.dirname(path),
- delete=False)
- tf.write(util.encode_text(json.dumps(data, indent=1) + "\n"))
+ delete=False, mode=mode)
+ tf.write(content)u
tf.close()
os.rename(tf.name, path)
except Exception as e:
if tf is not None:
- util.del_file(tf.name)
+ os.unlink(tf.name)
raise e
+def atomic_write_json(path, data):
+ return atomic_write_file(path, json.dumps(data, indent=1) + "\n")
+
+
def status_wrapper(name, args, data_d=None, link_d=None):
if data_d is None:
data_d = os.path.normpath("/var/lib/cloud/data")