+
+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
I think this is a special case and that we don't need a separate
function for this. There will only be a few cases where this is used, I
think.
Or maybe it's possible to modify call_request_state_change(0 to handle
errors?
def poll_for_state_change(server, virt, dom, exp_state, timeout=30):
+ dom_cs = None
cs = computersystem.get_cs_class(virt)
try:
@@ -146,22 +174,22 @@
dom_cs = cs(server, name=dom)
if dom_cs is None or dom_cs.Name != dom:
logger.error("CS instance not returned for %s." % dom)
- return FAIL
+ return FAIL, dom_cs
if dom_cs.EnabledState == exp_state:
break
except Exception, detail:
logger.error("Exception: %s" % detail)
- return FAIL
+ return FAIL, dom_cs
if dom_cs.EnabledState != exp_state:
logger.error("EnabledState is %i instead of %i." %
(dom_cs.EnabledState,
exp_state))
logger.error("Try to increase the timeout and run the test again")
- return FAIL
+ return FAIL, dom_cs
- return PASS
+ return PASS, dom_cs
This is a good set of changes - thanks!
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com