Merge "Use a workarounds option to disable rootwrap"

This commit is contained in:
Jenkins
2015-01-29 06:21:31 +00:00
committed by Gerrit Code Review
2 changed files with 21 additions and 1 deletions

View File

@@ -197,6 +197,17 @@ class GenericUtilsTestCase(test.NoDBTestCase):
self.assertEqual(
value, utils.get_hash_str(base_str))
def test_use_rootwrap(self):
self.flags(disable_rootwrap=False, group='workarounds')
self.flags(rootwrap_config='foo')
cmd = utils._get_root_helper()
self.assertEqual('sudo nova-rootwrap foo', cmd)
def test_use_sudo(self):
self.flags(disable_rootwrap=True, group='workarounds')
cmd = utils._get_root_helper()
self.assertEqual('sudo', cmd)
class MonkeyPatchTestCase(test.NoDBTestCase):
"""Unit test for utils.monkey_patch()."""

View File

@@ -92,6 +92,11 @@ Please use with care!
Document the BugID that your workaround is paired with."""
workarounds_opts = [
cfg.BoolOpt('disable_rootwrap',
default=False,
help='This option allows a fallback to sudo for performance '
'reasons. For example see '
'https://bugs.launchpad.net/nova/+bug/1415106'),
]
CONF = cfg.CONF
CONF.register_opts(monkey_patch_opts)
@@ -171,7 +176,11 @@ def vpn_ping(address, port, timeout=0.05, session_id=None):
def _get_root_helper():
return 'sudo nova-rootwrap %s' % CONF.rootwrap_config
if CONF.workarounds.disable_rootwrap:
cmd = 'sudo'
else:
cmd = 'sudo nova-rootwrap %s' % CONF.rootwrap_config
return cmd
def execute(*cmd, **kwargs):