Remove restart_command config option
In real life, nothing actually uses that config option. We currently support nova-compute and libvirt as services, and both only use start_command and stop_command. Libvirt only uses those because it needs to be stopped for a destructive test, and nova-compute only uses those because it implements restart() as a sequence of stop/start operations and waits for the service to appear down/up in the services API at each step. This patch removes the restart_command config option entirely, and moves the stop()/start() implementation of restart() into the base ServiceManager class. If we ever actually need to restart a service, we can re-add this config option in the future. Change-Id: I14dddb5846b2330811c496aa7c134d020781edb8
This commit is contained in:
parent
c74bb93b6d
commit
4a4d0c6d63
@ -88,7 +88,6 @@ class ServiceManager(SSHClient):
|
|||||||
self.config_path = getattr(conf, 'config_path', None)
|
self.config_path = getattr(conf, 'config_path', None)
|
||||||
self.start_command = getattr(conf, 'start_command', None)
|
self.start_command = getattr(conf, 'start_command', None)
|
||||||
self.stop_command = getattr(conf, 'stop_command', None)
|
self.stop_command = getattr(conf, 'stop_command', None)
|
||||||
self.restart_command = getattr(conf, 'restart_command', None)
|
|
||||||
self.mask_command = getattr(conf, 'mask_command', None)
|
self.mask_command = getattr(conf, 'mask_command', None)
|
||||||
self.unmask_command = getattr(conf, 'unmask_command', None)
|
self.unmask_command = getattr(conf, 'unmask_command', None)
|
||||||
|
|
||||||
@ -174,7 +173,8 @@ class ServiceManager(SSHClient):
|
|||||||
self.execute(self.mask_command, sudo=True)
|
self.execute(self.mask_command, sudo=True)
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
self.execute(self.restart_command, sudo=True)
|
self.stop()
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
|
||||||
class NovaServiceManager(ServiceManager):
|
class NovaServiceManager(ServiceManager):
|
||||||
@ -206,10 +206,6 @@ class NovaServiceManager(ServiceManager):
|
|||||||
'down')
|
'down')
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def restart(self):
|
|
||||||
self.stop()
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
|
|
||||||
class NUMAClient(SSHClient):
|
class NUMAClient(SSHClient):
|
||||||
"""A client to get host NUMA information. `numactl` needs to be installed
|
"""A client to get host NUMA information. `numactl` needs to be installed
|
||||||
|
@ -147,21 +147,15 @@ class ServiceManagerTestCase(base.WhiteboxPluginTestCase):
|
|||||||
service.get_conf_opt, 'section', 'foo')
|
service.get_conf_opt, 'section', 'foo')
|
||||||
|
|
||||||
def test_commands(self):
|
def test_commands(self):
|
||||||
# NOTE(artom) There is currently no service that has all 3 start, stop
|
|
||||||
# and restart, so we set up a fake one for testing.
|
|
||||||
CONF.register_group(cfg.OptGroup(name='whitebox-fake-service'))
|
CONF.register_group(cfg.OptGroup(name='whitebox-fake-service'))
|
||||||
CONF.register_opt(cfg.StrOpt('start_command'),
|
CONF.register_opt(cfg.StrOpt('start_command'),
|
||||||
group='whitebox-fake-service')
|
group='whitebox-fake-service')
|
||||||
CONF.register_opt(cfg.StrOpt('stop_command'),
|
CONF.register_opt(cfg.StrOpt('stop_command'),
|
||||||
group='whitebox-fake-service')
|
group='whitebox-fake-service')
|
||||||
CONF.register_opt(cfg.StrOpt('restart_command'),
|
|
||||||
group='whitebox-fake-service')
|
|
||||||
self.flags(start_command='fake start command',
|
self.flags(start_command='fake start command',
|
||||||
group='whitebox-fake-service')
|
group='whitebox-fake-service')
|
||||||
self.flags(stop_command='fake stop command',
|
self.flags(stop_command='fake stop command',
|
||||||
group='whitebox-fake-service')
|
group='whitebox-fake-service')
|
||||||
self.flags(restart_command='fake restart command',
|
|
||||||
group='whitebox-fake-service')
|
|
||||||
service = clients.ServiceManager('fake-host', 'fake-service')
|
service = clients.ServiceManager('fake-host', 'fake-service')
|
||||||
with mock.patch.object(service, 'execute') as mock_exec:
|
with mock.patch.object(service, 'execute') as mock_exec:
|
||||||
# Start
|
# Start
|
||||||
@ -172,9 +166,6 @@ class ServiceManagerTestCase(base.WhiteboxPluginTestCase):
|
|||||||
service.stop()
|
service.stop()
|
||||||
mock_exec.assert_called_with('fake stop command', sudo=True)
|
mock_exec.assert_called_with('fake stop command', sudo=True)
|
||||||
mock_exec.reset_mock()
|
mock_exec.reset_mock()
|
||||||
# Restart
|
|
||||||
service.restart()
|
|
||||||
mock_exec.assert_called_with('fake restart command', sudo=True)
|
|
||||||
|
|
||||||
|
|
||||||
class NUMAClientTestCase(base.WhiteboxPluginTestCase):
|
class NUMAClientTestCase(base.WhiteboxPluginTestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user