[PATCH 0 of 4] [TEST] Fix HostSystem.01 to work with sblim base provider installed and not

Follow up patch will fix the behavior of the enumerate() function, then update this patch sets Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1222152882 25200 # Node ID 529b767f1bb57a6e8079623168bf01bb7a5182e1 # Parent 3afab9812f48fd6ebbd123c9f678b0200895a540 [TEST] Define Linux_ComputerSystem class in enumclass Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 3afab9812f48 -r 529b767f1bb5 suites/libvirt-cim/lib/XenKvmLib/enumclass.py --- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Mon Sep 22 03:47:59 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Mon Sep 22 23:54:42 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

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1222152975 25200 # Node ID a85126ffa88f5fe6f9c11c1c84909df220963947 # Parent 529b767f1bb57a6e8079623168bf01bb7a5182e1 [TEST] Add check_sblim function to verify if sblim base provider is installed Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 529b767f1bb5 -r a85126ffa88f suites/libvirt-cim/lib/XenKvmLib/common_util.py --- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Sep 22 23:54:42 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Mon Sep 22 23:56:15 2008 -0700 @@ -38,7 +38,8 @@ from VirtLib.live import diskpool_list, from VirtLib.live import diskpool_list, virsh_version, net_list, domain_list from XenKvmLib.vxml import PoolXML, NetXML from XenKvmLib.enumclass import getInstance -from VirtLib import utils +from VirtLib import utils +from CimTest import Globals from XenKvmLib.const import default_pool_name, default_network_name disk_file = '/etc/libvirt/diskpool.conf' @@ -476,4 +477,21 @@ def libvirt_cached_data_poll(ip, virt, d sleep(1) - return cs + return cs + +def check_sblim(server): + status = FAIL + Globals.CIM_NS = 'root/cimv2' + keys = ['Name', 'CreationClassName'] + try: + linux_cs = enumclass.enumerate(server, 'ComputerSystem', keys, 'Linux') + if len(linux_cs) == 1: + 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

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1222153135 25200 # Node ID 98aff030dd48b0a1e08b90f6719d47c630b4d424 # Parent a85126ffa88f5fe6f9c11c1c84909df220963947 [TEST]Remove pieces in get_typed_class Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r a85126ffa88f -r 98aff030dd48 suites/libvirt-cim/lib/XenKvmLib/classes.py --- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Mon Sep 22 23:56:15 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/classes.py Mon Sep 22 23:58:55 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')

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1222153227 25200 # Node ID a22ec4af9d96154d80abf3c9240ec5f054a5fb50 # Parent 98aff030dd48b0a1e08b90f6719d47c630b4d424 [TEST] Fix HostSystem-01_enum with sblim base provider installed Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 98aff030dd48 -r a22ec4af9d96 suites/libvirt-cim/cimtest/HostSystem/01_enum.py --- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Mon Sep 22 23:58:55 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Tue Sep 23 00:00:27 2008 -0700 @@ -27,6 +27,7 @@ import sys from XenKvmLib import enumclass +from XenKvmLib.common_util import check_sblim from XenKvmLib.classes import get_typed_class from VirtLib import live from VirtLib import utils @@ -43,27 +44,34 @@ def main(): status = FAIL keys = ['Name', 'CreationClassName'] - try: - hs = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt) - name = get_typed_class(options.virt, 'HostSystem') + + status, linux_cs = check_sblim(options.ip) + if status == PASS: + name = 'Linux_ComputerSystem' + system = linux_cs[0] + else: + try: + hs = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt) + name = get_typed_class(options.virt, 'HostSystem') - if len(hs) != 1: - logger.error("Expected 1 %s instance returned" % name) - return FAIL + if len(hs) != 1: + logger.error("Expected 1 %s instance returned" % name) + return FAIL - system = hs[0] + system = hs[0] + except Exception, details: + logger.error("%s %s: %s" % (CIM_ERROR_ENUMERATE, name, details)) + status = FAIL - if system.CreationClassName != name or system.Name != host: - logger.error("Exp %s, got %s" % (name, system.CreationClassName)) - logger.error("Exp %s, got %s" % (host, system.Name)) - status = FAIL - else: - logger.info("%s is %s" % (name, host)) - status = PASS - except Exception, details: - logger.error("%s %s: %s" % (CIM_ERROR_ENUMERATE, name, details)) + if system.CreationClassName != name or system.Name != host: + logger.error("Exp %s, got %s" % (name, system.CreationClassName)) + logger.error("Exp %s, got %s" % (host, system.Name)) status = FAIL + else: + logger.info("%s is %s" % (name, host)) + status = PASS + return status

+ + status, linux_cs = check_sblim(options.ip) + if status == PASS: + name = 'Linux_ComputerSystem' + system = linux_cs[0] + else:
You'll want to verify that if check_sblim() passes, that enumerate HostSystem does not return an instance.
+ try: + hs = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt) + name = get_typed_class(options.virt, 'HostSystem')
- if len(hs) != 1: - logger.error("Expected 1 %s instance returned" % name) - return FAIL + if len(hs) != 1: + logger.error("Expected 1 %s instance returned" % name) + return FAIL
You'll want to return an XFAIL here. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2008-09-24 10:02:52:
+ + status, linux_cs = check_sblim(options.ip) + if status == PASS: + name = 'Linux_ComputerSystem' + system = linux_cs[0] + else:
You'll want to verify that if check_sblim() passes, that enumerate HostSystem does not return an instance.
Good catch. Add this verification in check_sblim() function.
+ try: + hs = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt) + name = get_typed_class(options.virt, 'HostSystem')
- if len(hs) != 1: - logger.error("Expected 1 %s instance returned" % name) - return FAIL + if len(hs) != 1: + logger.error("Expected 1 %s instance returned" %
name)
+ return FAIL
You'll want to return an XFAIL here.
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

This patch set focus on fix HostSystem - 01.enum to work with sblim base provider installed and without. Once it's applied, I will start to work on enumerate(), also a lot of tests have to be updated. Then I will cook up follow patches to make the other tests pass for sblim base provider installed. Thanks! Best, Regards Daisy (运国莲) VSM Team, China Systems & Technology Labs (CSTL) E-mail: yunguol@cn.ibm.com TEL: (86)-21-60922403 Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203 libvirt-cim-bounces@redhat.com wrote on 2008-09-23 15:00:58:
Follow up patch will fix the behavior of the enumerate() function, then update this patch sets
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (3)
-
Guo Lian Yun
-
Kaitlin Rupert
-
yunguol@cn.ibm.com