# HG changeset patch
# User Guolian Yun <yunguol(a)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(a)cn.ibm.com>
diff -r d2ae228a60c3 -r 83add054f191 suites/libvirt-cim/cimtest/HostSystem/01_enum.py
--- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Mon Sep 22 11:28:02 2008 -0700
+++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py Tue Sep 23 23:06:33 2008 -0700
@@ -27,12 +27,13 @@
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
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from XenKvmLib.const import do_main
-from CimTest.ReturnCodes import PASS, FAIL
+from CimTest.ReturnCodes import PASS, FAIL, XFAIL
SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC']
@@ -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, options.virt)
+ 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 XFAIL
- 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
diff -r d2ae228a60c3 -r 83add054f191 suites/libvirt-cim/lib/XenKvmLib/classes.py
--- a/suites/libvirt-cim/lib/XenKvmLib/classes.py Mon Sep 22 11:28:02 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/classes.py Tue Sep 23 23:06:33 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 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
diff -r d2ae228a60c3 -r 83add054f191 suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Mon Sep 22 11:28:02 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Tue Sep 23 23:06:33 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