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

> # HG changeset patch
> # User Kaitlin Rupert <karupert@us.ibm.com>
> # Date 1216051613 25200
> # Node ID d44423ea6fcf1af4d75ccc69caa3fd727459a770
> # Parent  7caeda6d0b06d47dd3e1b2758db16954e09725ce
> [TEST] 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.
>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
>
> diff -r 7caeda6d0b06 -r d44423ea6fcf suites/libvirt-
> cim/cimtest/LogicalDisk/02_nodevs.py
> --- a/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py   Mon Jul
> 14 08:42:34 2008 -0700
> +++ b/suites/libvirt-cim/cimtest/LogicalDisk/02_nodevs.py   Mon Jul
> 14 09:06:53 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

      Typos error, it takes four spaces.

> +    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 7caeda6d0b06 -r d44423ea6fcf suites/libvirt-
> cim/lib/XenKvmLib/devices.py
> --- a/suites/libvirt-cim/lib/XenKvmLib/devices.py   Mon Jul 14 08:
> 42:34 2008 -0700
> +++ b/suites/libvirt-cim/lib/XenKvmLib/devices.py   Mon Jul 14 09:
> 06:53 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