summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-02-24 20:47:35 -0500
committerScott Moser <smoser@ubuntu.com>2014-02-24 20:47:35 -0500
commitaf6b25e0b8895e8eead0a7202d637fa197c4401c (patch)
tree6ed26d3e512e05cbca3d89d7539007967c53345d /bin
parent4055b6d303da775580ab299145788c0cd16c0d45 (diff)
downloadvyos-cloud-init-af6b25e0b8895e8eead0a7202d637fa197c4401c.tar.gz
vyos-cloud-init-af6b25e0b8895e8eead0a7202d637fa197c4401c.zip
minor cleanups
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cloud-init19
1 files changed, 11 insertions, 8 deletions
diff --git a/bin/cloud-init b/bin/cloud-init
index 78f8600d..479d715d 100755
--- a/bin/cloud-init
+++ b/bin/cloud-init
@@ -419,6 +419,10 @@ def main_single(name, args):
return 0
+def write_json(path, data):
+ util.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")
@@ -472,7 +476,7 @@ def status_wrapper(name, args, data_d=None, link_d=None):
v1['stage'] = mode
v1[mode]['start'] = time.time()
- util.write_file(status_path, json.dumps(status))
+ write_json(status, status_path)
util.sym_link(os.path.relpath(status_path, link_d), status_link,
force=True)
@@ -481,11 +485,11 @@ def status_wrapper(name, args, data_d=None, link_d=None):
if mode in ('init', 'init-local'):
(datasource, errors) = ret
if datasource is not None:
- v1['datasource'] = datasource
- v1[mode]['errors'] = errors
+ v1['datasource'] = str(datasource)
else:
errors = ret
- v1[mode]['errors'] = ret
+
+ v1[mode]['errors'] = [str(e) for e in errors]
except Exception as e:
v1[mode]['errors'] = [str(e)]
@@ -493,7 +497,7 @@ def status_wrapper(name, args, data_d=None, link_d=None):
v1[mode]['finished'] = time.time()
v1['stage'] = None
- util.write_file(status_path, json.dumps(status))
+ write_json(status_path, status)
if mode == "modules-final":
# write the 'finished' file
@@ -502,9 +506,8 @@ def status_wrapper(name, args, data_d=None, link_d=None):
if v1[m]['errors']:
errors.extend(v1[m].get('errors', []))
- finished = {'datasource': v1['datasource'],
- 'errors': errors}
- util.write_file(result_path, json.dumps(finished))
+ write_json(result_path,
+ {'datasource': v1['datasource'], 'errors': errors})
util.sym_link(os.path.relpath(result_path, link_d), result_link,
force=True)