summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-05-25 15:37:15 -0500
committerScott Moser <smoser@brickies.net>2017-05-31 13:08:43 -0400
commit003c6678e9c873b3b787a814016872b6592f5069 (patch)
treef2fe8634229ec869ced9eb4eceb5db37513141e5
parent4a60af54957634920e84a928aa22b4fc9a6dfd11 (diff)
downloadvyos-cloud-init-003c6678e9c873b3b787a814016872b6592f5069.tar.gz
vyos-cloud-init-003c6678e9c873b3b787a814016872b6592f5069.zip
net: remove systemd link file writing from eni renderer
During the network v2 merge, we inadvertently re-enabled rendering systemd .link files. This files are not required as cloud-init already has to do interface renaming due to issues with udevd which may refuse to rename certain interfaces (such as veth devices in a LXD container). As such, removing the code altogether.
-rw-r--r--cloudinit/net/eni.py25
-rw-r--r--tests/unittests/test_net.py9
2 files changed, 3 insertions, 31 deletions
diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py
index 9819d4f5..0cc4e3b2 100644
--- a/cloudinit/net/eni.py
+++ b/cloudinit/net/eni.py
@@ -304,8 +304,6 @@ class Renderer(renderer.Renderer):
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(
'netrules_path', 'etc/udev/rules.d/70-persistent-net.rules')
@@ -451,28 +449,6 @@ class Renderer(renderer.Renderer):
util.write_file(netrules,
self._render_persistent_net(network_state))
- if self.links_path_prefix:
- self._render_systemd_links(target, network_state,
- links_prefix=self.links_path_prefix)
-
- def _render_systemd_links(self, target, network_state, links_prefix):
- fp_prefix = util.target_path(target, links_prefix)
- for f in glob.glob(fp_prefix + "*"):
- os.unlink(f)
- for iface in network_state.iter_interfaces():
- if (iface['type'] == 'physical' and 'name' in iface and
- iface.get('mac_address')):
- fname = fp_prefix + iface['name'] + ".link"
- content = "\n".join([
- "[Match]",
- "MACAddress=" + iface['mac_address'],
- "",
- "[Link]",
- "Name=" + iface['name'],
- ""
- ])
- util.write_file(fname, content)
-
def network_state_to_eni(network_state, header=None, render_hwaddress=False):
# render the provided network state, return a string of equivalent eni
@@ -480,7 +456,6 @@ def network_state_to_eni(network_state, header=None, render_hwaddress=False):
renderer = Renderer(config={
'eni_path': eni_path,
'eni_header': header,
- 'links_path_prefix': None,
'netrules_path': None,
})
if not header:
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 167ed01e..5a0fcbcf 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -992,9 +992,7 @@ class TestEniNetRendering(CiTestCase):
os.makedirs(render_dir)
renderer = eni.Renderer(
- {'links_path_prefix': None,
- 'eni_path': 'interfaces', 'netrules_path': None,
- })
+ {'eni_path': 'interfaces', 'netrules_path': None})
renderer.render_network_state(ns, render_dir)
self.assertTrue(os.path.exists(os.path.join(render_dir,
@@ -1376,7 +1374,7 @@ class TestNetplanRoundTrip(CiTestCase):
class TestEniRoundTrip(CiTestCase):
def _render_and_read(self, network_config=None, state=None, eni_path=None,
- links_prefix=None, netrules_path=None, dir=None):
+ netrules_path=None, dir=None):
if dir is None:
dir = self.tmp_dir()
@@ -1391,8 +1389,7 @@ class TestEniRoundTrip(CiTestCase):
eni_path = 'etc/network/interfaces'
renderer = eni.Renderer(
- config={'eni_path': eni_path, 'links_path_prefix': links_prefix,
- 'netrules_path': netrules_path})
+ config={'eni_path': eni_path, 'netrules_path': netrules_path})
renderer.render_network_state(ns, dir)
return dir2dict(dir)