nova.utils._get_root_helper() should be public

The nova.utils._get_root_helper() method is used outside of the
nova.utils module, so we should make it public.
Change the method to nova.utils.get_root_helper()

Change-Id: I63273aa3115502d2cd049c99b2176a7eca0d2f4c
Closes-Bug: #1479345
This commit is contained in:
Shuquan Huang 2015-07-30 09:35:44 +00:00
parent 07773000ab
commit 3ef597447d
11 changed files with 20 additions and 20 deletions

View File

@ -189,12 +189,12 @@ class GenericUtilsTestCase(test.NoDBTestCase):
def test_use_rootwrap(self):
self.flags(disable_rootwrap=False, group='workarounds')
self.flags(rootwrap_config='foo')
cmd = utils._get_root_helper()
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()
cmd = utils.get_root_helper()
self.assertEqual('sudo', cmd)
def test_ssh_execute(self):

View File

@ -179,7 +179,7 @@ class VirtDiskVFSLocalFSTest(test.NoDBTestCase):
self.assertEqual(dirs,
["/scratch/dir/some/dir", "/scratch/dir/other/dir"]),
root_helper = nova.utils._get_root_helper()
root_helper = nova.utils.get_root_helper()
self.assertEqual(commands,
[{'args': ('readlink', '-nm',
'/scratch/dir/some/dir'),
@ -212,7 +212,7 @@ class VirtDiskVFSLocalFSTest(test.NoDBTestCase):
self.assertEqual(files["/scratch/dir/some/file"]["content"],
"Hello World Goodbye")
root_helper = nova.utils._get_root_helper()
root_helper = nova.utils.get_root_helper()
self.assertEqual(commands,
[{'args': ('readlink', '-nm',
'/scratch/dir/some/file'),
@ -238,7 +238,7 @@ class VirtDiskVFSLocalFSTest(test.NoDBTestCase):
self.assertEqual(files["/scratch/dir/some/file"]["content"],
"Goodbye")
root_helper = nova.utils._get_root_helper()
root_helper = nova.utils.get_root_helper()
self.assertEqual(commands,
[{'args': ('readlink', '-nm',
'/scratch/dir/some/file'),
@ -259,7 +259,7 @@ class VirtDiskVFSLocalFSTest(test.NoDBTestCase):
vfs.imgdir = "/scratch/dir"
self.assertEqual(vfs.read_file("/some/file"), "Hello World")
root_helper = nova.utils._get_root_helper()
root_helper = nova.utils.get_root_helper()
self.assertEqual(commands,
[{'args': ('readlink', '-nm',
'/scratch/dir/some/file'),
@ -282,7 +282,7 @@ class VirtDiskVFSLocalFSTest(test.NoDBTestCase):
self.assertTrue(vfs.has_file("/some/file"))
self.assertFalse(vfs.has_file("/other/file"))
root_helper = nova.utils._get_root_helper()
root_helper = nova.utils.get_root_helper()
self.assertEqual(commands,
[{'args': ('readlink', '-nm',
'/scratch/dir/some/file'),
@ -322,7 +322,7 @@ class VirtDiskVFSLocalFSTest(test.NoDBTestCase):
vfs.set_permissions("/some/file", 0o777)
self.assertEqual(files["/scratch/dir/some/file"]["mode"], 0o777)
root_helper = nova.utils._get_root_helper()
root_helper = nova.utils.get_root_helper()
self.assertEqual(commands,
[{'args': ('readlink', '-nm',
'/scratch/dir/some/file'),
@ -365,7 +365,7 @@ class VirtDiskVFSLocalFSTest(test.NoDBTestCase):
self.assertEqual(files["/scratch/dir/some/file"]["uid"], 110)
self.assertEqual(files["/scratch/dir/some/file"]["gid"], 600)
root_helper = nova.utils._get_root_helper()
root_helper = nova.utils.get_root_helper()
self.assertEqual(commands,
[{'args': ('readlink', '-nm',
'/scratch/dir/some/file'),

View File

@ -239,7 +239,7 @@ def vpn_ping(address, port, timeout=0.05, session_id=None):
return (identifier == 0x40 and client_sess == session_id)
def _get_root_helper():
def get_root_helper():
if CONF.workarounds.disable_rootwrap:
cmd = 'sudo'
else:
@ -250,7 +250,7 @@ def _get_root_helper():
def execute(*cmd, **kwargs):
"""Convenience wrapper around oslo's execute() method."""
if 'run_as_root' in kwargs and 'root_helper' not in kwargs:
kwargs['root_helper'] = _get_root_helper()
kwargs['root_helper'] = get_root_helper()
return processutils.execute(*cmd, **kwargs)
@ -265,7 +265,7 @@ def ssh_execute(dest, *cmd, **kwargs):
def trycmd(*args, **kwargs):
"""Convenience wrapper around oslo's trycmd() method."""
if 'run_as_root' in kwargs and 'root_helper' not in kwargs:
kwargs['root_helper'] = _get_root_helper()
kwargs['root_helper'] = get_root_helper()
return processutils.trycmd(*args, **kwargs)

View File

@ -1033,7 +1033,7 @@ class LibvirtDriver(driver.ComputeDriver):
return []
def get_volume_connector(self, instance):
root_helper = utils._get_root_helper()
root_helper = utils.get_root_helper()
return connector.get_connector_properties(
root_helper, CONF.my_block_storage_ip,
CONF.libvirt.iscsi_use_multipath,

View File

@ -38,7 +38,7 @@ class LibvirtAOEVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
# Call the factory here so we can support
# more than x86 architectures.
self.connector = connector.InitiatorConnector.factory(
'AOE', utils._get_root_helper(),
'AOE', utils.get_root_helper(),
device_scan_attempts=CONF.libvirt.num_aoe_discover_tries)
def get_config(self, connection_info, disk_info):

View File

@ -34,7 +34,7 @@ class LibvirtFibreChannelVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
# Call the factory here so we can support
# more than x86 architectures.
self.connector = connector.InitiatorConnector.factory(
'FIBRE_CHANNEL', utils._get_root_helper(),
'FIBRE_CHANNEL', utils.get_root_helper(),
use_multipath=CONF.libvirt.iscsi_use_multipath,
device_scan_attempts=CONF.libvirt.num_iscsi_scan_tries)

View File

@ -31,7 +31,7 @@ class LibvirtHGSTVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
super(LibvirtHGSTVolumeDriver,
self).__init__(connection, is_block_dev=True)
self.connector = connector.InitiatorConnector.factory(
'HGST', utils._get_root_helper(),
'HGST', utils.get_root_helper(),
device_scan_attempts=CONF.libvirt.num_iscsi_scan_tries)
def get_config(self, connection_info, disk_info):

View File

@ -56,7 +56,7 @@ class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
# Call the factory here so we can support
# more than x86 architectures.
self.connector = connector.InitiatorConnector.factory(
'ISCSI', utils._get_root_helper(),
'ISCSI', utils.get_root_helper(),
use_multipath=CONF.libvirt.iscsi_use_multipath,
device_scan_attempts=CONF.libvirt.num_iscsi_scan_tries,
transport=self._get_transport())

View File

@ -37,7 +37,7 @@ class LibvirtISERVolumeDriver(iscsi.LibvirtISCSIVolumeDriver):
# Call the factory here so we can support
# more than x86 architectures.
self.connector = connector.InitiatorConnector.factory(
'ISER', utils._get_root_helper(),
'ISER', utils.get_root_helper(),
use_multipath=CONF.libvirt.iser_use_multipath,
device_scan_attempts=CONF.libvirt.num_iser_scan_tries,
transport=self._get_transport())

View File

@ -39,7 +39,7 @@ class LibvirtScaleIOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
super(LibvirtScaleIOVolumeDriver, self).__init__(connection,
is_block_dev=False)
self.connector = connector.InitiatorConnector.factory(
'SCALEIO', utils._get_root_helper(),
'SCALEIO', utils.get_root_helper(),
device_scan_attempts=CONF.libvirt.num_iscsi_scan_tries)
def get_config(self, connection_info, disk_info):

View File

@ -24,7 +24,7 @@ from nova import utils
def get_iscsi_initiator(execute=None):
"""Get iscsi initiator name for this machine."""
root_helper = utils._get_root_helper()
root_helper = utils.get_root_helper()
# so we can mock out the execute itself
# in unit tests.
if not execute: