+1 from me =)

Best,
Regards

Daisy (Ô˹úÁ«)
VSM Team, China Systems & Technology Labs (CSTL)
E-mail: yunguol@cn.ibm.com
TEL: (86)-21-60922144
Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203


libvirt-cim-bounces@redhat.com wrote on 2008-07-16 00:32:15:

> # HG changeset patch
> # User Kaitlin Rupert <karupert@us.ibm.com>
> # Date 1216138782 25200
> # Node ID 329b99c8516d4f0ae9ae49ed63ac0f4469917931
> # Parent  aee2bda69644fbf01ec3fbe038ecf6c52d63555a
> [TEST] #2 Remove guest creation from LogicalDisk - 02_nodevs.py.
>
> The point of this test is to ensure no devices are returned from
> EnumerateInstances() in the case where no guest is defined (or in
> the case where only Domain-0 is defined).
>
> Also add support for LXC.
>
> In the case where devices.enumerate() encountered a CIM error, raise
> an exception instead of printing an error.
>
> Updates from 1 to 2:
>   -Fix spacing in clean_system()
>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
>
> diff -r aee2bda69644 -r 329b99c8516d suites/libvirt-
> cim/cimtest/LogicalDisk/02_nodevs.py
> --- a/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py   Tue Jul
> 15 09:14:20 2008 -0700
> +++ b/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py   Tue Jul
> 15 09:19:42 2008 -0700
> @@ -25,21 +25,23 @@
>  
>  import sys
>  import pywbem
> -from VirtLib import utils
>  from VirtLib import live
>  from XenKvmLib import devices
> -from XenKvmLib.classes import get_typed_class
> -from XenKvmLib.vxml import XenXML, KVMXML, get_class
> -from XenKvmLib.test_doms import define_test_domain, undefine_test_domain
> -from XenKvmLib.test_xml import testxml
> -from CimTest.Globals import logger, do_main
> +from CimTest.Globals import logger, do_main, CIM_ERROR_ENUMERATE
> +from CimTest.ReturnCodes import PASS, FAIL, SKIP
>  
> -sup_types = ['Xen', 'KVM', 'XenFV']
> +sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
>  
>  test_dom = "test_domain"
>  def clean_system(host, virt='Xen'):
>      l = live.domain_list(host, virt)
> -    if len(l) > 1:
> +
> +    if virt == "XenFV" or virt == "Xen":
> +        if len(l) > 1:
> +            return False
> +        else:
> +            return True
> +    elif len(l) > 0:
>          return False
>      else:
>          return True
> @@ -49,31 +51,27 @@
>      options = main.options
>      if not clean_system(options.ip, options.virt):
>          logger.error("System has defined domains; unable to run")
> -        return 2
> +        return SKIP
>  
> -    if options.virt == 'Xen':
> -        test_dev = 'xvda'
> -    else:
> -        test_dev = 'hda'
> +    key_list = ["DeviceID", "CreationClassName", "SystemName",
> +                "SystemCreationClassName"]
>  
> -    vsxml = get_class(options.virt)(test_dom, disk=test_dev)
> -    ret = vsxml.define(options.ip)
> -    if not ret:
> -        logger.error("Failed to Define the dom: %s", test_dom)
> +    cn = "LogicalDisk"
> +
> +    try:
> +        devs = devices.enumerate(options.ip, cn, key_list, options.virt)
> +
> +    except Exception, details:
> +        logger.error(CIM_ERROR_ENUMERATE, cn)
> +        logger.error(details)
>          return FAIL
>  
> -    devid = "%s/%s" % (test_dom, test_dev)
> +    if len(devs) != 0:
> +        logger.error("%s returned %d instead of empty list" % (cn,
> len(devs)))
> +        status = FAIL
> +    else:
> +        status = PASS
>  
> -    status = 0
> -    key_list = ["DeviceID", "CreationClassName", "SystemName",
> "SystemCreationClassName"]
> -
> -    devs = devices.enumerate(options.ip, 'LogicalDisk', key_list)
> -    if devs.__class__ == str:
> -        logger.error("Got error instead of empty list: %s" % devs)
> -        status = 1    
> -
> -    vsxml.undefine(options.ip)
> -    
>      return status
>  
>  if __name__ == "__main__":
> diff -r aee2bda69644 -r 329b99c8516d suites/libvirt-
> cim/lib/XenKvmLib/devices.py
> --- a/suites/libvirt-cim/lib/XenKvmLib/devices.py   Tue Jul 15 09:
> 14:20 2008 -0700
> +++ b/suites/libvirt-cim/lib/XenKvmLib/devices.py   Tue Jul 15 09:
> 19:42 2008 -0700
> @@ -85,6 +85,9 @@
>  class KVM_LogicalDisk(CIM_LogicalDisk):
>      pass
>  
> +class LXC_LogicalDisk(CIM_LogicalDisk):
> +    pass
> +
>  class Xen_NetworkPort(CIM_NetworkPort):
>      pass
>  
> @@ -123,7 +126,7 @@
>      try:
>          names = conn.EnumerateInstanceNames(devtype.__name__)
>      except pywbem.CIMError, arg:
> -        print arg[1]
> +        raise Exception("%s" % arg[1])
>          return list
>  
>      for name in names:
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim@redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim