# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1220235476 25200
# Node ID 57b15d9bb761cb09f48dc86a793f3d2f79e59e19
# Parent 946fd46b96866adaab356876f9c8bbf937f0b3d6
[TEST] #2 Use enumclass.py to cover computersystem.py behavior and update commom_util.py
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 946fd46b9686 -r 57b15d9bb761 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Thu Aug 28 14:07:25 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Sun Aug 31 19:17:56 2008 -0700
@@ -28,7 +28,6 @@
from XenKvmLib.test_xml import *
from XenKvmLib.test_doms import *
from XenKvmLib import vsms
-from XenKvmLib import computersystem
from XenKvmLib import enumclass
from pywbem.cim_obj import CIMInstanceName
from XenKvmLib.devices import CIM_Instance
@@ -54,7 +53,7 @@
def get_cs_instance(domain_name, ip, virt='Xen'):
cs = None
try:
- cs = computersystem.get_cs_class(virt)(ip, domain_name)
+ cs = get_typed_class(virt, 'ComputerSystem')(ip, domain_name)
if cs.Name != domain_name:
logger.error("VS %s is not found" % domain_name)
@@ -169,7 +168,7 @@
def poll_for_state_change(server, virt, dom, exp_state, timeout=30):
dom_cs = None
- cs = computersystem.get_cs_class(virt)
+ cs = get_typed_class(virt, 'ComputerSystem')
try:
for i in range(1, (timeout + 1)):
diff -r 946fd46b9686 -r 57b15d9bb761 suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Thu Aug 28 14:07:25 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Sun Aug 31 19:17:56 2008 -0700
@@ -26,7 +26,7 @@
import pywbem
from pywbem.cim_obj import CIMInstanceName
from XenKvmLib.devices import CIM_Instance
-from XenKvmLib.classes import get_typed_class
+from XenKvmLib.classes import get_typed_class, virt_types
from CimTest import Globals
class CIM_MyClass(CIM_Instance):
@@ -45,7 +45,32 @@
CIM_Instance.__init__(self, inst)
+ def __invoke(self, method, params):
+ try:
+ return self.conn.InvokeMethod(method,
+ self.ref,
+ **params)
+ except pywbem.CIMError, arg:
+ print 'InvokeMethod(%s): %s' % (method, arg[1])
+ raise
+
+ def __getattr__(self, attr):
+ if self.inst.has_key(attr):
+ return self.inst[attr]
+ else:
+ return CimExt._Method(self.__invoke, attr)
+
+
class CIM_System(CIM_MyClass):
+ pass
+
+class Xen_ComputerSystem(CIM_System):
+ pass
+
+class KVM_ComputerSystem(CIM_System):
+ pass
+
+class LXC_ComputerSystem(CIM_System):
pass
class CIM_AllocationCapabilities(CIM_MyClass):