[Libvirt-cim] [PATCH] [TEST] Update RASD -t 04_disk_rasd_size.py to user cim_define()

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Thu Jan 8 06:23:46 UTC 2009



Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1231350675 28800
> # Node ID f0ebc2def018b3d34a897762e249e922ca44f71f
> # Parent  0e5943129dc448a12b0cb8c382afbdcc61d89a7a
> [TEST] Update RASD -t 04_disk_rasd_size.py to user cim_define()
>
> Also, reorganize the test slighly so that there's no need to pass cxml to a
> function for the define call.
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r 0e5943129dc4 -r f0ebc2def018 suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py
> --- a/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py	Wed Jan 07 09:51:11 2009 -0800
> +++ b/suites/libvirt-cim/cimtest/RASD/04_disk_rasd_size.py	Wed Jan 07 09:51:15 2009 -0800
> @@ -29,11 +29,9 @@
>  from XenKvmLib.const import do_main
>  from CimTest.Globals import logger
>  from VirtLib import utils
> -from XenKvmLib.test_doms import undefine_test_domain
> -from XenKvmLib.common_util import create_using_definesystem
> -from XenKvmLib import vsms
>  from XenKvmLib import enumclass
>  from XenKvmLib.classes import get_typed_class
> +from XenKvmLib.vxml import get_class 
>
>  def make_image(ip, size):
>      s, fn = utils.run_remote(ip, "mktemp")
> @@ -59,47 +57,17 @@
>
>   
Can you change the message in the check_rasd_size() fn :
if rasd["AllocationUnits"] != "Bytes":
logger.error("AllocationUnits != Bytes?")
return FAIL
Looking at the error message in the log or on console will not give a 
clear information that we were expecting AllocationUnits to be Bytes.
Can you change it to something like:
logger.error("Allocationunits mismatch, returned %s , Expected %s", 
rasd["AllocationUnits"] ,"Bytes")

or something better.
>      try:
>          cim_size = int(rasd["VirtualQuantity"])
> -    except Exception, e:
> -        logger.error("Failed to get DiskRASD size: %s" % e)
> +    except Exception, details:
> +        logger.error("Failed to get DiskRASD size: %s" % details)
>          return FAIL
>
>      if cim_size != size:
>          logger.error("CIM reports %i bytes, but should be %i bytes" % (cim_size,
>                                                                         size))
>   
This should be aligned as below and we can also use comman instead of %:
logger.error("CIM reports disksize as %i bytes, but should be %i bytes" ,
cim_size, size)

>          return FAIL
> -    else:
> -        logger.info("Verified %i bytes" % cim_size)
> -        return PASS
>
> -def test_rasd(options, temp, test_size):
> -    vssd = vsms.get_vssd_mof(options.virt, default_dom)
> -
> -    drasd_class = vsms.get_dasd_class(options.virt)
> -    drasd = drasd_class("hda", temp, default_dom)
> -
> -    mrasd_class = vsms.get_masd_class(options.virt)
> -    mrasd = mrasd_class(name=default_dom, megabytes=32)
> -
> -    params = {
> -        "vssd" : vssd,
> -        "rasd" : [drasd.mof(), mrasd.mof()]
> -        }
> -
> -    create_using_definesystem(default_dom,
> -                              options.ip,
> -                              params=params,
> -                              virt=options.virt)
> -
> -    cn = get_typed_class(options.virt, 'DiskResourceAllocationSettingData') 
> -    rasds = enumclass.EnumInstances(options.ip, cn, ret_cim_inst=True)
> -
> -    status = FAIL
> -    for rasd in rasds:
> -        if rasd["Address"] == temp:
> -            status = check_rasd_size(rasd, test_size)
> -            break
> -
> -    return status
> +    logger.info("Verified %i bytes" % cim_size)
> +    return PASS
>
>  @do_main(sup_types)
>  def main():
> @@ -113,14 +81,29 @@
>          return FAIL
>
>      logger.info("Created temp disk %s of size %i bytes" % (temp, test_size))
> +   
> +    cxml = get_class(options.virt)(default_dom, mem=32, 
> +                                   disk_file_path=temp, disk="hda")
>   
The above line can be split as follows:
virt_type = get_class(options.virt)
> +    try:
> +        ret = cxml.cim_define(options.ip)
> +        if not ret:
> +            raise Exception("Failed to define the dom: %s" % default_dom)
>
> -    try:
> -        status = test_rasd(options, temp, test_size)
> -    except Exception, e:
> -        logger.error("Failed to test RASD: %s" % e)
> +        cn = get_typed_class(options.virt, 'DiskResourceAllocationSettingData') 
> +        rasds = enumclass.EnumInstances(options.ip, cn, ret_cim_inst=True)
>
>   
Instead of Enumerating the DiskRASD we can use GetInstance() on the domain.
Like that we would avoid the for rasd in rasds loop.
Instead we can verify the address directly if it is returned and then 
call the check_rasd_size() directly.
Any specific reason to use EnumInstances ?
> -    undefine_test_domain(default_dom, options.ip, options.virt)
> +        status = FAIL
> +        for rasd in rasds:
> +            if rasd["Address"] == temp:
> +                status = check_rasd_size(rasd, test_size)
> +                break
> +
> +    except Exception, details:
> +        logger.error("Failed to test RASD: %s" % details)
> +        status = FAIL
> +
>      kill_image(options.ip, temp)
> +    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