Merge "Ensure dnsmasq is down before enabling it in restart method"
This commit is contained in:
commit
4cf0c77751
|
@ -140,12 +140,12 @@ class DhcpBase(object):
|
||||||
"""Enables DHCP for this network."""
|
"""Enables DHCP for this network."""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def disable(self, retain_port=False):
|
def disable(self, retain_port=False, block=False):
|
||||||
"""Disable dhcp for this network."""
|
"""Disable dhcp for this network."""
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
"""Restart the dhcp service for the network."""
|
"""Restart the dhcp service for the network."""
|
||||||
self.disable(retain_port=True)
|
self.disable(retain_port=True, block=True)
|
||||||
self.enable()
|
self.enable()
|
||||||
|
|
||||||
@abc.abstractproperty
|
@abc.abstractproperty
|
||||||
|
@ -233,10 +233,13 @@ class DhcpLocalProcess(DhcpBase):
|
||||||
pid_file=self.get_conf_file_name('pid'),
|
pid_file=self.get_conf_file_name('pid'),
|
||||||
run_as_root=True)
|
run_as_root=True)
|
||||||
|
|
||||||
def disable(self, retain_port=False):
|
def disable(self, retain_port=False, block=False):
|
||||||
"""Disable DHCP for this network by killing the local process."""
|
"""Disable DHCP for this network by killing the local process."""
|
||||||
self.process_monitor.unregister(self.network.id, DNSMASQ_SERVICE_NAME)
|
self.process_monitor.unregister(self.network.id, DNSMASQ_SERVICE_NAME)
|
||||||
self._get_process_manager().disable()
|
pm = self._get_process_manager()
|
||||||
|
pm.disable()
|
||||||
|
if block:
|
||||||
|
common_utils.wait_until_true(lambda: not pm.active)
|
||||||
if not retain_port:
|
if not retain_port:
|
||||||
self._destroy_namespace_and_port()
|
self._destroy_namespace_and_port()
|
||||||
self._remove_config_files()
|
self._remove_config_files()
|
||||||
|
|
|
@ -1094,8 +1094,8 @@ class TestDhcpBase(TestBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.called.append('enable')
|
self.called.append('enable')
|
||||||
|
|
||||||
def disable(self, retain_port=False):
|
def disable(self, retain_port=False, block=False):
|
||||||
self.called.append('disable %s' % retain_port)
|
self.called.append('disable %s %s' % (retain_port, block))
|
||||||
|
|
||||||
def reload_allocations(self):
|
def reload_allocations(self):
|
||||||
pass
|
pass
|
||||||
|
@ -1106,7 +1106,7 @@ class TestDhcpBase(TestBase):
|
||||||
|
|
||||||
c = SubClass()
|
c = SubClass()
|
||||||
c.restart()
|
c.restart()
|
||||||
self.assertEqual(c.called, ['disable True', 'enable'])
|
self.assertEqual(c.called, ['disable True True', 'enable'])
|
||||||
|
|
||||||
|
|
||||||
class TestDhcpLocalProcess(TestBase):
|
class TestDhcpLocalProcess(TestBase):
|
||||||
|
|
Loading…
Reference in New Issue