Remove utils.execute() from virt.disk.api.

Change-Id: I359a412fcabe9e59c99167b35bb3be6553e5f41b
This commit is contained in:
Michael Still 2018-11-26 17:22:45 +11:00
parent 1292fd52ff
commit fcb0691b72
2 changed files with 6 additions and 8 deletions

View File

@ -20,7 +20,6 @@ from oslo_concurrency import processutils
from oslo_utils import units
from nova import test
from nova import utils
from nova.virt.disk import api
from nova.virt.disk.mount import api as mount
from nova.virt.disk.vfs import localfs
@ -51,7 +50,7 @@ class APITestCase(test.NoDBTestCase):
self.assertFalse(api.is_image_extendable(image))
self.assertTrue(mock_image_fs.called)
@mock.patch.object(utils, 'execute', autospec=True)
@mock.patch('oslo_concurrency.processutils.execute', autospec=True)
def test_is_image_extendable_raw(self, mock_exec):
imgfile = tempfile.NamedTemporaryFile()
image = imgmodel.LocalFileImage(imgfile, imgmodel.FORMAT_RAW)
@ -107,7 +106,7 @@ class APITestCase(test.NoDBTestCase):
return_value=True)
@mock.patch.object(api, 'resize2fs', autospec=True)
@mock.patch.object(mount.Mount, 'instance_for_format')
@mock.patch.object(utils, 'execute', autospec=True)
@mock.patch('oslo_concurrency.processutils.execute', autospec=True)
def test_extend_qcow_success(self, mock_exec, mock_inst, mock_resize,
mock_extendable, mock_can_resize):
imgfile = tempfile.NamedTemporaryFile()
@ -145,7 +144,7 @@ class APITestCase(test.NoDBTestCase):
@mock.patch.object(api, 'can_resize_image', autospec=True,
return_value=True)
@mock.patch.object(api, 'is_image_extendable', autospec=True)
@mock.patch.object(utils, 'execute', autospec=True)
@mock.patch('oslo_concurrency.processutils.execute', autospec=True)
def test_extend_qcow_no_resize(self, mock_execute, mock_extendable,
mock_can_resize_image):
imgfile = tempfile.NamedTemporaryFile()
@ -179,7 +178,7 @@ class APITestCase(test.NoDBTestCase):
@mock.patch.object(api, 'can_resize_image', autospec=True,
return_value=True)
@mock.patch.object(api, 'resize2fs', autospec=True)
@mock.patch.object(utils, 'execute', autospec=True)
@mock.patch('oslo_concurrency.processutils.execute', autospec=True)
def test_extend_raw_success(self, mock_exec, mock_resize,
mock_can_resize):
imgfile = tempfile.NamedTemporaryFile()

View File

@ -39,7 +39,6 @@ from nova import exception
from nova.i18n import _
import nova.privsep.fs
import nova.privsep.libvirt
from nova import utils
from nova.virt.disk.mount import api as mount
from nova.virt.disk.vfs import api as vfs
from nova.virt.image import model as imgmodel
@ -136,7 +135,7 @@ def extend(image, size):
nova.privsep.libvirt.ploop_resize(image.path, size)
return
utils.execute('qemu-img', 'resize', image.path, size)
processutils.execute('qemu-img', 'resize', image.path, size)
if (image.format != imgmodel.FORMAT_RAW and
not CONF.resize_fs_using_block_device):
@ -218,7 +217,7 @@ def is_image_extendable(image):
else:
# For raw, we can directly inspect the file system
try:
utils.execute('e2label', image.path)
processutils.execute('e2label', image.path)
except processutils.ProcessExecutionError as e:
LOG.debug('Unable to determine label for image %(image)s with '
'error %(error)s. Cannot resize.',