summaryrefslogtreecommitdiff
path: root/cloudinit/sources/helpers
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/sources/helpers
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/sources/helpers')
-rw-r--r--cloudinit/sources/helpers/openstack.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py
index 156aba6c..3ccb11d3 100644
--- a/cloudinit/sources/helpers/openstack.py
+++ b/cloudinit/sources/helpers/openstack.py
@@ -190,14 +190,14 @@ class BaseReader(object):
versions_available)
return selected_version
- def _read_content_path(self, item):
+ def _read_content_path(self, item, decode=False):
path = item.get('content_path', '').lstrip("/")
path_pieces = path.split("/")
valid_pieces = [p for p in path_pieces if len(p)]
if not valid_pieces:
raise BrokenMetadata("Item %s has no valid content path" % (item))
path = self._path_join(self.base_path, "openstack", *path_pieces)
- return self._path_read(path)
+ return self._path_read(path, decode=decode)
def read_v2(self):
"""Reads a version 2 formatted location.
@@ -298,7 +298,8 @@ class BaseReader(object):
net_item = metadata.get("network_config", None)
if net_item:
try:
- results['network_config'] = self._read_content_path(net_item)
+ content = self._read_content_path(net_item, decode=True)
+ results['network_config'] = content
except IOError as e:
raise BrokenMetadata("Failed to read network"
" configuration: %s" % (e))
@@ -333,8 +334,8 @@ class ConfigDriveReader(BaseReader):
components = [base] + list(add_ons)
return os.path.join(*components)
- def _path_read(self, path):
- return util.load_file(path, decode=False)
+ def _path_read(self, path, decode=False):
+ return util.load_file(path, decode=decode)
def _fetch_available_versions(self):
if self._versions is None:
@@ -446,7 +447,7 @@ class MetadataReader(BaseReader):
self._versions = found
return self._versions
- def _path_read(self, path):
+ def _path_read(self, path, decode=False):
def should_retry_cb(_request_args, cause):
try:
@@ -463,7 +464,10 @@ class MetadataReader(BaseReader):
ssl_details=self.ssl_details,
timeout=self.timeout,
exception_cb=should_retry_cb)
- return response.contents
+ if decode:
+ return response.contents.decode()
+ else:
+ return response.contents
def _path_join(self, base, *add_ons):
return url_helper.combine_url(base, *add_ons)