# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1217330632 25200
# Node ID f2f1c1899247df3a68d885a73bbfbb989a6e7941
# Parent 32d78f23f6e73f5443022179410128767896465d
1) Fixed get_cs_instance() debug statement.
2) Moved the common code which tried to match the error to a new fn verify_err_desc().
3) Added try_request_state_change() to verify the error conditions of
RequestStateChange().
4) Added check_reqstate_value() that verifies the RequestState value.
The changes are verified with KVM Xen, XenFV with current sources.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r 32d78f23f6e7 -r f2f1c1899247 suites/libvirt-cim/lib/XenKvmLib/common_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/common_util.py Wed Jul 23 00:32:36 2008 -0700
+++ b/suites/libvirt-cim/lib/XenKvmLib/common_util.py Tue Jul 29 04:23:52 2008 -0700
@@ -33,7 +33,8 @@
from pywbem.cim_obj import CIMInstanceName
from XenKvmLib.devices import CIM_Instance
from XenKvmLib.classes import get_typed_class
-from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE
+from CimTest.Globals import logger, log_param, CIM_ERROR_ENUMERATE, \
+CIM_ERROR_GETINSTANCE
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
from VirtLib.live import diskpool_list, virsh_version, net_list
from XenKvmLib.vxml import PoolXML, NetXML
@@ -57,7 +58,7 @@
return (1, cs)
except Exception, detail:
- logger.error(Globals.CIM_ERROR_GETINSTANCE,
+ logger.error(CIM_ERROR_GETINSTANCE,
get_typed_class(virt, 'ComputerSystem'))
logger.error("Exception: %s", detail)
return (1, cs)
@@ -122,10 +123,21 @@
return PASS
+def verify_err_desc(exp_rc, exp_desc, err_no, err_desc):
+ if err_no == exp_rc and err_desc.find(exp_desc) >= 0:
+ logger.info("Got expected exception where ")
+ logger.info("Errno is '%s' ", exp_rc)
+ logger.info("Error string is '%s'", exp_desc)
+ return PASS
+ else:
+ logger.error("Unexpected rc code %s and description %s\n",
+ (err_no, err_desc))
+ return FAIL
+
def call_request_state_change(domain_name, ip, rs, time, virt='Xen'):
rc, cs = get_cs_instance(domain_name, ip, virt)
if rc != 0:
- return 1
+ return FAIL
try:
cs.RequestStateChange(RequestedState=pywbem.cim_types.Uint16(rs),
@@ -133,9 +145,24 @@
except Exception, detail:
logger.error("Exception: %s" % detail)
- return 1
+ return FAIL
- return 0
+ return PASS
+
+def try_request_state_change(domain_name, ip, rs, time, exp_rc,
+ exp_desc, virt='Xen'):
+ rc, cs = get_cs_instance(domain_name, ip, virt)
+ if rc != 0:
+ return FAIL
+
+ try:
+ cs.RequestStateChange(RequestedState=pywbem.cim_types.Uint16(rs),
+ TimeoutPeriod=pywbem.cim_types.CIMDateTime(time))
+
+ except Exception, (err_no, err_desc) :
+ return verify_err_desc(exp_rc, exp_desc, err_no, err_desc)
+ logger.error("RequestStateChange failed to generate an exception")
+ return FAIL
def poll_for_state_change(server, virt, dom, exp_state, timeout=30):
cs = computersystem.get_cs_class(virt)
@@ -162,6 +189,20 @@
return FAIL
return PASS
+
+
+def check_reqstate_value(domain_name, server, rq_state, virt):
+ rc, cs = get_cs_instance(domain_name, server, virt)
+ if rc != 0:
+ return FAIL
+
+ if cs.RequestedState != rq_state:
+ logger.error("RequestedState should be %d not %d",
+ rq_state, cs.RequestedState)
+ return FAIL
+
+ return PASS
+
def get_host_info(server, virt="Xen"):
status = PASS
@@ -191,20 +232,12 @@
try:
assoc_info = conn.AssociatorNames(instanceref, \
AssocClass=assoc_classname)
- except pywbem.CIMError, (err_no, desc):
+ except pywbem.CIMError, (err_no, err_desc):
exp_rc = expr_values['rc']
exp_desc = expr_values['desc']
- if err_no == exp_rc and desc.find(exp_desc) >= 0:
- logger.info("Got expected exception where ")
- logger.info("Errno is '%s' ", exp_rc)
- logger.info("Error string is '%s'", exp_desc)
- return PASS
- else:
- logger.error("Unexpected rc code %s and description %s\n" \
- %(err_no, desc))
- return FAIL
- logger.error("'%s' association failed to generate an exception and \
-'%s' passed.", assoc_classname, field_name)
+ return verify_err_desc(exp_rc, exp_desc, err_no, err_desc)
+ logger.error("'%s' association failed to generate an exception and"
+ " '%s' passed.", assoc_classname, field_name)
return XFAIL_RC(bug_no)
def try_getinstance(conn, classname, keys, field_name, expr_values, bug_no):
@@ -213,20 +246,12 @@
instanceref = CIMInstanceName(classname, keybindings=keys)
logger.info ("Instanceref is '%s'", instanceref)
inst = conn.GetInstance(instanceref)
- except pywbem.CIMError, (err_no, desc):
+ except pywbem.CIMError, (err_no, err_desc):
exp_rc = expr_values['rc']
exp_desc = expr_values['desc']
- if err_no == exp_rc and desc.find(exp_desc) >= 0:
- logger.info("Got expected exception where ")
- logger.info("Errno is '%s' ", exp_rc)
- logger.info("Error string is '%s'", exp_desc)
- return PASS
- else:
- logger.error("Unexpected rc code %s and description %s\n" \
- %(err_no, desc))
- return FAIL
- logger.error("'%s' GetInstance failed to generate an exception and \
-'%s' passed.", classname, field_name)
+ return verify_err_desc(exp_rc, exp_desc, err_no, err_desc)
+ logger.error("'%s' GetInstance failed to generate an exception and"
+ " '%s' passed.", classname, field_name)
return XFAIL_RC(bug_no)
def profile_init_list():