cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #06317
[Merge] ~goneri/cloud-init:netplan_clean_up into cloud-init:master
Gonéri Le Bouder has proposed merging ~goneri/cloud-init:netplan_clean_up into cloud-init:master.
Commit message:
netplan: reuse _post_cmds attribue
_netplan_generate() and _net_setup_link() are method of the Renderer
class. And so, they can access self._post_cmds directly.
Requested reviews:
cloud-init commiters (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~goneri/cloud-init/+git/cloud-init/+merge/368587
--
Your team cloud-init commiters is requested to review the proposed merge of ~goneri/cloud-init:netplan_clean_up into cloud-init:master.
diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py
index e54a34e..c5f2051 100644
--- a/cloudinit/net/netplan.py
+++ b/cloudinit/net/netplan.py
@@ -207,21 +207,21 @@ class Renderer(renderer.Renderer):
if self.clean_default:
_clean_default(target=target)
- self._netplan_generate(run=self._postcmds)
- self._net_setup_link(run=self._postcmds)
+ self._netplan_generate()
+ self._net_setup_link()
- def _netplan_generate(self, run=False):
- if not run:
+ def _netplan_generate(self):
+ if not self._postcmds:
LOG.debug("netplan generate postcmd disabled")
return
util.subp(self.NETPLAN_GENERATE, capture=True)
- def _net_setup_link(self, run=False):
+ def _net_setup_link(self):
"""To ensure device link properties are applied, we poke
udev to re-evaluate networkd .link files and call
the setup_link udev builtin command
"""
- if not run:
+ if not self._postcmds:
LOG.debug("netplan net_setup_link postcmd disabled")
return
setup_lnk = ['udevadm', 'test-builtin', 'net_setup_link']
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index b936bc9..46f695f 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -3298,8 +3298,8 @@ class TestNetplanPostcommands(CiTestCase):
{'netplan_path': render_target, 'postcmds': True})
renderer.render_network_state(ns, target=render_dir)
- mock_netplan_generate.assert_called_with(run=True)
- mock_net_setup_link.assert_called_with(run=True)
+ mock_netplan_generate.assert_called_with()
+ mock_net_setup_link.assert_called_with()
@mock.patch('cloudinit.util.SeLinuxGuard')
@mock.patch.object(netplan, "get_devicelist")