
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1233789475 28800 # Node ID 2d445349b1e6fc2dff2f86e12566a0e55259b44a # Parent edfa908a60d058c7f1ba7394bd1d818999802287 [TEST] #3 Update VSMS 14_define_sys_disk.py to use cim_define() Updates from 2 to 3: -Verify the Address attribute of the DiskRASD for the guest is the same address specified during the define call. Updates form 1 to 2: -Added comment to describe test -Added flag to indicate whether guest should be undefined Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r edfa908a60d0 -r 2d445349b1e6 suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py Tue Feb 03 09:37:05 2009 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py Wed Feb 04 15:17:55 2009 -0800 @@ -18,6 +18,14 @@ # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Purpose: +# Verify providers support disk images with long paths / names +# +# Steps: +# 1) Create a disk image with a long path +# 2) Build RASD parameters, making sure to specify disk image created in step 1 +# 3) Verify guest is defined properly # import sys @@ -25,14 +33,13 @@ from VirtLib.utils import run_remote from CimTest.Globals import logger from CimTest.ReturnCodes import FAIL, PASS -from XenKvmLib.common_util import create_using_definesystem -from XenKvmLib.test_doms import destroy_and_undefine_domain from XenKvmLib.classes import get_typed_class, inst_to_mof from XenKvmLib.rasd import get_default_rasds -from XenKvmLib.vsms import get_vssd_mof -from XenKvmLib.const import get_provider_version from XenKvmLib.const import do_main, _image_dir, f9_changeset, \ - KVM_default_disk_dev + KVM_default_disk_dev, get_provider_version +from XenKvmLib.vxml import get_class +from XenKvmLib.common_util import parse_instance_id +from XenKvmLib.enumclass import EnumInstances sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] test_dom = 'rstest_disk_domain' @@ -50,28 +57,58 @@ return path -def get_vssd_rasd(ip, virt, addr, disk_type): - vssd = get_vssd_mof(virt, test_dom) +def get_rasd_list(ip, virt, addr, disk_type): + drasd_cn = get_typed_class(virt, "DiskResourceAllocationSettingData") rasds = get_default_rasds(ip, virt) - rasd_list = [] + rasd_list = {} for rasd in rasds: - if 'DiskPool' in rasd['PoolID']: + if rasd.classname == drasd_cn: if disk_type != "" and rasd['Caption'] != disk_type: continue rasd['Address'] = addr curr_cim_rev, changeset = get_provider_version(virt, ip) if changeset == f9_changeset and virt == 'KVM': rasd['VirtualDevice'] = KVM_default_disk_dev - rasd_list.append(inst_to_mof(rasd)) + rasd_list[rasd.classname] = inst_to_mof(rasd) - params = { 'vssd' : vssd, - 'rasd' : rasd_list - } + return rasd_list - return params +def verify_disk_path(ip, virt, addr, guest_name): + inst = None + + try: + drasd_cn = get_typed_class(virt, 'DiskResourceAllocationSettingData') + enum_list = EnumInstances(ip, drasd_cn) + + if enum_list < 1: + raise Exception("No %s instances returned" % drasd_cn) + + for rasd in enum_list: + guest, dev, status = parse_instance_id(rasd.InstanceID) + if status != PASS: + raise Exception("Unable to parse InstanceID: %s" % \ + rasd.InstanceID) + + if guest == guest_name: + inst = rasd + break + + if inst is None: + raise Exception("%s instance for %s not found" % (drasd_cn, + guest_name)) + + if inst.Address != addr: + raise Exception("%s instance for %s not found" % (drasd_cn, + guest_name)) + + except Exception, details: + logger.error(details) + return FAIL + + return PASS @do_main(sup_types) def main(): @@ -84,20 +121,29 @@ else: disk_cap = "" + cxml = get_class(options.virt)(test_dom) + + guest_defined = False + try: addr = make_long_disk_path(options.ip) if addr is None: raise Exception("Unable to create large disk image") - define_params = get_vssd_rasd(options.ip, options.virt, addr, disk_cap) - if len(define_params) != 2: - raise Exception("Unable to get VSSD and RASDs for %s" % test_dom) + rasd_list = get_rasd_list(options.ip, options.virt, addr, disk_cap) + if len(rasd_list) < 1: + raise Exception("Unable to get template RASDs for %s" % test_dom) - status = create_using_definesystem(test_dom, options.ip, - params=define_params, ref_config="", - virt=options.virt) + cxml.set_res_settings(rasd_list) + ret = cxml.cim_define(options.ip) + if not ret: + raise Exception("Unable to define %s" % test_dom) + + guest_defined = True + + status = verify_disk_path(options.ip, options.virt, addr, test_dom) if status != PASS: - raise Exception("Unable to define %s" % test_dom) + raise Exception("Failed to verify disk path for %s" % test_dom) except Exception, details: logger.error(details) @@ -106,7 +152,8 @@ if os.path.exists(addr): os.remove(addr) - destroy_and_undefine_domain(test_dom, options.ip, options.virt) + if guest_defined == True: + cxml.undefine(options.ip) return status