summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2017-05-13 01:28:14 +0100
committerScott Moser <smoser@brickies.net>2017-05-17 12:28:51 -0400
commita6572d9415e592cbf9821b769bbee9e7fdf029d5 (patch)
tree4aefa462a7353f8de5ac215ba5fa42aba9a6a3d8
parent31b6f173280fcc8e9be2732ae2e9b6f6c89679d4 (diff)
downloadvyos-cloud-init-a6572d9415e592cbf9821b769bbee9e7fdf029d5.tar.gz
vyos-cloud-init-a6572d9415e592cbf9821b769bbee9e7fdf029d5.zip
netplan: fix netplan render_network_state signature.
tools/net-convert fails to output netplan config, because the positional arguments of render_network_state are the wrong way around for that function w.r.t. other renders. Fix the netplan renderer to have the correct signature. LP: #1685944
-rw-r--r--cloudinit/net/netplan.py2
-rw-r--r--tests/unittests/test_net.py16
2 files changed, 9 insertions, 9 deletions
diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py
index 825fe831..56b41be4 100644
--- a/cloudinit/net/netplan.py
+++ b/cloudinit/net/netplan.py
@@ -205,7 +205,7 @@ class Renderer(renderer.Renderer):
self._postcmds = config.get('postcmds', False)
self.clean_default = config.get('clean_default', True)
- def render_network_state(self, target, network_state):
+ def render_network_state(self, network_state, target):
# check network state for version
# if v2, then extract network_state.config
# else render_v2_from_state
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 052c4016..d36d0e76 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -1073,7 +1073,7 @@ class TestNetplanNetRendering(CiTestCase):
render_target = 'netplan.yaml'
renderer = netplan.Renderer(
{'netplan_path': render_target, 'postcmds': False})
- renderer.render_network_state(render_dir, ns)
+ renderer.render_network_state(ns, render_dir)
self.assertTrue(os.path.exists(os.path.join(render_dir,
render_target)))
@@ -1178,7 +1178,7 @@ class TestNetplanPostcommands(CiTestCase):
render_target = 'netplan.yaml'
renderer = netplan.Renderer(
{'netplan_path': render_target, 'postcmds': True})
- renderer.render_network_state(render_dir, ns)
+ renderer.render_network_state(ns, render_dir)
mock_netplan_generate.assert_called_with(run=True)
mock_net_setup_link.assert_called_with(run=True)
@@ -1203,7 +1203,7 @@ class TestNetplanPostcommands(CiTestCase):
'/sys/class/net/lo'], capture=True),
]
with mock.patch.object(os.path, 'islink', return_value=True):
- renderer.render_network_state(render_dir, ns)
+ renderer.render_network_state(ns, render_dir)
mock_subp.assert_has_calls(expected)
@@ -1354,9 +1354,9 @@ class TestCmdlineReadKernelConfig(CiTestCase):
class TestNetplanRoundTrip(CiTestCase):
def _render_and_read(self, network_config=None, state=None,
- netplan_path=None, dir=None):
- if dir is None:
- dir = self.tmp_dir()
+ netplan_path=None, target=None):
+ if target is None:
+ target = self.tmp_dir()
if network_config:
ns = network_state.parse_net_config_data(network_config)
@@ -1371,8 +1371,8 @@ class TestNetplanRoundTrip(CiTestCase):
renderer = netplan.Renderer(
config={'netplan_path': netplan_path})
- renderer.render_network_state(dir, ns)
- return dir2dict(dir)
+ renderer.render_network_state(ns, target)
+ return dir2dict(target)
def testsimple_render_small_netplan(self):
entry = NETWORK_CONFIGS['small']