# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1220420079 25200
# Node ID 9e48d953adc1414dd4d0b3e60813cbd4fd4a9669
# Parent 90ff66d2baee23319d29727d61fa9cf5d8f64f27
[TEST] #3 Use enumclass.py to cover computersystem.py behavior and update CS testes
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 90ff66d2baee -r 9e48d953adc1 suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py Fri Aug 29 13:26:12 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/01_enum.py Tue Sep 02 22:34:39 2008 -0700
@@ -24,7 +24,7 @@
import sys
from XenKvmLib.const import do_main
-from XenKvmLib import computersystem
+from XenKvmLib import enumclass
from VirtLib import live
from VirtLib import utils
from CimTest import Globals
@@ -37,8 +37,9 @@ 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 90ff66d2baee -r 9e48d953adc1
suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Fri Aug 29 13:26:12 2008
-0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Tue Sep 02 22:34:39 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
@@ -50,8 +50,9 @@ def main():
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 90ff66d2baee -r 9e48d953adc1
suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py Fri Aug 29 13:26:12 2008
-0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py Tue Sep 02 22:34:39 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 @@ def main():
Globals.logger.error(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 90ff66d2baee -r 9e48d953adc1
suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py Fri Aug 29 13:26:12
2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/04_defineStartVS.py Tue Sep 02 22:34:39
2008 -0700
@@ -32,8 +32,8 @@ import sys
import sys
from time import sleep
from XenKvmLib import vxml
-from XenKvmLib import computersystem
-from CimTest import Globals
+from XenKvmLib import enumclass
+from CimTest import Globals, CimExt
from XenKvmLib.classes import get_typed_class
from XenKvmLib.const import do_main
from CimTest.ReturnCodes import PASS, FAIL
@@ -62,8 +62,11 @@ def main():
# otherwise.
for i in range(1, (timeout + 1)):
sleep(1)
- cs = computersystem.get_cs_class(options.virt)(options.ip,
- test_dom)
+ keys = {
+ 'Name' : test_dom,
+ 'CreationClassName' : get_typed_class(options.virt,
'ComputerSystem')
+ }
+ cs = enumclass.getInstance(options.ip, 'ComputerSystem', keys,
options.virt)
if cs.Name != test_dom:
Globals.logger.error("VS %s is not defined" % test_dom)
break
diff -r 90ff66d2baee -r 9e48d953adc1
suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py Fri Aug 29
13:26:12 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py Tue Sep 02
22:34:39 2008 -0700
@@ -42,11 +42,12 @@
# 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
from XenKvmLib.const import do_main
+from XenKvmLib.classes import get_typed_class
from XenKvmLib.common_util import call_request_state_change
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
@@ -73,7 +74,12 @@ def main():
logger.error("ERROR: VS %s was not defined" % test_dom)
return status
- cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom)
+ keys = {
+ 'Name' : test_dom,
+ 'CreationClassName' : get_typed_class(options.virt,
'ComputerSystem')
+ }
+ cs = enumclass.getInstance(options.ip, 'ComputerSystem', keys,
options.virt)
+
if cs.Name == test_dom:
from_State = cs.EnabledState
else:
@@ -95,7 +101,7 @@ def main():
#Get the value of the EnabledState property and RequestedState property.
try:
- cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom)
+ cs= enumclass.getInstance(options.ip, 'ComputerSystem', keys,
options.virt)
if cs.Name == test_dom:
to_RequestedState = cs.RequestedState
enabledState = cs.EnabledState
diff -r 90ff66d2baee -r 9e48d953adc1
suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Fri Aug 29
13:26:12 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Tue Sep 02
22:34:39 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 90ff66d2baee -r 9e48d953adc1
suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py Fri Aug 29 13:26:12
2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/22_define_suspend.py Tue Sep 02 22:34:39
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 90ff66d2baee -r 9e48d953adc1
suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Fri Aug 29
13:26:12 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/41_cs_to_settingdefinestate.py Tue Sep 02
22:34:39 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 90ff66d2baee -r 9e48d953adc1 suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Aug 29 13:26:12 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Tue Sep 02 22:34:39 2008 -0700
@@ -27,7 +27,7 @@ from pywbem.cim_obj import CIMInstanceNa
from pywbem.cim_obj import CIMInstanceName
from XenKvmLib.devices import CIM_Instance
from XenKvmLib.classes import get_typed_class
-from CimTest import Globals
+from CimTest import Globals, CimExt
class CIM_MyClass(CIM_Instance):
def __init__(self, server, keys):
@@ -42,8 +42,30 @@ class CIM_MyClass(CIM_Instance):
inst = conn.GetInstance(ref)
except pywbem.CIMError, arg:
raise arg
+
+ self.conn = conn
+ self.inst = inst
+ self.ref = ref
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_ComputerSystem(CIM_MyClass):
+ pass
class CIM_System(CIM_MyClass):
pass
@@ -91,6 +113,15 @@ class CIM_ProcResourceAllocationSettingD
pass
class CIM_DiskResourceAllocationSettingData(CIM_MyClass):
+ pass
+
+class Xen_ComputerSystem(CIM_ComputerSystem):
+ pass
+
+class KVM_ComputerSystem(CIM_ComputerSystem):
+ pass
+
+class LXC_ComputerSystem(CIM_ComputerSystem):
pass
class Xen_HostSystem(CIM_System):