From 43de8377429218a3a5a233546878701b2805fe1a Mon Sep 17 00:00:00 2001 From: Balamuruhan S Date: Tue, 4 Jun 2019 12:41:41 +0530 Subject: [PATCH] utils_disk: move `new_disk_vol_name()` to utils_disk reorganise disk related method to utils_disk. Signed-off-by: Balamuruhan S --- virttest/utils_disk.py | 20 ++++++++++++++++++++ virttest/utils_test/libvirt.py | 19 ------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/virttest/utils_disk.py b/virttest/utils_disk.py index 27c906355e2..2c3951ced96 100644 --- a/virttest/utils_disk.py +++ b/virttest/utils_disk.py @@ -24,6 +24,7 @@ from virttest import error_context from virttest import utils_numeric +from virttest.libvirt_xml import pool_xml from virttest.compat_52lts import decode_to_text from virttest.compat_52lts import results_stdout_52lts @@ -835,6 +836,25 @@ def get_disk_by_serial(serial_str, session=None): return disk +def new_disk_vol_name(pool_name): + """ + According to BZ#1138523, the new volume name must be the next + created partition(sdb1, etc.), so we need to inspect the original + partitions of the disk then count the new partition number. + + :param pool_name: Disk pool name + :return: New volume name or none + """ + poolxml = pool_xml.PoolXML.new_from_dumpxml(pool_name) + if poolxml.get_type(pool_name) != "disk": + logging.error("This is not a disk pool") + return None + disk = poolxml.get_source().device_path[5:] + part_num = len(list(filter(lambda s: s.startswith(disk), + get_parts_list()))) + return disk + str(part_num) + + class Disk(object): """ diff --git a/virttest/utils_test/libvirt.py b/virttest/utils_test/libvirt.py index 7f7500603c6..7a149ca6c63 100644 --- a/virttest/utils_test/libvirt.py +++ b/virttest/utils_test/libvirt.py @@ -3287,25 +3287,6 @@ def exec_virsh_edit(source, edit_cmd, connect_uri="qemu:///system"): return False -def new_disk_vol_name(pool_name): - """ - According to BZ#1138523, the new volume name must be the next - created partition(sdb1, etc.), so we need to inspect the original - partitions of the disk then count the new partition number. - - :param pool_name: Disk pool name - :return: New volume name or none - """ - poolxml = pool_xml.PoolXML.new_from_dumpxml(pool_name) - if poolxml.get_type(pool_name) != "disk": - logging.error("This is not a disk pool") - return None - disk = poolxml.get_source().device_path[5:] - part_num = len(list(filter(lambda s: s.startswith(disk), - utils_misc.utils_disk.get_parts_list()))) - return disk + str(part_num) - - def update_polkit_rule(params, pattern, new_value): """ This function help to update the rule during testing.