# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1219986526 25200
# Node ID a10801bed98fb176effa2ccc9eb3fe3765a1ea14
# Parent a9978826a31d881a7fcaa2ca277a44322511a624
[TEST] Use enumclass.py to cover computersystem.py behavior and update CS tests
More update patches related to this change to follow, and at last remove
computersystem.py
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r a9978826a31d -r a10801bed98f suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py Wed Aug 27 01:04:31 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py Thu Aug 28 22:08:46 2008 -0700
@@ -24,7 +24,7 @@
import sys
from CimTest.Globals import do_main
-from XenKvmLib import computersystem
+from XenKvmLib import enumclass
from VirtLib import live
from VirtLib import utils
from CimTest import Globals
@@ -36,9 +36,10 @@
def main():
options = main.options
status = PASS
-
+
+ keys = ['Name', 'CreationClassName']
try:
- cs = computersystem.enumerate(options.ip, options.virt)
+ cs = enumclass.enumerate(options.ip, 'ComputerSystem', keys,
options.virt)
live_cs = live.domain_list(options.ip, options.virt)
for system in cs:
name = system.name
diff -r a9978826a31d -r a10801bed98f
suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Wed Aug 27 01:04:31 2008
-0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Thu Aug 28 22:08:46 2008
-0700
@@ -24,7 +24,7 @@
import sys
import pywbem
-from XenKvmLib import computersystem
+from XenKvmLib import enumclass
from VirtLib import live
from VirtLib import utils
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
@@ -49,9 +49,9 @@
return SKIP
cn = "%s_ComputerSystem" % options.virt
-
+ keys = ['Name', 'CreationClassName']
try:
- cs = computersystem.enumerate(options.ip, options.virt)
+ cs = enumclass.enumerate(options.ip, 'ComputerSystem', keys,
options.virt)
except Exception, details:
logger.error(CIM_ERROR_ENUMERATE, cn)
diff -r a9978826a31d -r a10801bed98f
suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py Wed Aug 27 01:04:31 2008
-0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py Thu Aug 28 22:08:46 2008
-0700
@@ -27,7 +27,7 @@
# 26-Sep-2007
import sys
-from XenKvmLib import computersystem
+from XenKvmLib import enumclass
from XenKvmLib import vxml
from XenKvmLib.classes import get_typed_class
from VirtLib import utils
@@ -49,8 +49,9 @@
Globals.logger.error(Globals.VIRSH_ERROR_DEFINE % test_dom)
return status
+ keys = ['Name', 'CreationClassName']
try:
- cs = computersystem.enumerate(options.ip, options.virt)
+ cs = enumclass.enumerate(options.ip, 'ComputerSystem', keys,
options.virt)
if len(cs) == 0:
raise Exception('No cs instance returned')
for dom in cs:
diff -r a9978826a31d -r a10801bed98f
suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py Wed Aug 27 01:04:31
2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py Thu Aug 28 22:08:46
2008 -0700
@@ -32,7 +32,7 @@
import sys
from time import sleep
from XenKvmLib import vxml
-from XenKvmLib import computersystem
+from XenKvmLib import enumclass
from CimTest import Globals
from XenKvmLib.classes import get_typed_class
from CimTest.Globals import do_main
@@ -62,7 +62,7 @@
# otherwise.
for i in range(1, (timeout + 1)):
sleep(1)
- cs = computersystem.get_cs_class(options.virt)(options.ip,
+ cs = enumclass.get_cs_class(options.virt)(options.ip,
test_dom)
if cs.Name != test_dom:
Globals.logger.error("VS %s is not defined" % test_dom)
diff -r a9978826a31d -r a10801bed98f
suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py Wed Aug 27
01:04:31 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py Thu Aug 28
22:08:46 2008 -0700
@@ -42,7 +42,7 @@
# Date : 17-10-2007
import sys
-from XenKvmLib import computersystem
+from XenKvmLib import enumclass
from XenKvmLib import vxml
from VirtLib import utils
from CimTest.Globals import logger
@@ -73,7 +73,7 @@
logger.error("ERROR: VS %s was not defined" % test_dom)
return status
- cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom)
+ cs = enumclass.get_cs_class(options.virt)(options.ip, test_dom)
if cs.Name == test_dom:
from_State = cs.EnabledState
else:
@@ -95,7 +95,7 @@
#Get the value of the EnabledState property and RequestedState property.
try:
- cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom)
+ cs = enumclass.get_cs_class(options.virt)(options.ip, test_dom)
if cs.Name == test_dom:
to_RequestedState = cs.RequestedState
enabledState = cs.EnabledState
diff -r a9978826a31d -r a10801bed98f
suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Wed Aug 27
01:04:31 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Thu Aug 28
22:08:46 2008 -0700
@@ -41,7 +41,6 @@
# Date :18-10-2007
import sys
-from XenKvmLib import computersystem
from XenKvmLib import vxml
from VirtLib import utils
from XenKvmLib.test_doms import destroy_and_undefine_all
diff -r a9978826a31d -r a10801bed98f
suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py Wed Aug 27 01:04:31
2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py Thu Aug 28 22:08:46
2008 -0700
@@ -29,7 +29,6 @@
# Date: 14-12-2007
import sys
-from XenKvmLib import computersystem
from VirtLib import utils
from XenKvmLib import vxml
from XenKvmLib.test_doms import destroy_and_undefine_domain
diff -r a9978826a31d -r a10801bed98f
suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Wed Aug 27
01:04:31 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Thu Aug 28
22:08:46 2008 -0700
@@ -58,7 +58,6 @@
import sys
from VirtLib import utils
-from XenKvmLib import computersystem
from XenKvmLib.vxml import get_class
from XenKvmLib.classes import get_typed_class
from XenKvmLib.test_doms import destroy_and_undefine_all
diff -r a9978826a31d -r a10801bed98f suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Wed Aug 27 01:04:31 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Thu Aug 28 22:08:46 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):
@@ -357,3 +382,12 @@
return None
return inst
+
+def get_cs_class(virt):
+ if virt in virt_types:
+ return eval(get_typed_class(virt, 'ComputerSystem'))
+
+def system_of(server, iname):
+ t = eval(iname["CreationClassName"])
+
+ return t(server, iname["Name"])