summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-06-21 11:23:52 -0400
committerScott Moser <smoser@ubuntu.com>2016-06-21 11:23:52 -0400
commitfd816e7e1f9c48d7ab89958f6eee7677fb310932 (patch)
tree7544ffdc0d80931b230a8fd9e58350698b8bef92
parent575c7030e4ff1bd68ca7229f10c482af00620711 (diff)
parente6b594bf2bf4cd40bbfbe9581c2b62f3b77e9123 (diff)
downloadvyos-cloud-init-fd816e7e1f9c48d7ab89958f6eee7677fb310932.tar.gz
vyos-cloud-init-fd816e7e1f9c48d7ab89958f6eee7677fb310932.zip
merge with trunk
-rw-r--r--cloudinit/distros/debian.py10
-rw-r--r--cloudinit/net/__init__.py5
-rw-r--r--cloudinit/net/eni.py4
3 files changed, 17 insertions, 2 deletions
diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py
index 53f3aa4d..5ae9a509 100644
--- a/cloudinit/distros/debian.py
+++ b/cloudinit/distros/debian.py
@@ -43,6 +43,13 @@ APT_GET_WRAPPER = {
'enabled': 'auto',
}
+ENI_HEADER = """# This file is generated from information provided by
+# the datasource. Changes to it will not persist across an instance.
+# To disable cloud-init's network configuration capabilities, write a file
+# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
+# network: {config: disabled}
+"""
+
class Distro(distros.Distro):
hostname_conf_fn = "/etc/hostname"
@@ -59,7 +66,8 @@ class Distro(distros.Distro):
self.osfamily = 'debian'
self._net_renderer = eni.Renderer({
'eni_path': self.network_conf_fn,
- 'links_prefix_path': self.links_prefix,
+ 'eni_header': ENI_HEADER,
+ 'links_prefix_path': None,
'netrules_path': None,
})
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
index 6959ad34..63e54f91 100644
--- a/cloudinit/net/__init__.py
+++ b/cloudinit/net/__init__.py
@@ -237,6 +237,11 @@ def _get_current_rename_info(check_downable=True):
def _rename_interfaces(renames, strict_present=True, strict_busy=True,
current_info=None):
+
+ if not len(renames):
+ LOG.debug("no interfaces to rename")
+ return
+
if current_info is None:
current_info = _get_current_rename_info()
diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py
index 2da13ffd..1c66319a 100644
--- a/cloudinit/net/eni.py
+++ b/cloudinit/net/eni.py
@@ -306,6 +306,7 @@ class Renderer(renderer.Renderer):
if not config:
config = {}
self.eni_path = config.get('eni_path', 'etc/network/interfaces')
+ self.eni_header = config.get('eni_header', None)
self.links_path_prefix = config.get(
'links_path_prefix', 'etc/systemd/network/50-cloud-init-')
self.netrules_path = config.get(
@@ -442,7 +443,8 @@ class Renderer(renderer.Renderer):
def render_network_state(self, target, network_state):
fpeni = os.path.join(target, self.eni_path)
util.ensure_dir(os.path.dirname(fpeni))
- util.write_file(fpeni, self._render_interfaces(network_state))
+ header = self.eni_header if self.eni_header else ""
+ util.write_file(fpeni, header + self._render_interfaces(network_state))
if self.netrules_path:
netrules = os.path.join(target, self.netrules_path)