summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-24 17:30:57 -0400
committerScott Moser <smoser@ubuntu.com>2016-03-24 17:30:57 -0400
commit18bf614ca1d9fbabdf83495e7675a2cacaf6c2f4 (patch)
treede2352926ea476abcafcdb14790ea21958973db9 /bin
parent4f2065ad569355d5d0bc54176bde6b8e55047341 (diff)
parent20cc8113dde9e6849e8a692aea64cf81a266406d (diff)
downloadvyos-cloud-init-18bf614ca1d9fbabdf83495e7675a2cacaf6c2f4.tar.gz
vyos-cloud-init-18bf614ca1d9fbabdf83495e7675a2cacaf6c2f4.zip
support network configuration in cloud-init --local
this allows 'cloud-init --local' to fully run before networking comes up. By doing so, we can now cleanly apply networking to the new system. This adds support for reading ConfigDrive network configuration and also from NoCloud. The support is only present for ubuntu/debian at the current time. Other distros will follow. Also ability to specify network configuration on kernel command line via either ip= or network-config=<base64>.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cloud-init20
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")