
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1222312007 25200 # Node ID 27157c757211adf675236cab10777541aa7c8922 # Parent 375ae129b8e910fe42a5e4434b67ada5589bc72f [TEST] #3 Add helper function() to fix HostSystem related tc work with sblim base provider installed Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 375ae129b8e9 -r 27157c757211 suites/libvirt-cim/lib/XenKvmLib/classes.py --- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Tue Sep 23 04:45:04 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/classes.py Wed Sep 24 20:06:47 2008 -0700 @@ -22,10 +22,6 @@ virt_types = ['Xen', 'KVM', 'XenFV', 'LX virt_types = ['Xen', 'KVM', 'XenFV', 'LXC'] def get_typed_class(virt, basename): - if virt not in virt_types: - if virt != "Virt" and basename != "MigrationJob": - raise ValueError('Invalid class type') - if basename == None or basename == '': raise ValueError('Invalide class base name') diff -r 375ae129b8e9 -r 27157c757211 suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Sep 23 04:45:04 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Sep 24 20:06:47 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,23 @@ 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'] + linux_cs = None + try: + linux = enumclass.enumerate(server, 'ComputerSystem', keys, 'Linux') + if len(linux) == 1: + status = PASS + linux_cs = linux[0] + else: + logger.info("Enumerate of Linux_ComputerSystem return NULL") + except Exception, detail: + logger.error(CIM_ERROR_ENUMERATE, 'Linux_ComputerSystem') + logger.error("Exception: %s", detail) + + Globals.CIM_NS = 'root/virt' + return status, linux_cs diff -r 375ae129b8e9 -r 27157c757211 suites/libvirt-cim/lib/XenKvmLib/enumclass.py --- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Tue Sep 23 04:45:04 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Wed Sep 24 20:06:47 2008 -0700 @@ -63,6 +63,23 @@ class CIM_MyClass(CIM_Instance): return self.inst[attr] else: return CimExt._Method(self.__invoke, attr) + +class Linux_ComputerSystem(CIM_Instance): + def __init__(self, server, keys): + conn = pywbem.WBEMConnection('http://%s' % server, + (Globals.CIM_USER, Globals.CIM_PASS), + Globals.CIM_NS) + + try: + classname = self.__class__.__name__ + ref = CIMInstanceName(classname, + keybindings=keys) + inst = conn.GetInstance(ref) + except pywbem.CIMError, arg: + raise arg + + CIM_Instance.__init__(self, inst) + class CIM_ComputerSystem(CIM_MyClass): pass