# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1224666506 25200
# Node ID fc949371313630bd0d5abd47e5f15048e85c9ca8
# Parent 868aa0f5175568c5752787c1fcbd2b1df4001aad
[TEST] #2 Remove old enumerate* and getInstance in devices.py and enumclass.py
Due to these patch will hit most of tc, I will cut it into several patches:
1) Remove old enumerate* and getInstance
2) Remove CIM_Instance in devices.py and update related tc
3) Remove CIM_* class definitions and update related tc
Signed-off-by: Guolian Yun <yunguol(a)cn.ibm.com>
diff -r 868aa0f51755 -r fc9493713136 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Oct 21 01:31:11 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Oct 22 02:08:26 2008 -0700
@@ -38,7 +38,6 @@
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
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 XenKvmLib.const import default_pool_name, default_network_name
@@ -52,12 +51,13 @@
def get_cs_instance(domain_name, ip, virt='Xen'):
cs = None
+ cs_class = get_typed_class(virt, 'ComputerSystem')
try:
keys = {
'Name' : domain_name,
- 'CreationClassName' : get_typed_class(virt,
'ComputerSystem')
+ 'CreationClassName' : cs_class
}
- cs = enumclass.getInstance(ip, 'ComputerSystem', keys, virt)
+ cs = enumclass.GetInstance(ip, cs_class, keys)
if cs.Name != domain_name:
logger.error("VS %s is not found" % domain_name)
@@ -172,16 +172,15 @@
def poll_for_state_change(server, virt, dom, exp_state, timeout=30):
dom_cs = None
-
+ cs_class = get_typed_class(virt, 'ComputerSystem')
keys = {
'Name' : dom,
- 'CreationClassName' : get_typed_class(virt,
'ComputerSystem')
+ 'CreationClassName' : cs_class
}
try:
for i in range(1, (timeout + 1)):
- dom_cs = enumclass.getInstance(server, 'ComputerSystem', keys,
- virt)
+ dom_cs = enumclass.GetInstance(server, cs_class, keys)
if dom_cs is None or dom_cs.Name != dom:
continue
diff -r 868aa0f51755 -r fc9493713136 suites/libvirt-cim/lib/XenKvmLib/devices.py
--- a/suites/libvirt-cim/lib/XenKvmLib/devices.py Tue Oct 21 01:31:11 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/devices.py Wed Oct 22 02:08:26 2008 -0700
@@ -101,36 +101,6 @@
def get_class(classname):
return eval(classname)
-def enumerate(server, basetype, keys, virt='Xen'):
- conn = pywbem.WBEMConnection('http://%s' % server,
- (Globals.CIM_USER, Globals.CIM_PASS),
- Globals.CIM_NS)
-
- list = []
-
- #FIXME - Remove once all tests are converted for KVM
- basetype = basetype.split('_', 1)[-1]
-
- devtype = eval(get_typed_class(virt, basetype))
- try:
- names = conn.EnumerateInstanceNames(devtype.__name__)
- except pywbem.CIMError, arg:
- raise Exception("%s" % arg[1])
- return list
-
- for name in names:
- key_list = {}
- for item in keys:
- key_list[item] = name.keybindings[item]
-
- if len(key_list) == 0:
- return list
-
- list.append(devtype(server, key_list))
-
- return list
-
-
def device_of(server, key_list):
t = eval(key_list["CreationClassName"])
diff -r 868aa0f51755 -r fc9493713136 suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Tue Oct 21 01:31:11 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Wed Oct 22 02:08:26 2008 -0700
@@ -357,75 +357,6 @@
pass
-# Generic function which can be used to get the enumerate instances of any
-# class when the following fields are specified
-# classname = any class for which we want obtain the instances
-# ex: Xen_RegisteredProfile
-# keyname = The keyvalue
-# ex: InstanceID in case of Xen_RegisteredProfile
-def enumerate_inst(server, classname, virt="Xen"):
- classname = "%s" % classname
- new_classname = classname.split('_')
- if len(new_classname) == 2:
- classname = new_classname[1]
- classname = eval(get_typed_class(virt, classname))
- instances = []
- conn = pywbem.WBEMConnection('http://%s' % server,
- (Globals.CIM_USER, Globals.CIM_PASS),
- Globals.CIM_NS)
-
- try:
- instances = conn.EnumerateInstances(classname.__name__)
- except pywbem.CIMError, arg:
- print arg[1]
- return []
-
- return instances
-
-def enumerate(server, basename, keys, virt="Xen"):
- #FIXME - Remove once all tests are converted for KVM
- basename = "%s" % basename
- new_base = basename.split('_')
- if len(new_base) == 2:
- basename = new_base[1]
-
- classname = eval(get_typed_class(virt, basename))
- instances = enumerate_inst(server, classname, virt)
-
- list = []
-
- for instance in instances:
- key_list = {}
- for item in keys:
- key_list[item] = instance[item]
-
- if len(key_list) == 0:
- return list
-
- list.append(classname(server, key_list))
-
- return list
-
-def getInstance(server, basename, keys, virt="Xen"):
- conn = pywbem.WBEMConnection('http://%s' % server,
- (Globals.CIM_USER, Globals.CIM_PASS),
- Globals.CIM_NS)
-
- #FIXME - Remove once all tests are converted for KVM
- basename = "%s" % basename
- new_base = basename.split('_')
- if len(new_base) == 2:
- basename = new_base[1]
-
- classname = eval(get_typed_class(virt, basename))
- try:
- inst = classname(server, keys)
-
- except pywbem.CIMError, arg:
- print arg[1]
- return None
-
- return inst
class CIM_CimtestClass(CIM_Instance):
def __init__(self, host, ref):