diff --git a/etc/quantum/rootwrap.d/dhcp.filters b/etc/quantum/rootwrap.d/dhcp.filters index 1e2150049b..4a4635a263 100644 --- a/etc/quantum/rootwrap.d/dhcp.filters +++ b/etc/quantum/rootwrap.d/dhcp.filters @@ -11,9 +11,7 @@ # dhcp-agent ip_exec_dnsmasq: DnsmasqNetnsFilter, /sbin/ip, root dnsmasq: DnsmasqFilter, /sbin/dnsmasq, root -dnsmasq_ver: DnsmasqVersionFilter, /sbin/dnsmasq, root dnsmasq_usr: DnsmasqFilter, /usr/sbin/dnsmasq, root -dnsmasq_usr_ver: DnsmasqVersionFilter, /usr/sbin/dnsmasq, root # dhcp-agent uses kill as well, that's handled by the generic KillFilter # it looks like these are the only signals needed, per # quantum/agent/linux/dhcp.py diff --git a/quantum/agent/dhcp_agent.py b/quantum/agent/dhcp_agent.py index afe79226b5..f8f342c41d 100644 --- a/quantum/agent/dhcp_agent.py +++ b/quantum/agent/dhcp_agent.py @@ -80,7 +80,7 @@ class DhcpAgent(manager.Manager): self.device_manager = DeviceManager(self.conf, self.plugin_rpc) self.lease_relay = DhcpLeaseRelay(self.update_lease) - self.dhcp_driver_cls.check_version(self.root_helper) + self.dhcp_driver_cls.check_version() self._populate_networks_cache() def _populate_networks_cache(self): diff --git a/quantum/agent/linux/dhcp.py b/quantum/agent/linux/dhcp.py index 95c9f14edf..dde040f64b 100644 --- a/quantum/agent/linux/dhcp.py +++ b/quantum/agent/linux/dhcp.py @@ -101,7 +101,7 @@ class DhcpBase(object): raise NotImplementedError @classmethod - def check_version(cls, root_helper): + def check_version(cls): """Execute version checks on DHCP server.""" raise NotImplementedError @@ -224,11 +224,11 @@ class Dnsmasq(DhcpLocalProcess): MINIMUM_VERSION = 2.59 @classmethod - def check_version(cls, root_helper): + def check_version(cls): is_valid_version = None try: cmd = ['dnsmasq', '--version'] - out = utils.execute(cmd, root_helper) + out = utils.execute(cmd) ver = re.findall("\d+.\d+", out)[0] is_valid_version = float(ver) >= cls.MINIMUM_VERSION if not is_valid_version: @@ -236,7 +236,7 @@ class Dnsmasq(DhcpLocalProcess): 'DHCP AGENT MAY NOT RUN CORRECTLY! ' 'Please ensure that its version is %s ' 'or above!'), cls.MINIMUM_VERSION) - except (RuntimeError, IndexError, ValueError): + except (OSError, RuntimeError, IndexError, ValueError): LOG.warning(_('Unable to determine dnsmasq version. ' 'Please ensure that its version is %s ' 'or above!'), cls.MINIMUM_VERSION) diff --git a/quantum/rootwrap/filters.py b/quantum/rootwrap/filters.py index 6461369402..30472452ca 100644 --- a/quantum/rootwrap/filters.py +++ b/quantum/rootwrap/filters.py @@ -171,12 +171,6 @@ class DnsmasqFilter(CommandFilter): return env -class DnsmasqVersionFilter(CommandFilter): - """Specific filter to check dnsmasq version.""" - def match(self, userargs): - return userargs[0] == "dnsmasq" and userargs[1] == "--version" - - class DnsmasqNetnsFilter(DnsmasqFilter): """Specific filter for the dnsmasq call (which includes env).""" diff --git a/quantum/tests/unit/test_linux_dhcp.py b/quantum/tests/unit/test_linux_dhcp.py index c5331b169b..7a4426fb66 100644 --- a/quantum/tests/unit/test_linux_dhcp.py +++ b/quantum/tests/unit/test_linux_dhcp.py @@ -142,7 +142,7 @@ class TestDhcpBase(base.BaseTestCase): def test_check_version_abstract_error(self): self.assertRaises(NotImplementedError, - dhcp.DhcpBase.check_version, None) + dhcp.DhcpBase.check_version) def test_base_abc_error(self): self.assertRaises(TypeError, dhcp.DhcpBase, None) @@ -720,7 +720,7 @@ tag:tag1,option:classless-static-route,%s,%s""".lstrip() % (fake_v6, def _check_version(self, cmd_out, expected_value): with mock.patch('quantum.agent.linux.utils.execute') as cmd: cmd.return_value = cmd_out - result = dhcp.Dnsmasq.check_version('sudo') + result = dhcp.Dnsmasq.check_version() self.assertEqual(result, expected_value) def test_check_minimum_version(self):