Skip to content

Commit

Permalink
Introduce libvirt (un)mask)_command config option
Browse files Browse the repository at this point in the history
On Ubunu Focal, libvirtd can be activated by other systemd units. To
avoid this unwanted activation, and only have libvirtd start when we
tell it to start, we need to mask it. This patch introduced the config
options to mask and unmask the libvirtd service. They will be used in
a susequent patch that starts using the Focal image to unskip some
tests.

Change-Id: Ib28811fd4f155cbc02f10b43d470f4cef142513b
  • Loading branch information
notartom committed Sep 15, 2020
1 parent 1de36b3 commit 072b2c7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions devstack/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ function configure {

iniset $TEMPEST_CONFIG whitebox-libvirt start_command "$WHITEBOX_LIBVIRT_START_COMMAND"
iniset $TEMPEST_CONFIG whitebox-libvirt stop_command "$WHITEBOX_LIBVIRT_STOP_COMMAND"
iniset $TEMPEST_CONFIG whitebox-libvirt mask_command "$WHITEBOX_LIBVIRT_MASK_COMMAND"
iniset $TEMPEST_CONFIG whitebox-libvirt unmask_command "$WHITEBOX_LIBVIRT_UNMASK_COMMAND"

iniset $TEMPEST_CONFIG whitebox-database user $DATABASE_USER
iniset $TEMPEST_CONFIG whitebox-database password $DATABASE_PASSWORD
Expand Down
2 changes: 2 additions & 0 deletions devstack/settings
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ WHITEBOX_NOVA_COMPUTE_START_COMMAND=${WHITEBOX_NOVA_COMPUTE_START_COMMAND:-'syst

WHITEBOX_LIBVIRT_START_COMMAND=${WHITEBOX_LIBVIRT_START_COMMAND:-'systemctl start libvirtd'}
WHITEBOX_LIBVIRT_STOP_COMMAND=${WHITEBOX_LIBVIRT_STOP_COMMAND:-'systemctl stop libvirtd'}
WHITEBOX_LIBVIRT_MASK_COMMAND=${WHITEBOX_LIBVIRT_MASK_COMMAND:-'systemctl mask libvirtd'}
WHITEBOX_LIBVIRT_UNMASK_COMMAND=${WHITEBOX_LIBVIRT_UNMASK_COMMAND:-'systemctl unmask libvirtd'}

WHITEBOX_CPU_TOPOLOGY=${WHITEBOX_CPU_TOPOLOGY:-''}
15 changes: 14 additions & 1 deletion whitebox_tempest_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,20 @@
help='Command to stop the libvirt service, without any '
'privilege management (ie, no sudo).',
deprecated_opts=[cfg.DeprecatedOpt('stop_command',
group='whitebox-nova-libvirt')])
group='whitebox-nova-libvirt')]),
cfg.StrOpt(
'mask_command',
help='In some situations (Ubuntu Focal, for example), libvirtd can '
'be activated by other systemd units even if it is stopped. '
'In such cases, it can be useful to mask a service (ie, disable '
'it completely) to prevent it from being started outside of our '
'control. This config options sets the command to mask libvirt. '
'If set, it will be executed after every stop command.'),
cfg.StrOpt(
'unmask_command',
help='Similar to the mask_command option, this config options sets '
'the command to unmask libvirt. If set, it will be run before '
'every start command.'),
]

database_group = cfg.OptGroup(
Expand Down
10 changes: 8 additions & 2 deletions whitebox_tempest_plugin/services/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ def __init__(self, hostname, service):
raise exceptions.MissingServiceSectionException(service=service)
self.service = service
self.config_path = getattr(conf, 'config_path', None)
self.restart_command = getattr(conf, 'restart_command', None)
self.stop_command = getattr(conf, 'stop_command', None)
self.start_command = getattr(conf, 'start_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.unmask_command = getattr(conf, 'unmask_command', None)

@contextlib.contextmanager
def config_options(self, *opts):
Expand Down Expand Up @@ -162,10 +164,14 @@ def del_conf_opt(self, section, option):
return self.execute(command, container_name=None, sudo=True)

def start(self):
if self.unmask_command:
self.execute(self.unmask_command, sudo=True)
self.execute(self.start_command, sudo=True)

def stop(self):
self.execute(self.stop_command, sudo=True)
if self.unmask_command:
self.execute(self.mask_command, sudo=True)

def restart(self):
self.execute(self.restart_command, sudo=True)
Expand Down

0 comments on commit 072b2c7

Please sign in to comment.