diff options
-rw-r--r-- | nova/tests/baremetal/test_virtual_power_driver.py | 15 | ||||
-rw-r--r-- | nova/tests/fake_processutils.py (renamed from nova/tests/fake_utils.py) | 7 | ||||
-rw-r--r-- | nova/tests/test_imagebackend.py | 14 | ||||
-rw-r--r-- | nova/tests/test_virt_disk_vfs_localfs.py | 115 | ||||
-rw-r--r-- | nova/tests/test_xenapi.py | 10 | ||||
-rw-r--r-- | nova/utils.py | 69 | ||||
-rw-r--r-- | nova/virt/baremetal/virtual_power_driver.py | 5 | ||||
-rw-r--r-- | nova/virt/powervm/blockdev.py | 6 | ||||
-rw-r--r-- | nova/virt/powervm/common.py | 5 | ||||
-rw-r--r-- | nova/virt/powervm/operator.py | 5 |
10 files changed, 112 insertions, 139 deletions
diff --git a/nova/tests/baremetal/test_virtual_power_driver.py b/nova/tests/baremetal/test_virtual_power_driver.py index 4cac0a3ba..d6d615194 100644 --- a/nova/tests/baremetal/test_virtual_power_driver.py +++ b/nova/tests/baremetal/test_virtual_power_driver.py @@ -27,7 +27,6 @@ from nova.tests.baremetal.db import base as bm_db_base from nova.tests.baremetal.db import utils as bm_db_utils from nova.tests.image import fake as fake_image from nova.tests import utils -from nova import utils as nutils from nova.virt.baremetal import db from nova.virt.baremetal import virtual_power_driver import nova.virt.powervm.common as connection @@ -352,9 +351,9 @@ class VPDClassMethodsTestCase(BareMetalVPDTestCase): self._create_pm() self.mox.StubOutWithMock(self.pm, '_set_connection') - self.mox.StubOutWithMock(nutils, 'ssh_execute') + self.mox.StubOutWithMock(processutils, 'ssh_execute') self.pm._set_connection().AndReturn(True) - nutils.ssh_execute(None, '/usr/bin/VBoxManage test return', + processutils.ssh_execute(None, '/usr/bin/VBoxManage test return', check_exit_code=True).AndReturn(("test\nreturn", "")) self.pm._matched_name = 'testNode' self.mox.ReplayAll() @@ -367,10 +366,10 @@ class VPDClassMethodsTestCase(BareMetalVPDTestCase): self._create_pm() self.mox.StubOutWithMock(self.pm, '_set_connection') - self.mox.StubOutWithMock(nutils, 'ssh_execute') + self.mox.StubOutWithMock(processutils, 'ssh_execute') self.pm._set_connection().AndReturn(True) - nutils.ssh_execute(None, '/usr/bin/VBoxManage test return', + processutils.ssh_execute(None, '/usr/bin/VBoxManage test return', check_exit_code=True).\ AndRaise(processutils.ProcessExecutionError) self.mox.ReplayAll() @@ -384,14 +383,14 @@ class VPDClassMethodsTestCase(BareMetalVPDTestCase): self._create_pm() self.mox.StubOutWithMock(self.pm, '_check_for_node') - self.mox.StubOutWithMock(nutils, 'ssh_execute') + self.mox.StubOutWithMock(processutils, 'ssh_execute') self.pm._check_for_node().AndReturn(['"testNode"']) self.pm._check_for_node().AndReturn(['"testNode"']) - nutils.ssh_execute('test', '/usr/bin/VBoxManage startvm ', + processutils.ssh_execute('test', '/usr/bin/VBoxManage startvm ', check_exit_code=True).\ AndRaise(processutils.ProcessExecutionError) - nutils.ssh_execute('test', '/usr/bin/VBoxManage list runningvms', + processutils.ssh_execute('test', '/usr/bin/VBoxManage list runningvms', check_exit_code=True).\ AndRaise(processutils.ProcessExecutionError) diff --git a/nova/tests/fake_utils.py b/nova/tests/fake_processutils.py index 6a295b43b..04d39e7e5 100644 --- a/nova/tests/fake_utils.py +++ b/nova/tests/fake_processutils.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""This modules stubs out functions in nova.utils.""" +"""This modules stubs out functions in openstack.common.processutils.""" import re @@ -22,7 +22,6 @@ from eventlet import greenthread from nova.openstack.common import log as logging from nova.openstack.common import processutils -from nova import utils LOG = logging.getLogger(__name__) @@ -106,7 +105,7 @@ def fake_execute(*cmd_parts, **kwargs): return reply -def stub_out_utils_execute(stubs): +def stub_out_processutils_execute(stubs): fake_execute_set_repliers([]) fake_execute_clear_log() - stubs.Set(utils, 'execute', fake_execute) + stubs.Set(processutils, 'execute', fake_execute) diff --git a/nova/tests/test_imagebackend.py b/nova/tests/test_imagebackend.py index 4ec36daa8..0f1d8532b 100644 --- a/nova/tests/test_imagebackend.py +++ b/nova/tests/test_imagebackend.py @@ -24,7 +24,7 @@ from nova import exception from nova.openstack.common import uuidutils from nova import test from nova.tests import fake_libvirt_utils -from nova.tests import fake_utils +from nova.tests import fake_processutils from nova.virt.libvirt import imagebackend CONF = cfg.CONF @@ -131,8 +131,8 @@ class _ImageTestCase(object): def test_prealloc_image(self): CONF.set_override('preallocate_images', 'space') - fake_utils.fake_execute_clear_log() - fake_utils.stub_out_utils_execute(self.stubs) + fake_processutils.fake_execute_clear_log() + fake_processutils.stub_out_processutils_execute(self.stubs) image = self.image_class(self.INSTANCE, self.NAME) def fake_fetch(target, *args, **kwargs): @@ -144,7 +144,7 @@ class _ImageTestCase(object): image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE) image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE) - self.assertEqual(fake_utils.fake_execute_get_log(), + self.assertEqual(fake_processutils.fake_execute_get_log(), ['fallocate -n -l 1 %s.fallocate_test' % self.PATH, 'fallocate -n -l %s %s' % (self.SIZE, self.PATH), 'fallocate -n -l %s %s' % (self.SIZE, self.PATH)]) @@ -427,8 +427,8 @@ class LvmTestCase(_ImageTestCase, test.TestCase): def test_prealloc_image(self): CONF.set_override('preallocate_images', 'space') - fake_utils.fake_execute_clear_log() - fake_utils.stub_out_utils_execute(self.stubs) + fake_processutils.fake_execute_clear_log() + fake_processutils.stub_out_processutils_execute(self.stubs) image = self.image_class(self.INSTANCE, self.NAME) def fake_fetch(target, *args, **kwargs): @@ -438,7 +438,7 @@ class LvmTestCase(_ImageTestCase, test.TestCase): image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE) - self.assertEqual(fake_utils.fake_execute_get_log(), []) + self.assertEqual(fake_processutils.fake_execute_get_log(), []) class BackendTestCase(test.TestCase): diff --git a/nova/tests/test_virt_disk_vfs_localfs.py b/nova/tests/test_virt_disk_vfs_localfs.py index 5bbac670e..b52817b18 100644 --- a/nova/tests/test_virt_disk_vfs_localfs.py +++ b/nova/tests/test_virt_disk_vfs_localfs.py @@ -14,13 +14,17 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg + from nova import exception +from nova.openstack.common import processutils from nova import test from nova.tests import utils as tests_utils -from nova import utils from nova.virt.disk.vfs import localfs as vfsimpl +CONF = cfg.CONF + dirs = [] files = {} commands = [] @@ -121,13 +125,13 @@ class VirtDiskVFSLocalFSTestPaths(test.TestCase): def setUp(self): super(VirtDiskVFSLocalFSTestPaths, self).setUp() - real_execute = utils.execute + real_execute = processutils.execute def nonroot_execute(*cmd_parts, **kwargs): kwargs.pop('run_as_root', None) return real_execute(*cmd_parts, **kwargs) - self.stubs.Set(utils, 'execute', nonroot_execute) + self.stubs.Set(processutils, 'execute', nonroot_execute) def test_check_safe_path(self): if tests_utils.is_osx(): @@ -152,7 +156,7 @@ class VirtDiskVFSLocalFSTest(test.TestCase): global dirs, commands dirs = [] commands = [] - self.stubs.Set(utils, 'execute', fake_execute) + self.stubs.Set(processutils, 'execute', fake_execute) vfs = vfsimpl.VFSLocalFS(imgfile="/dummy.qcow2", imgfmt="qcow2") vfs.imgdir = "/scratch/dir" @@ -162,25 +166,30 @@ class VirtDiskVFSLocalFSTest(test.TestCase): self.assertEqual(dirs, ["/scratch/dir/some/dir", "/scratch/dir/other/dir"]), + root_helper = 'sudo nova-rootwrap %s' % CONF.rootwrap_config self.assertEqual(commands, [{'args': ('readlink', '-nm', '/scratch/dir/some/dir'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('mkdir', '-p', '/scratch/dir/some/dir'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-nm', '/scratch/dir/other/dir'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('mkdir', '-p', '/scratch/dir/other/dir'), - 'kwargs': {'run_as_root': True}}]) + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}]) def test_append_file(self): global files, commands files = {} commands = [] - self.stubs.Set(utils, 'execute', fake_execute) + self.stubs.Set(processutils, 'execute', fake_execute) vfs = vfsimpl.VFSLocalFS(imgfile="/dummy.qcow2", imgfmt="qcow2") vfs.imgdir = "/scratch/dir" @@ -190,20 +199,23 @@ class VirtDiskVFSLocalFSTest(test.TestCase): self.assertEquals(files["/scratch/dir/some/file"]["content"], "Hello World Goodbye") + root_helper = 'sudo nova-rootwrap %s' % CONF.rootwrap_config self.assertEqual(commands, [{'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('tee', '-a', '/scratch/dir/some/file'), 'kwargs': {'process_input': ' Goodbye', - 'run_as_root': True}}]) + 'run_as_root': True, + 'root_helper': root_helper}}]) def test_replace_file(self): global files, commands files = {} commands = [] - self.stubs.Set(utils, 'execute', fake_execute) + self.stubs.Set(processutils, 'execute', fake_execute) vfs = vfsimpl.VFSLocalFS(imgfile="/dummy.qcow2", imgfmt="qcow2") vfs.imgdir = "/scratch/dir" @@ -213,36 +225,42 @@ class VirtDiskVFSLocalFSTest(test.TestCase): self.assertEquals(files["/scratch/dir/some/file"]["content"], "Goodbye") + root_helper = 'sudo nova-rootwrap %s' % CONF.rootwrap_config self.assertEqual(commands, [{'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('tee', '/scratch/dir/some/file'), 'kwargs': {'process_input': 'Goodbye', - 'run_as_root': True}}]) + 'run_as_root': True, + 'root_helper': root_helper}}]) def test_read_file(self): global commands, files files = {} commands = [] - self.stubs.Set(utils, 'execute', fake_execute) + self.stubs.Set(processutils, 'execute', fake_execute) vfs = vfsimpl.VFSLocalFS(imgfile="/dummy.qcow2", imgfmt="qcow2") vfs.imgdir = "/scratch/dir" self.assertEqual(vfs.read_file("/some/file"), "Hello World") + root_helper = 'sudo nova-rootwrap %s' % CONF.rootwrap_config self.assertEqual(commands, [{'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('cat', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}]) + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}]) def test_has_file(self): global commands, files files = {} commands = [] - self.stubs.Set(utils, 'execute', fake_execute) + self.stubs.Set(processutils, 'execute', fake_execute) vfs = vfsimpl.VFSLocalFS(imgfile="/dummy.qcow2", imgfmt="qcow2") vfs.imgdir = "/scratch/dir" @@ -251,31 +269,38 @@ class VirtDiskVFSLocalFSTest(test.TestCase): self.assertTrue(vfs.has_file("/some/file")) self.assertFalse(vfs.has_file("/other/file")) + root_helper = 'sudo nova-rootwrap %s' % CONF.rootwrap_config self.assertEqual(commands, [{'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('cat', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-e', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-nm', '/scratch/dir/other/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-e', '/scratch/dir/other/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, ]) def test_set_permissions(self): global commands, files commands = [] files = {} - self.stubs.Set(utils, 'execute', fake_execute) + self.stubs.Set(processutils, 'execute', fake_execute) vfs = vfsimpl.VFSLocalFS(imgfile="/dummy.qcow2", imgfmt="qcow2") vfs.imgdir = "/scratch/dir" @@ -284,24 +309,29 @@ class VirtDiskVFSLocalFSTest(test.TestCase): vfs.set_permissions("/some/file", 0777) self.assertEquals(files["/scratch/dir/some/file"]["mode"], 0777) + root_helper = 'sudo nova-rootwrap %s' % CONF.rootwrap_config self.assertEqual(commands, [{'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('cat', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('chmod', '777', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}]) + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}]) def test_set_ownership(self): global commands, files commands = [] files = {} - self.stubs.Set(utils, 'execute', fake_execute) + self.stubs.Set(processutils, 'execute', fake_execute) vfs = vfsimpl.VFSLocalFS(imgfile="/dummy.qcow2", imgfmt="qcow2") vfs.imgdir = "/scratch/dir" @@ -322,27 +352,36 @@ class VirtDiskVFSLocalFSTest(test.TestCase): self.assertEquals(files["/scratch/dir/some/file"]["uid"], 110) self.assertEquals(files["/scratch/dir/some/file"]["gid"], 600) + root_helper = 'sudo nova-rootwrap %s' % CONF.rootwrap_config self.assertEqual(commands, [{'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('cat', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('chown', 'fred', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('chgrp', 'users', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('readlink', '-nm', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}, + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}, {'args': ('chown', 'joe:admins', '/scratch/dir/some/file'), - 'kwargs': {'run_as_root': True}}]) + 'kwargs': {'run_as_root': True, + 'root_helper': root_helper}}]) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 62e9b08f1..9a366d7bf 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -39,7 +39,7 @@ from nova.openstack.common import log as logging from nova import test from nova.tests.db import fakes as db_fakes from nova.tests import fake_network -from nova.tests import fake_utils +from nova.tests import fake_processutils import nova.tests.image.fake as fake_image from nova.tests import matchers from nova.tests.xenapi import stubs @@ -323,7 +323,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): stubs.stubout_get_this_vm_uuid(self.stubs) stubs.stubout_is_vdi_pv(self.stubs) stubs.stub_out_vm_methods(self.stubs) - fake_utils.stub_out_utils_execute(self.stubs) + fake_processutils.stub_out_processutils_execute(self.stubs) self.user_id = 'fake' self.project_id = 'fake' self.context = context.RequestContext(self.user_id, self.project_id) @@ -872,7 +872,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): def _readlink_handler(cmd_parts, **kwargs): return os.path.realpath(cmd_parts[2]), '' - fake_utils.fake_execute_set_repliers([ + fake_processutils.fake_execute_set_repliers([ # Capture the tee .../etc/network/interfaces command (r'tee.*interfaces', _tee_handler), (r'readlink -nm.*', _readlink_handler), @@ -917,7 +917,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): self._tee_executed = True return '', '' - fake_utils.fake_execute_set_repliers([ + fake_processutils.fake_execute_set_repliers([ (r'mount', _mount_handler), (r'umount', _umount_handler), (r'tee.*interfaces', _tee_handler)]) @@ -1319,7 +1319,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase): self.migration = db.migration_create( context.get_admin_context(), migration_values) - fake_utils.stub_out_utils_execute(self.stubs) + fake_processutils.stub_out_processutils_execute(self.stubs) stubs.stub_out_migration_methods(self.stubs) stubs.stubout_get_this_vm_uuid(self.stubs) diff --git a/nova/utils.py b/nova/utils.py index 64606f4f8..aaa46d31e 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -155,71 +155,10 @@ def execute(*cmd, **kwargs): def trycmd(*args, **kwargs): - """ - A wrapper around execute() to more easily handle warnings and errors. - - Returns an (out, err) tuple of strings containing the output of - the command's stdout and stderr. If 'err' is not empty then the - command can be considered to have failed. - - :discard_warnings True | False. Defaults to False. If set to True, - then for succeeding commands, stderr is cleared - - """ - discard_warnings = kwargs.pop('discard_warnings', False) - - try: - out, err = execute(*args, **kwargs) - failed = False - except processutils.ProcessExecutionError, exn: - out, err = '', str(exn) - failed = True - - if not failed and discard_warnings and err: - # Handle commands that output to stderr but otherwise succeed - err = '' - - return out, err - - -def ssh_execute(ssh, cmd, process_input=None, - addl_env=None, check_exit_code=True): - LOG.debug(_('Running cmd (SSH): %s'), cmd) - if addl_env: - raise exception.NovaException(_('Environment not supported over SSH')) - - if process_input: - # This is (probably) fixable if we need it... - msg = _('process_input not supported over SSH') - raise exception.NovaException(msg) - - stdin_stream, stdout_stream, stderr_stream = ssh.exec_command(cmd) - channel = stdout_stream.channel - - #stdin.write('process_input would go here') - #stdin.flush() - - # NOTE(justinsb): This seems suspicious... - # ...other SSH clients have buffering issues with this approach - stdout = stdout_stream.read() - stderr = stderr_stream.read() - stdin_stream.close() - - exit_status = channel.recv_exit_status() - - # exit_status == -1 if no exit code was returned - if exit_status != -1: - LOG.debug(_('Result was %s') % exit_status) - if check_exit_code and exit_status != 0: - # TODO(mikal): I know this is a bit odd, but its needed for - # consistency. I will move this method into processutils in a - # later change. - raise processutils.ProcessExecutionError(exit_code=exit_status, - stdout=stdout, - stderr=stderr, - cmd=cmd) - - return (stdout, stderr) + """Convenience wrapper around oslo's trycmd() method.""" + if 'run_as_root' in kwargs and not 'root_helper' in kwargs: + kwargs['root_helper'] = 'sudo nova-rootwrap %s' % CONF.rootwrap_config + return processutils.trycmd(*args, **kwargs) def novadir(): diff --git a/nova/virt/baremetal/virtual_power_driver.py b/nova/virt/baremetal/virtual_power_driver.py index 22dd815d0..e110bf436 100644 --- a/nova/virt/baremetal/virtual_power_driver.py +++ b/nova/virt/baremetal/virtual_power_driver.py @@ -24,7 +24,6 @@ from nova import exception from nova.openstack.common import importutils from nova.openstack.common import log as logging from nova.openstack.common import processutils -from nova import utils from nova.virt.baremetal import baremetal_states from nova.virt.baremetal import base from nova.virt.baremetal import db @@ -230,8 +229,8 @@ class VirtualPowerManager(base.PowerManager): cmd = '%s %s' % (self._vp_cmd.base_cmd, cmd) try: - stdout, stderr = utils.ssh_execute(self._connection, cmd, - check_exit_code=check_exit_code) + stdout, stderr = processutils.ssh_execute( + self._connection, cmd, check_exit_code=check_exit_code) result = stdout.strip().splitlines() LOG.debug('Result for run_command: %s' % result) except processutils.ProcessExecutionError: diff --git a/nova/virt/powervm/blockdev.py b/nova/virt/powervm/blockdev.py index 0c3528d5c..5b15c14bb 100644 --- a/nova/virt/powervm/blockdev.py +++ b/nova/virt/powervm/blockdev.py @@ -25,7 +25,7 @@ from nova.compute import task_states from nova.image import glance from nova.openstack.common import excutils from nova.openstack.common import log as logging -from nova import utils +from nova.openstack.common import processutils from nova.virt import images from nova.virt.powervm import command from nova.virt.powervm import common @@ -533,8 +533,8 @@ class PowerVMLocalVolumeAdapter(PowerVMDiskAdapter): :param command: String with the command to run. """ self._set_connection() - stdout, stderr = utils.ssh_execute(self._connection, cmd, - check_exit_code=check_exit_code) + stdout, stderr = processutils.ssh_execute( + self._connection, cmd, check_exit_code=check_exit_code) error_text = stderr.strip() if error_text: diff --git a/nova/virt/powervm/common.py b/nova/virt/powervm/common.py index 0b1dc6a14..0fd2f84a4 100644 --- a/nova/virt/powervm/common.py +++ b/nova/virt/powervm/common.py @@ -23,7 +23,6 @@ import paramiko from nova.openstack.common import log as logging from nova.openstack.common import processutils -from nova import utils from nova.virt.powervm import constants from nova.virt.powervm import exception @@ -113,7 +112,7 @@ def ssh_command_as_root(ssh_connection, cmd, check_exit_code=True): stdin.flush() exit_status = chan.recv_exit_status() - # Lets handle the error just like nova.utils.ssh_execute does. + # Lets handle the error just like processutils.ssh_execute does. if exit_status != -1: LOG.debug(_('Result was %s') % exit_status) if check_exit_code and exit_status != 0: @@ -218,7 +217,7 @@ def vios_to_vios_auth(source, dest, conn_info): dest_conn_obj = ssh_connect(dest_conn_info) def run_command(conn_obj, cmd): - stdout, stderr = utils.ssh_execute(conn_obj, cmd) + stdout, stderr = processutils.ssh_execute(conn_obj, cmd) return stdout.strip().splitlines() def build_keypair_on_source(): diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py index 2539f29b1..f78aeb475 100644 --- a/nova/virt/powervm/operator.py +++ b/nova/virt/powervm/operator.py @@ -25,7 +25,6 @@ from nova.compute import power_state from nova.openstack.common import excutils from nova.openstack.common import log as logging from nova.openstack.common import processutils -from nova import utils from nova.virt.powervm import blockdev from nova.virt.powervm import command from nova.virt.powervm import common @@ -666,8 +665,8 @@ class BaseOperator(object): :param command: String with the command to run. """ self._set_connection() - stdout, stderr = utils.ssh_execute(self._connection, cmd, - check_exit_code=check_exit_code) + stdout, stderr = processutils.ssh_execute( + self._connection, cmd, check_exit_code=check_exit_code) error_text = stderr.strip() if error_text: |