+def verify_rpcs_err_val(virt, server, rpcs_conn, dp_cn, pool_name,
+ exp_vol_path, dp_inst):
+ for err_scen in invalid_scen.keys():
+ logger.info("Verifying errors for '%s'....", err_scen)
+ status = FAIL
+ del_res = [FAIL]
+ try:
I would put the try / execpt outside of the for loop. This will save
you some indentation.
+ res_settings = get_sto_vol_rasd(virt, server, dp_cn,
+ pool_name, exp_vol_path)
+ if res_settings == None:
+ raise Exception("Failed to get the resource settings for
'%s'" \
+ " Vol" % vol_name)
+ if not "MISSING" in err_scen:
+ exp_err_no = CIM_ERR_FAILED
+ if "NO_ADDRESS" in err_scen:
+ del res_settings['Address']
+ elif "INVALID_ADDRESS" in err_scen:
+ res_settings['Address'] =
invalid_scen[err_scen]['val']
+
+ resource = inst_to_mof(res_settings)
+ del_res = rpcs_conn.DeleteResourceInPool(Resource=resource,
+ Pool=dp_inst)
+ else:
+ exp_err_no = CIM_ERR_INVALID_PARAMETER
+ if err_scen == "MISSING_RESOURCE":
+ del_res = rpcs_conn.DeleteResourceInPool(Pool=dp_inst)
+ elif err_scen == "MISSING_POOL":
+ del_res = rpcs_conn.DeleteResourceInPool(Resource=resource)
Will invalid_scen.keys() already return the keys in the same order? I'm
wondering if it is possible for resource to be undefined here since it
only gets defined if "if not "MISSING" in err_scen:" has passed in a
prior iteration of the loop.
If "if not "MISSING" in err_scen:" fails the first time through the
loop, resource will be undefined.
+
+ except CIMError, (err_no, err_desc):
+ if invalid_scen[err_scen]['msg'] in err_desc \
+ and exp_err_no == err_no:
+ logger.error("Got the expected error message: '%s' for
'%s'",
+ err_desc, err_scen)
+ status=PASS
Spaces between the = here.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin(a)linux.vnet.ibm.com