From f5628a2c44e3e008c432ab03a2b31983feefb30d Mon Sep 17 00:00:00 2001 From: Srikanth Aithal Date: Fri, 5 Jul 2019 12:53:14 +0530 Subject: [PATCH] update disk related API to adopt utils_disk refactor testcases to adopt utils_disk API reorg. Signed-off-by: Srikanth Aithal --- libvirt/tests/src/bios/virsh_boot.py | 3 ++- libvirt/tests/src/migration/migrate_vm.py | 7 ++++--- libvirt/tests/src/npiv/npiv_concurrent.py | 3 ++- libvirt/tests/src/resource_abnormal.py | 5 +++-- libvirt/tests/src/virsh_cmd/domain/virsh_blkiotune.py | 2 +- libvirt/tests/src/virsh_cmd/domain/virsh_blockresize.py | 3 ++- .../src/virsh_cmd/domain/virsh_migrate_virtio_scsi.py | 4 ++-- libvirt/tests/src/virsh_cmd/volume/virsh_vol_clone_wipe.py | 6 +++--- libvirt/tests/src/virsh_cmd/volume/virsh_vol_resize.py | 5 +++-- libvirt/tests/src/virsh_cmd/volume/virsh_volume.py | 3 ++- libvirt/tests/src/virtual_disks/virtual_disks_gluster.py | 3 ++- v2v/tests/src/v2v_options.py | 3 ++- 12 files changed, 28 insertions(+), 19 deletions(-) diff --git a/libvirt/tests/src/bios/virsh_boot.py b/libvirt/tests/src/bios/virsh_boot.py index 17651c70ef..9a816ab6f7 100755 --- a/libvirt/tests/src/bios/virsh_boot.py +++ b/libvirt/tests/src/bios/virsh_boot.py @@ -13,6 +13,7 @@ from virttest.libvirt_xml.devices.disk import Disk from virttest.utils_test import libvirt as utlv from virttest import utils_misc +from virttest import utils_disk from virttest import data_dir from virttest import ceph @@ -426,7 +427,7 @@ def prepare_gluster_disk(blk_source, test, **kwargs): host_ip = utlv.setup_or_cleanup_gluster(True, vol_name, brick_path) logging.debug("host ip: %s ", host_ip) # Copy the domain disk image to gluster disk path - image_info = utils_misc.get_image_info(blk_source) + image_info = utils_disk.get_image_info(blk_source) dest_image = "/mnt/%s" % disk_img if image_info["format"] == disk_format: disk_cmd = ("cp -f %s %s" % (blk_source, dest_image)) diff --git a/libvirt/tests/src/migration/migrate_vm.py b/libvirt/tests/src/migration/migrate_vm.py index 07da98b3dc..d434b77eb5 100644 --- a/libvirt/tests/src/migration/migrate_vm.py +++ b/libvirt/tests/src/migration/migrate_vm.py @@ -19,6 +19,7 @@ from virttest import utils_config from virttest import utils_libvirtd from virttest import utils_misc +from virttest import utils_disk from virttest import utils_netperf from virttest import utils_package from virttest import utils_selinux @@ -371,7 +372,7 @@ def prepare_gluster_disk(params): host_ip = libvirt.setup_or_cleanup_gluster(True, vol_name, brick_path, pool_name) logging.debug("host ip: %s ", host_ip) - image_info = utils_misc.get_image_info(image_source) + image_info = utils_disk.get_image_info(image_source) if image_info["format"] == disk_format: disk_cmd = ("cp -f %s /mnt/%s" % (image_source, disk_img)) else: @@ -1445,7 +1446,7 @@ def run(test, params, env): if disk_name or disk_type or disk_cache: update_disk_driver(vm_name, disk_name, disk_type, disk_cache) - image_info_dict = utils_misc.get_image_info(disk_source) + image_info_dict = utils_disk.get_image_info(disk_source) logging.debug("disk image info: %s", image_info_dict) target_image_source = test_dict.get("target_image_source", disk_source) cmd = test_dict.get("create_another_target_image_cmd") @@ -1735,7 +1736,7 @@ def run(test, params, env): local_image_source = test_dict.get("local_image_source") tgt_size = 0 if local_image_source and check_image_size: - image_info_dict = utils_misc.get_image_info(local_image_source) + image_info_dict = utils_disk.get_image_info(local_image_source) logging.debug("Local disk image info: %s", image_info_dict) dsize = image_info_dict["dsize"] diff --git a/libvirt/tests/src/npiv/npiv_concurrent.py b/libvirt/tests/src/npiv/npiv_concurrent.py index 4c460814f3..a9d75984e5 100644 --- a/libvirt/tests/src/npiv/npiv_concurrent.py +++ b/libvirt/tests/src/npiv/npiv_concurrent.py @@ -8,6 +8,7 @@ from virttest import virsh from virttest import utils_misc +from virttest import utils_disk from virttest import utils_npiv from virttest.libvirt_xml import vm_xml from virttest.libvirt_xml.devices import disk @@ -263,7 +264,7 @@ def run(test, params, env): path_to_blk = os.path.join(_BYPATH_DIR, lun_dev) path_to_blks.append(path_to_blk) img_src = vm.get_first_disk_devices()['source'] - img_info = utils_misc.get_image_info(img_src) + img_info = utils_disk.get_image_info(img_src) src_fmt = img_info["format"] dest_fmt = "qcow2" convert_img_to_dev(test, src_fmt, dest_fmt, img_src, path_to_blk) diff --git a/libvirt/tests/src/resource_abnormal.py b/libvirt/tests/src/resource_abnormal.py index bd9e6f2bf8..763b91a7a8 100644 --- a/libvirt/tests/src/resource_abnormal.py +++ b/libvirt/tests/src/resource_abnormal.py @@ -17,6 +17,7 @@ from virttest import qemu_storage from virttest import libvirt_vm from virttest import utils_misc +from virttest import utils_disk from virttest import virsh from virttest import remote from virttest import data_dir @@ -175,7 +176,7 @@ def __init__(self, test, params): xml_file = vm_xml.VMXML.new_from_inactive_dumpxml(self.vm_name) disk_node = xml_file.get_disk_all()['vda'] source_file = disk_node.find('source').get('file') - self.image_size = utils_misc.get_image_info(source_file)['dsize'] + self.image_size = utils_disk.get_image_info(source_file)['dsize'] # Set the size to be image_size iscsi_size = "%sM" % (self.image_size / 1024 / 1024) params['image_size'] = iscsi_size @@ -341,7 +342,7 @@ def __init__(self, test, params): xml_file = vm_xml.VMXML.new_from_inactive_dumpxml(self.vm_name) disk_node = xml_file.get_disk_all()['vda'] source_file = disk_node.find('source').get('file') - image_type = utils_misc.get_image_info(source_file)['format'] + image_type = utils_disk.get_image_info(source_file)['format'] if image_type != "qcow2": self.test.cancel("Disk image format is not qcow2, " "ignore snapshot test!") diff --git a/libvirt/tests/src/virsh_cmd/domain/virsh_blkiotune.py b/libvirt/tests/src/virsh_cmd/domain/virsh_blkiotune.py index 2a57ff99c4..e7cd59b912 100644 --- a/libvirt/tests/src/virsh_cmd/domain/virsh_blkiotune.py +++ b/libvirt/tests/src/virsh_cmd/domain/virsh_blkiotune.py @@ -6,7 +6,7 @@ from virttest import libvirt_xml, utils_libvirtd, virsh from virttest.staging import utils_cgroup -from virttest.utils_misc import get_dev_major_minor +from virttest.utils_disk import get_dev_major_minor from virttest.compat_52lts import results_stdout_52lts diff --git a/libvirt/tests/src/virsh_cmd/domain/virsh_blockresize.py b/libvirt/tests/src/virsh_cmd/domain/virsh_blockresize.py index 54e0851a32..98a5b822b1 100644 --- a/libvirt/tests/src/virsh_cmd/domain/virsh_blockresize.py +++ b/libvirt/tests/src/virsh_cmd/domain/virsh_blockresize.py @@ -7,6 +7,7 @@ from virttest import virsh from virttest import data_dir from virttest import utils_misc +from virttest import utils_disk from provider import libvirt_version @@ -130,7 +131,7 @@ def run(test, params, env): else: test.error("Unknown scale value") - image_info = utils_misc.get_image_info(image_path) + image_info = utils_disk.get_image_info(image_path) actual_size = int(image_info['vsize']) logging.info("The expected block size is %s bytes, " diff --git a/libvirt/tests/src/virsh_cmd/domain/virsh_migrate_virtio_scsi.py b/libvirt/tests/src/virsh_cmd/domain/virsh_migrate_virtio_scsi.py index dce4f50151..5fb754834c 100644 --- a/libvirt/tests/src/virsh_cmd/domain/virsh_migrate_virtio_scsi.py +++ b/libvirt/tests/src/virsh_cmd/domain/virsh_migrate_virtio_scsi.py @@ -8,7 +8,7 @@ from virttest import utils_test from virttest import virsh -from virttest import utils_misc +from virttest import utils_disk from virttest import libvirt_vm from virttest import virt_vm from virttest import remote @@ -146,7 +146,7 @@ def cleanup_ssh_config(vm): sys_image = vm.get_first_disk_devices() sys_image_source = sys_image["source"] - sys_image_info = utils_misc.get_image_info(sys_image_source) + sys_image_info = utils_disk.get_image_info(sys_image_source) logging.debug("System image information:\n%s", sys_image_info) sys_image_fmt = sys_image_info["format"] created_img_path = os.path.join(os.path.dirname(sys_image_source), diff --git a/libvirt/tests/src/virsh_cmd/volume/virsh_vol_clone_wipe.py b/libvirt/tests/src/virsh_cmd/volume/virsh_vol_clone_wipe.py index 4f10d222ff..fa25d2917f 100644 --- a/libvirt/tests/src/virsh_cmd/volume/virsh_vol_clone_wipe.py +++ b/libvirt/tests/src/virsh_cmd/volume/virsh_vol_clone_wipe.py @@ -14,7 +14,7 @@ from virttest import libvirt_storage from virttest import data_dir from virttest import virsh -from virttest import utils_misc +from virttest import utils_disk from virttest import libvirt_xml from provider import libvirt_version @@ -251,7 +251,7 @@ def run(test, params, env): key, virsh_vol_info[key]) vol_path = virsh.vol_path(new_vol_name, pool_name).stdout.strip() - qemu_vol_info = utils_misc.get_image_info(vol_path) + qemu_vol_info = utils_disk.get_image_info(vol_path) for key in qemu_vol_info: logging.debug("Wiped volume info(qemu): %s = %s", key, qemu_vol_info[key]) @@ -287,7 +287,7 @@ def run(test, params, env): key, virsh_vol_info[key]) vol_path = virsh.vol_path(vol_name, pool_name).stdout.strip() - qemu_vol_info = utils_misc.get_image_info(vol_path) + qemu_vol_info = utils_disk.get_image_info(vol_path) for key in qemu_vol_info: logging.debug("Wiped volume info(qemu): %s = %s", key, qemu_vol_info[key]) diff --git a/libvirt/tests/src/virsh_cmd/volume/virsh_vol_resize.py b/libvirt/tests/src/virsh_cmd/volume/virsh_vol_resize.py index 89389c1838..1bc7d0ab4a 100644 --- a/libvirt/tests/src/virsh_cmd/volume/virsh_vol_resize.py +++ b/libvirt/tests/src/virsh_cmd/volume/virsh_vol_resize.py @@ -9,6 +9,7 @@ from virttest import libvirt_storage from virttest import utils_misc +from virttest import utils_disk from virttest import virsh from virttest import libvirt_xml from virttest.utils_test import libvirt @@ -55,7 +56,7 @@ def get_expect_info(new_capacity, vol_path, test, resize_option=None): new_size = utils_misc.normalize_data_size(new_capacity, "B", factor) # Get image info - img_info = utils_misc.get_image_info(vol_path) + img_info = utils_disk.get_image_info(vol_path) # Init expect_info expect_info['Capacity'] = img_info['vsize'] @@ -197,7 +198,7 @@ def check_vol_info(pool_vol, vol_name, test, expect_info=None): try: # Get image info vol_path = pool_vol.list_volumes()[vol_name] - img_info = utils_misc.get_image_info(vol_path) + img_info = utils_disk.get_image_info(vol_path) if expect_info['Capacity'] != img_info['vsize']: logging.debug("Capacity(Virtual size) is %s bytes", img_info['vsize']) diff --git a/libvirt/tests/src/virsh_cmd/volume/virsh_volume.py b/libvirt/tests/src/virsh_cmd/volume/virsh_volume.py index 73d958c0e7..2b55bf3e73 100644 --- a/libvirt/tests/src/virsh_cmd/volume/virsh_volume.py +++ b/libvirt/tests/src/virsh_cmd/volume/virsh_volume.py @@ -5,6 +5,7 @@ from avocado.utils import process from virttest import utils_misc +from virttest import utils_disk from virttest import data_dir from virttest import virsh from virttest import libvirt_storage @@ -243,7 +244,7 @@ def check_vol(expected, avail=True): expected['name']) # Check format from against qemu-img info - img_info = utils_misc.get_image_info(expected['path']) + img_info = utils_disk.get_image_info(expected['path']) if expected['format']: if expected['format'] != img_info['format']: logging.error("Volume format mismatch for volume: %s\n" diff --git a/libvirt/tests/src/virtual_disks/virtual_disks_gluster.py b/libvirt/tests/src/virtual_disks/virtual_disks_gluster.py index 01bc2a677a..a73b942b82 100644 --- a/libvirt/tests/src/virtual_disks/virtual_disks_gluster.py +++ b/libvirt/tests/src/virtual_disks/virtual_disks_gluster.py @@ -6,6 +6,7 @@ from virttest import virsh from virttest import data_dir from virttest import utils_misc +from virttest import utils_disk from virttest import virt_vm, remote from virttest.utils_test import libvirt from virttest.libvirt_xml import vm_xml @@ -38,7 +39,7 @@ def prepare_gluster_disk(disk_img, disk_format): host_ip = libvirt.setup_or_cleanup_gluster(True, vol_name, brick_path, pool_name) logging.debug("host ip: %s ", host_ip) - image_info = utils_misc.get_image_info(image_source) + image_info = utils_disk.get_image_info(image_source) image_dest = "/mnt/%s" % disk_img if image_info["format"] == disk_format: diff --git a/v2v/tests/src/v2v_options.py b/v2v/tests/src/v2v_options.py index 6eb2296253..1c364880dd 100644 --- a/v2v/tests/src/v2v_options.py +++ b/v2v/tests/src/v2v_options.py @@ -15,6 +15,7 @@ from virttest import data_dir from virttest import ssh_key from virttest import utils_misc +from virttest import utils_disk from virttest import utils_v2v from virttest import virsh from virttest import remote @@ -171,7 +172,7 @@ def check_image(img_path, check_point, expected_value): """ if not img_path or not os.path.isfile(img_path): test.error("Image path: '%s' is invalid" % img_path) - img_info = utils_misc.get_image_info(img_path) + img_info = utils_disk.get_image_info(img_path) logging.debug("Image info: %s", img_info) if check_point == "allocation": if expected_value == "sparse":