convert_image: add flags required for IPA
To write whole disk images using convert_image we need to support cache flags and out-of-order. Change-Id: I60df5a747a51109965b432653184b1ee3c98e2a5
This commit is contained in:
parent
df9a2e85a5
commit
36b8486419
|
@ -479,9 +479,15 @@ def _retry_on_res_temp_unavailable(exc):
|
|||
retry=tenacity.retry_if_exception(_retry_on_res_temp_unavailable),
|
||||
stop=tenacity.stop_after_attempt(CONF.disk_utils.image_convert_attempts),
|
||||
reraise=True)
|
||||
def convert_image(source, dest, out_format, run_as_root=False):
|
||||
def convert_image(source, dest, out_format, run_as_root=False, cache=None,
|
||||
out_of_order=False):
|
||||
"""Convert image to other format."""
|
||||
cmd = ('qemu-img', 'convert', '-O', out_format, source, dest)
|
||||
cmd = ['qemu-img', 'convert', '-O', out_format]
|
||||
if cache is not None:
|
||||
cmd += ['-t', cache]
|
||||
if out_of_order:
|
||||
cmd.append('-W')
|
||||
cmd += [source, dest]
|
||||
try:
|
||||
utils.execute(*cmd, run_as_root=run_as_root,
|
||||
prlimit=_qemu_img_limits(),
|
||||
|
|
|
@ -1099,6 +1099,17 @@ class OtherFunctionTestCase(base.IronicLibTestCase):
|
|||
prlimit=mock.ANY,
|
||||
use_standard_locale=True)
|
||||
|
||||
@mock.patch.object(utils, 'execute', autospec=True)
|
||||
def test_convert_image_flags(self, execute_mock):
|
||||
disk_utils.convert_image('source', 'dest', 'out_format',
|
||||
cache='directsync', out_of_order=True)
|
||||
execute_mock.assert_called_once_with('qemu-img', 'convert', '-O',
|
||||
'out_format', '-t', 'directsync',
|
||||
'-W', 'source', 'dest',
|
||||
run_as_root=False,
|
||||
prlimit=mock.ANY,
|
||||
use_standard_locale=True)
|
||||
|
||||
@mock.patch.object(utils, 'execute', autospec=True)
|
||||
def test_convert_image_retries(self, execute_mock):
|
||||
ret_err = 'qemu: qemu_thread_create: Resource temporarily unavailable'
|
||||
|
|
Loading…
Reference in New Issue