[Libvirt-cim] [PATCH] [TEST] #2 patch set of fixing HostSystem-01_enum.py with sblim base provider installed

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Wed Sep 24 12:45:55 UTC 2008



yunguol at cn.ibm.com wrote:
> # HG changeset patch
> # User Guolian Yun <yunguol at cn.ibm.com>
> # Date 1222236393 25200
> # Node ID 83add054f191b8b6ad2c4ba53fce67cdca455989
> # Parent  d2ae228a60c34b78c3dd1e4f43f6a5413898980d
> [TEST] #2 patch set of fixing HostSystem-01_enum.py with sblim base provider installed
>
> Signed-off-by: Guolian Yun <yunguol at cn.ibm.com>
>
>
>
> diff -r d2ae228a60c3 -r 83add054f191 suites/libvirt-cim/lib/XenKvmLib/common_util.py
> --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py	Mon Sep 22 11:28:02 2008 -0700
> +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py	Tue Sep 23 23:06:33 2008 -0700
> @@ -27,7 +27,8 @@ from distutils.file_util import move_fil
>  from distutils.file_util import move_file
>  from XenKvmLib.test_xml import * 
>  from XenKvmLib.test_doms import * 
> -from XenKvmLib import vsms 
> +from XenKvmLib import vsms
> +from CimTest import Globals 
>  from XenKvmLib import enumclass 
>  from pywbem.cim_obj import CIMInstanceName
>  from XenKvmLib.devices import CIM_Instance
> @@ -477,4 +478,22 @@ def libvirt_cached_data_poll(ip, virt, d
>
>              sleep(1)
>              
> -    return cs 
> +    return cs
> +
> +def check_sblim(server, virt='Xen'):
> +    status = FAIL
> +    Globals.CIM_NS = 'root/cimv2'
> +    keys = ['Name', 'CreationClassName']
> +    try:
> +        linux_cs = enumclass.enumerate(server, 'ComputerSystem', keys, 'Linux')
> +        host_sys = enumclass.enumerate(server, 'HostSystem', keys, virt)
> +        if len(linux_cs) == 1 and len(host_sys) == 0:
> +            status = PASS
> +        else:
> +            logger.info("sblim base provider is not installed")
> +    except Exception, detail:
> +        logger.error(CIM_ERROR_ENUMERATE, 'Linux_ComputerSystem')
> +        logger.error("Exception: %s", detail)
> +
> +    Globals.CIM_NS = 'root/virt'
> +    return status, linux_cs 
>   

The return statement will throw an error in case the exception block is 
hit, something similar to the one below.

*UnboundLocalError: local variable 'linux_cs' referenced before assignment.*

You should declare and initialize linux_cs before the try block.




More information about the Libvirt-cim mailing list