[Libvirt-cim] [PATCH] [TEST] Update VSMS 14_define_sys_disk.py to use cim_define()

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Tue Feb 3 09:28:46 UTC 2009



Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1233605202 28800
> # Node ID f9b044c4d5ddeed5b2383186ebfb9337b102ba5d
> # Parent  4327fd7361d8107c8f7fc827d62162e9151ff6dd
> [TEST] Update VSMS 14_define_sys_disk.py to use cim_define()
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r 4327fd7361d8 -r f9b044c4d5dd suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py
> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py	Mon Feb 02 12:04:30 2009 -0800
> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/14_define_sys_disk.py	Mon Feb 02 12:06:42 2009 -0800
> @@ -25,14 +25,11 @@
>  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
>
>  sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
>  test_dom = 'rstest_disk_domain'
> @@ -50,28 +47,24 @@
>
>      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 params 
> +    return rasd_list 
>
>  @do_main(sup_types)
>  def main():
> @@ -84,21 +77,24 @@
>      else:
>          disk_cap = "" 
>
> +    cxml = get_class(options.virt)(test_dom)
> +
>      try:
>          addr = make_long_disk_path(options.ip)
>          if addr is None:
>              raise Exception("Unable to create large disk image")
>   
You can immediately return from here instead of raising an Exception. 
Also if you raise an exception then calling

cxml.undefine(options.ip) is not needed as we would have not defined the guest.

 
> -        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)
> -        if status != PASS:
> +        cxml.set_res_settings(rasd_list)
> +        ret = cxml.cim_define(options.ip)
> +        if not ret:
>              raise Exception("Unable to define %s" % test_dom)
>   
same here.
> +        status = PASS
> +
>      except Exception, details:
>          logger.error(details)
>          status = FAIL
> @@ -106,7 +102,7 @@
>      if os.path.exists(addr):
>          os.remove(addr)
>
> -    destroy_and_undefine_domain(test_dom, options.ip, options.virt)
> +    cxml.undefine(options.ip)
>
>      return status 
>
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>   

-- 
Thanks and Regards,
Deepti B. Kalakeri
IBM Linux Technology Center
deeptik at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list