diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-23 11:00:37 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-23 11:00:37 -0400 |
commit | d32116c3468e5c394b56d078ceef86d416d83b3a (patch) | |
tree | 6c92d8bc5edfd9726106946bd57e9c8acc26f86a /bin/cloud-init | |
parent | 6082a5b0c2b1a52ddbf63bfd80331f28f8cdc4fa (diff) | |
parent | 5b3cad36be8981cd12cffdf5c5e539b522404000 (diff) | |
download | vyos-cloud-init-d32116c3468e5c394b56d078ceef86d416d83b3a.tar.gz vyos-cloud-init-d32116c3468e5c394b56d078ceef86d416d83b3a.zip |
merge from trunk.net1
Diffstat (limited to 'bin/cloud-init')
-rwxr-xr-x | bin/cloud-init | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/bin/cloud-init b/bin/cloud-init index 11cc0237..341359e3 100755 --- a/bin/cloud-init +++ b/bin/cloud-init @@ -263,6 +263,10 @@ def main_init(name, args): return (None, []) else: return (None, ["No instance datasource found."]) + + if args.local: + init.apply_network_config() + # Stage 6 iid = init.instancify() LOG.debug("%s will now be targeting instance id: %s", name, iid) @@ -325,7 +329,7 @@ def main_modules(action_name, args): init.read_cfg(extract_fns(args)) # Stage 2 try: - init.fetch() + init.fetch(existing="trust") except sources.DataSourceNotFoundException: # There was no datasource found, theres nothing to do msg = ('Can not apply stage %s, no datasource found! Likely bad ' @@ -379,7 +383,7 @@ def main_single(name, args): init.read_cfg(extract_fns(args)) # Stage 2 try: - init.fetch() + init.fetch(existing="trust") except sources.DataSourceNotFoundException: # There was no datasource found, # that might be bad (or ok) depending on @@ -432,20 +436,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) 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") |