def _do_test_extract_snapshot(self, dest_format="raw", out_format="raw"): self.mox.StubOutWithMock(utils, "execute") utils.execute("qemu-img", "convert", "-f", "qcow2", "-O", out_format, "/path/to/disk/image", "/extracted/snap") # Start test self.mox.ReplayAll() libvirt_utils.extract_snapshot("/path/to/disk/image", "qcow2", "/extracted/snap", dest_format)
def _do_test_extract_snapshot(self, mock_execute, dest_format='raw', out_format='raw'): libvirt_utils.extract_snapshot('/path/to/disk/image', 'qcow2', '/extracted/snap', dest_format) mock_execute.assert_called_once_with( 'qemu-img', 'convert', '-f', 'qcow2', '-O', out_format, '/path/to/disk/image', '/extracted/snap')
def _do_test_extract_snapshot(self, mock_execute, src_format='qcow2', dest_format='raw', out_format='raw'): libvirt_utils.extract_snapshot('/path/to/disk/image', src_format, '/extracted/snap', dest_format) qemu_img_cmd = ('qemu-img', 'convert', '-f', src_format, '-O', out_format) if CONF.libvirt.snapshot_compression and dest_format == "qcow2": qemu_img_cmd += ('-c',) qemu_img_cmd += ('/path/to/disk/image', '/extracted/snap') mock_execute.assert_called_once_with(*qemu_img_cmd)
def _do_test_extract_snapshot(self, mock_execute, mock_direct_io, mock_disk_op_sema, src_format='qcow2', dest_format='raw', out_format='raw'): libvirt_utils.extract_snapshot('/path/to/disk/image', src_format, '/extracted/snap', dest_format) qemu_img_cmd = ('qemu-img', 'convert', '-t', 'none', '-O', out_format, '-f', src_format, ) if CONF.libvirt.snapshot_compression and dest_format == "qcow2": qemu_img_cmd += ('-c',) qemu_img_cmd += ('/path/to/disk/image', '/extracted/snap') mock_disk_op_sema.__enter__.assert_called_once() mock_direct_io.assert_called_once_with(CONF.instances_path) mock_execute.assert_called_once_with(*qemu_img_cmd)
def test_extract_snapshot_no_directio(self, mock_execute, mock_direct_io, mock_disk_op_sema): # Test a single variant with no support for direct IO. # This could be removed if we add unit tests for convert_image(). src_format = 'qcow2' dest_format = 'raw' out_format = 'raw' libvirt_utils.extract_snapshot('/path/to/disk/image', src_format, '/extracted/snap', dest_format) qemu_img_cmd = ('qemu-img', 'convert', '-t', 'writeback', '-O', out_format, '-f', src_format, ) if CONF.libvirt.snapshot_compression and dest_format == "qcow2": qemu_img_cmd += ('-c',) qemu_img_cmd += ('/path/to/disk/image', '/extracted/snap') mock_disk_op_sema.__enter__.assert_called_once() mock_direct_io.assert_called_once_with(CONF.instances_path) mock_execute.assert_called_once_with(*qemu_img_cmd)
def snapshot_extract(self, target, out_format): libvirt_utils.extract_snapshot(self.path, 'qcow2', target, out_format)
def snapshot_extract(self, target, out_format): img_path = os.path.join(self.path, "root.hds") libvirt_utils.extract_snapshot(img_path, 'parallels', target, out_format)
def _do_test_extract_snapshot(self, mock_execute, dest_format="raw", out_format="raw"): libvirt_utils.extract_snapshot("/path/to/disk/image", "qcow2", "/extracted/snap", dest_format) mock_execute.assert_called_once_with( "qemu-img", "convert", "-f", "qcow2", "-O", out_format, "/path/to/disk/image", "/extracted/snap" )
def snapshot_extract(self, target, out_format): libvirt_utils.extract_snapshot(self.path, "qcow2", self.snapshot_name, target, out_format)