summaryrefslogtreecommitdiff
path: root/cloudinit/helpers.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-06-03 16:22:19 -0400
committerScott Moser <smoser@ubuntu.com>2016-06-03 16:22:19 -0400
commitbc9bd58d1533d996029770da758f73217c15af33 (patch)
tree04a23063e872352604042a16171f908f7a8abb83 /cloudinit/helpers.py
parente513fc39555242f0be3049fb36eb04e708e70e66 (diff)
parent42a7d2b6d44be5fd6e41734902e08897b709015d (diff)
downloadvyos-cloud-init-bc9bd58d1533d996029770da758f73217c15af33.tar.gz
vyos-cloud-init-bc9bd58d1533d996029770da758f73217c15af33.zip
improve network configuration
This branch accomplishes several things: - centrally handle 'dsmode' to be 'local' or 'net. This allows local data sources to run before networking but still have user-data read by default when networking is available. - support networking information being read on dreamcompute dreamcompute's openstack declares networking via the /etc/network/interfaces style 'network_config' format. - support reading and applying networking information on SmartOS - improve reading networking from openstack network_data.json (LP: #1577982) add support for mtu and routes and many miscellaneous fixes. - support for renaming devices in a container (LP: #1579130). Also rename network devices as instructed by the host on every boot where cloud-init networking is enabled. This is required because a.) containers do not get systemd.link files applied as they do not have udev. b.) if the initramfs is out of date then we need to apply them. - remove blocking of udev rules (LP: #1577844, LP: #1571761) LP: #1577982, #1579130, #1577844, #1571761
Diffstat (limited to 'cloudinit/helpers.py')
-rw-r--r--cloudinit/helpers.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
index 09d75e65..fb95babc 100644
--- a/cloudinit/helpers.py
+++ b/cloudinit/helpers.py
@@ -328,6 +328,7 @@ class Paths(object):
self.cfgs = path_cfgs
# Populate all the initial paths
self.cloud_dir = path_cfgs.get('cloud_dir', '/var/lib/cloud')
+ self.run_dir = path_cfgs.get('run_dir', '/run/cloud-init')
self.instance_link = os.path.join(self.cloud_dir, 'instance')
self.boot_finished = os.path.join(self.instance_link, "boot-finished")
self.upstart_conf_d = path_cfgs.get('upstart_dir')
@@ -349,26 +350,19 @@ class Paths(object):
"data": "data",
"vendordata_raw": "vendor-data.txt",
"vendordata": "vendor-data.txt.i",
+ "instance_id": ".instance-id",
}
# Set when a datasource becomes active
self.datasource = ds
# get_ipath_cur: get the current instance path for an item
def get_ipath_cur(self, name=None):
- ipath = self.instance_link
- add_on = self.lookups.get(name)
- if add_on:
- ipath = os.path.join(ipath, add_on)
- return ipath
+ return self._get_path(self.instance_link, name)
# get_cpath : get the "clouddir" (/var/lib/cloud/<name>)
# for a name in dirmap
def get_cpath(self, name=None):
- cpath = self.cloud_dir
- add_on = self.lookups.get(name)
- if add_on:
- cpath = os.path.join(cpath, add_on)
- return cpath
+ return self._get_path(self.cloud_dir, name)
# _get_ipath : get the instance path for a name in pathmap
# (/var/lib/cloud/instances/<instance>/<name>)
@@ -397,6 +391,14 @@ class Paths(object):
else:
return ipath
+ def _get_path(self, base, name=None):
+ if name is None:
+ return base
+ return os.path.join(base, self.lookups[name])
+
+ def get_runpath(self, name=None):
+ return self._get_path(self.run_dir, name)
+
# This config parser will not throw when sections don't exist
# and you are setting values on those sections which is useful