# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1226705922 28800
# Node ID 948d7dc5b2acdb9f95af95e933eb1a9b07b6337f
# Parent 8d5eb7acc2dab6eda1fb15bf695bae4a090a5816
[TEST] Update ETCP tests to expect instance from get_host_info().
For EC 01, make sure namespace is set as interop only after EnumInstances() for the result
classes have been called. Cleanup XFAIL logic.
Also, handle __iter__, __repr__, and items functions in enumclass.py for Cimtest
instances. This allows for printing for Cimtest instances without encountering
an error. Also allows the caller to call inst.items() to get a list of
instance properties - the same that can be done with instances of type
CIMInstance.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 8d5eb7acc2da -r 948d7dc5b2ac
suites/libvirt-cim/cimtest/ElementConforms/01_forward.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/01_forward.py Fri Nov 14 15:30:52 2008
-0800
+++ b/suites/libvirt-cim/cimtest/ElementConforms/01_forward.py Fri Nov 14 15:38:42 2008
-0800
@@ -43,7 +43,7 @@
from XenKvmLib.classes import get_typed_class
from XenKvmLib import vxml
from CimTest import Globals
-from XenKvmLib.common_util import print_field_error, check_sblim, get_host_info
+from XenKvmLib.common_util import print_field_error, get_host_info
from CimTest.Globals import logger, CIM_ERROR_ENUMERATE
from XenKvmLib.const import do_main, get_provider_version
from CimTest.ReturnCodes import PASS, FAIL, XFAIL, XFAIL_RC
@@ -65,18 +65,12 @@
"ProcessorPool", "MemoryPool"]
cn_names.extend(cn_names2)
- status, host_name, host_ccn = get_host_info(server, virt)
+ status, host_inst = get_host_info(server, virt)
if status != PASS:
logger.error("Unable to get host system instance objects")
return FAIL, verify_ectp_list
- #FIXME - get_host_info() should be updated to return the host instance
- insts = EnumInstances(server, host_ccn, True)
- if len(insts) < 1:
- logger.error("Expected 1 %s instance", host_ccn)
- return FAIL, verify_ectp_list
-
- verify_ectp_list[host_ccn] = insts
+ verify_ectp_list[host_inst.CreationClassName] = [host_inst]
for cn_base in cn_names:
cn = get_typed_class(virt, cn_base)
@@ -165,19 +159,21 @@
return FAIL
prev_namespace = Globals.CIM_NS
- Globals.CIM_NS = 'root/interop'
+ verify_ectp_list = {}
try:
+ status, verify_ectp_list = init_vs_pool_values(server, virt)
+ if status != PASS:
+ raise Exception("Failed to get instances needed for verification")
+
+ Globals.CIM_NS = 'root/interop'
+
reg_classname = get_typed_class(virt, "RegisteredProfile")
an = get_typed_class(virt,"ElementConformsToProfile")
status, prof_inst_lst = get_proflist(server, reg_classname, virt)
if status != PASS:
raise Exception("Failed to get profile list")
-
- status, verify_ectp_list = init_vs_pool_values(server, virt)
- if status != PASS:
- raise Exception("Failed to get instances needed for verification")
for prof_id in prof_inst_lst:
logger.info("Verifying '%s' with '%s'", an,
prof_id)
@@ -187,14 +183,8 @@
InstanceID = prof_id)
if len(assoc_info) < 1:
- ret_val, linux_cs = check_sblim(server, virt)
- if ret_val != PASS:
- status = FAIL
- raise Exception(" '%s' returned (%d) '%s'
objects" % \
- (len(assoc_info), reg_classname))
- else:
- status = XFAIL_RC(bug_sblim)
- raise Exception("Known failure")
+ raise Exception(" '%s' returned (%d) '%s'
objects" % \
+ (an, len(assoc_info), reg_classname))
for inst in assoc_info:
status, verify_ectp_list = verify_fields(inst, verify_ectp_list)
@@ -214,6 +204,10 @@
Globals.CIM_NS = prev_namespace
cxml.destroy(server)
cxml.undefine(server)
+
+ if "Linux_ComputerSystem" in verify_ectp_list:
+ return XFAIL_RC(bug_sblim)
+
return status
if __name__ == "__main__":
diff -r 8d5eb7acc2da -r 948d7dc5b2ac
suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py
--- a/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Fri Nov 14 15:30:52 2008
-0800
+++ b/suites/libvirt-cim/cimtest/ElementConforms/02_reverse.py Fri Nov 14 15:38:42 2008
-0800
@@ -109,17 +109,19 @@
inst_list[cs.CreationClassName] = cs.Name
try:
- status, host_name, classname = get_host_info(server, virt)
+ status, host_inst = get_host_info(server, virt)
if status != PASS:
logger.error("Unable to get host information")
cxml.undefine(server)
return status
+
+
except Exception, details:
logger.error("DEBUG Exception: %s" % details)
cxml.undefine(server)
return FAIL
- inst_list[classname] = host_name
+ inst_list[host_inst.CreationClassName] = host_inst.Name
prev_namespace = Globals.CIM_NS
Globals.CIM_NS = 'root/interop'
diff -r 8d5eb7acc2da -r 948d7dc5b2ac suites/libvirt-cim/lib/XenKvmLib/enumclass.py
--- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Nov 14 15:30:52 2008 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py Fri Nov 14 15:38:42 2008 -0800
@@ -50,6 +50,14 @@
CIM_Instance.__init__(self, inst)
def __invoke(self, method, params):
+ if method == "__iter__" or method == "items":
+ return self.inst.items()
+ if method == "__repr__":
+ items = ""
+ for item in self.inst.items():
+ items += "('%s' %s)," % item
+ return items.rstrip(",")
+
try:
return self.conn.InvokeMethod(method,
self.ref,
@@ -63,6 +71,7 @@
return self.inst[attr]
else:
return CimExt._Method(self.__invoke, attr)
+
def EnumNames(host, cn):
'''Resolve the enumeration given the @cn.