本文整理汇总了Python中SSH_utils类的典型用法代码示例。如果您正苦于以下问题:Python SSH_utils类的具体用法?Python SSH_utils怎么用?Python SSH_utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SSH_utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_for_expired_proxies
def check_for_expired_proxies(utils,ssh,wms_location_var):
proxies=SSH_utils.execute_remote_cmd(utils,ssh,"find %s/proxycache/ -name \*.pem"%(wms_location_var)).split("\n")
for proxy in proxies:
if proxy.strip()!='':
expiry_date=SSH_utils.execute_remote_cmd(utils,ssh,"openssl x509 -in %s -noout -enddate"%(proxy.strip())).split("=")[1].strip("\n")
ddate_str=time.strptime(expiry_date,"%b %d %H:%M:%S %Y %Z")[0:8]
dt = datetime.datetime(ddate_str[0],ddate_str[1],ddate_str[2],ddate_str[3],ddate_str[4],ddate_str[5],ddate_str[6])
now_dt = datetime.datetime.utcnow()
diff=now_dt-dt
minutes, seconds = divmod(diff.seconds, 60)
hours, minutes = divmod(minutes, 60)
if diff.days>=0:
#Maybe it is necessary to check and minutes
if hours>=6:
utils.log_info("ERROR: Find expired proxy for more than 6 hours. Proxy is %s"%(proxy))
raise GeneralError("Check for expired proxies for more than 6 hours","Find expired proxy for more than 6 hours. Proxy is %s"%(proxy))
示例2: set_limiter_values
def set_limiter_values(utils,ssh,limit_values):
try:
job_submit="\"${WMS_LOCATION_SBIN}/glite_wms_wmproxy_load_monitor --oper jobSubmit %s\""%(limit_values)
job_register="\"${WMS_LOCATION_SBIN}/glite_wms_wmproxy_load_monitor --oper jobRegister %s\""%(limit_values)
utils.log_info("Set jobSubmit = %s; and jobRegister = %s; to glite_wms.conf at WMS"%(job_submit,job_register))
SSH_utils.change_remote_file(utils,ssh,"/etc/glite-wms/glite_wms.conf", ['jobSubmit','jobRegister'],['*','*'], [job_submit,job_register])
except (RunCommandError,GeneralError,TimeOutError) , e :
utils.log_info('ERROR - Command: %s'%(e.expression))
utils.log_info('ERROR - Message: %s'%(e.message))
restore_configuration_file(utils,ssh)
示例3: test6
def test6(utils,title):
utils.show_progress(title)
utils.info(title)
fails=0
try:
if utils.OSB_DEST_HOSTNAME=='' or utils.OSB_DEST_USERNAME=='' or utils.OSB_DEST_PASSWORD=='' :
utils.warn("Please set the required variables for OSB node in test's configuration file")
utils.show_progress("Please set the required variables for OSB node in test's configuration file")
return 1
ssh=SSH_utils.open_ssh(utils.OSB_DEST_HOSTNAME,utils.OSB_DEST_USERNAME,utils.OSB_DEST_PASSWORD)
SSH_utils.execute_remote_cmd(ssh,"mkdir -p -m 0777 /tmp/%s/osbbase"%(utils.ID))
target_info,target_ces=utils.get_target_ces()
if len(target_info)==0:
target_info.append("Default Test - Submit to CREAM CE")
target_ces.append("/cream-")
for target in target_ces:
utils.show_progress("%s - %s"%(title,target_info[target_ces.index(target)]))
utils.info("%s - %s"%(title,target_info[target_ces.index(target)]))
utils.run_command_continue_on_error("rm -rf %s/*"%(utils.get_job_output_dir()))
if osbbasetdesturi_test(utils,target,ssh)==1:
fails=fails+1
SSH_utils.close_ssh(ssh)
except (RunCommandError,GeneralError,TimeOutError) , e :
utils.log_error("%s"%(utils.get_current_test()))
utils.log_error("Command: %s"%(e.expression))
utils.log_error("Message: %s"%(e.message))
utils.log_traceback("%s"%(utils.get_current_test()))
utils.log_traceback(traceback.format_exc())
fails=fails+1
示例4: check_for_empty_directories
def check_for_empty_directories(utils,ssh,wms_location_var):
dirs = SSH_utils.execute_remote_cmd(utils,ssh,"ls /%s/proxycache"%(wms_location_var)).split(" ")
for dir in dirs:
dir=dir.strip(" \n\t")
if dir.find("cache")==-1:
utils.log_info("Check directory: %s"%(dir))
subdirs=SSH_utils.execute_remote_cmd(utils,ssh,"find /%s/proxycache/%s -name userproxy.pem | wc -l"%(wms_location_var,dir))
total_subdirs=SSH_utils.execute_remote_cmd(utils,ssh,"ls -l /%s/proxycache/%s | grep glite | wc -l"%(wms_location_var,dir))
if total_subdirs == subdirs :
utils.log_info("Check OK, there are no empty directories in %s"%(dir))
else:
utils.log_info("ERROR: Test Failed. There are empty directories in %s"%(dir))
raise GeneralError("Check for emptry directories","Test Failed. There are empty directories in %s"%(dir))
示例5: main
def main():
utils = Test_utils.Test_utils(sys.argv[0],"Check glite_wms.conf file")
tests=["Test 1: Check common section"]
tests.append("Test 2: Check JobController section")
tests.append("Test 3: Check NetworkServer section")
tests.append("Test 4: Check LogMonitor section")
tests.append("Test 5: Check WorkloadManager section")
tests.append("Test 6: Check WorkloadManagerProxy section")
tests.append("Test 7: Check ICE section")
tests.append("Test 8: Check if attributes match values of yaim variables")
utils.prepare(sys.argv[1:],tests)
if utils.WMS_USERNAME=='' or utils.WMS_PASSWORD=='':
utils.warn("Please set the required variables WMS_USERNAME , WMS_PASSWORD in test's configuration file")
utils.show_progress("Please set the required variables WMS_USERNAME , WMS_PASSWORD in test's configuration file")
sys.exit(0)
signal.signal(signal.SIGINT,utils.exit_interrupt)
fails=[]
all_tests=utils.is_all_enabled()
utils.info("Get glite_wms.conf file")
try:
logging.info("Get glite_wms.conf file from remote host %s"%(utils.get_WMS()))
ssh=SSH_utils.open_ssh(utils.get_WMS(),utils.WMS_USERNAME,utils.WMS_PASSWORD)
target='/etc/glite-wms/glite_wms.conf'
SSH_utils.ssh_get_file(ssh,target,"%s/glite_wms.conf_local"%(utils.get_tmp_dir()))
SSH_utils.close_ssh(ssh)
except (GeneralError) , e:
utils.log_error("Unable to get the glite_wms.conf from remote host: %s"%(utils.get_WMS()))
utils.log_error(e)
utils.exit_failure("Unable to get the glite_wms.conf from remote host: %s %s %s"%(utils.get_WMS(),utils.WMS_USERNAME,utils.WMS_PASSWORD))
示例6: test7_target
def test7_target(utils,ssh,wms_location_var):
proxies=SSH_utils.execute_remote_cmd(utils,ssh,"find %s/SandboxDir/ -name user.proxy"%(wms_location_var)).split("\n")
has_expired=0
for proxy in proxies:
if proxy.strip()!='':
expiry_date=SSH_utils.execute_remote_cmd(utils,ssh,"openssl x509 -in %s -noout -enddate"%(proxy.strip())).split("=")[1].strip("\n")
ddate_str=time.strptime(expiry_date,"%b %d %H:%M:%S %Y %Z")[0:8]
dt = datetime.datetime(ddate_str[0],ddate_str[1],ddate_str[2],ddate_str[3],ddate_str[4],ddate_str[5],ddate_str[6])
now_dt = datetime.datetime.utcnow()
diff=now_dt-dt
minutes, seconds = divmod(diff.seconds, 60)
hours, minutes = divmod(minutes, 60)
if diff.days>=0:
if minutes>0 or hours>0:
target_proxy=proxy
has_expired=1
break
if has_expired==0:
utils.log_info("Skip test: Unable to find any expired proxy in %s/SandboxDir"%(wms_location_var))
raise GeneralError("","Skip test: Unable to find any expired proxy in %s/SandboxDir"%(wms_location_var))
target_dir=target_proxy.split("/https")[0]
return target_dir
示例7: check_nodes_info
def check_nodes_info(utils,ssh,nodes_prefix,nodes_dir):
x=0
for ndprefix in nodes_prefix:
output=SSH_utils.execute_remote_cmd_failed(utils,ssh,"ls -l /var/SandboxDir/%s/%s"%(ndprefix,nodes_dir[x]))
if output.find("No such file or directory")==-1:
utils.log_info("Command failed for some other reason. Expected reason 'No such file or directory'")
raise GeneralError("Execute command ls -l /var/SandboxDir/%s/%s"%(ndprefix,nodes_dir[x]),"Command failed for some other reason. Expected reasaon 'No such file or directory'")
x=x+1
示例8: get_nodes_dir
def get_nodes_dir(utils,ssh,jobid):
output=utils.run_command("glite-wms-job-status -c %s %s"%(utils.get_config_file(),jobid)).split("\n")
nodes_dir=[]
for line in output :
if line.find("https://")!=-1 and line.find(jobid)==-1:
id=line.split("Status info for the Job : ")[1]
ndprefix=id.split(":9000/")[1][0:2]
nodes_dir.append(SSH_utils.execute_remote_cmd(utils,ssh,"ls /var/SandboxDir/%s"%(ndprefix)))
return nodes_dir
示例9: main
def main():
fails=[]
tests=["Test 1: Test option --load1 threshold for load average (1 min)"]
tests.append("Test 2: Test option --load5 threshold for load average (5 min)")
tests.append("Test 3: Test option --load15 threshold for load average (15 min)")
tests.append("Test 4: Test option --memusage threshold for memory usage (%)")
tests.append("Test 5: Test option --swapusage threshold for swap usage (%)")
tests.append("Test 6: Test option --ftpconn threshold for number of FTP connections")
tests.append("Test 7: Test option --diskusage threshold for disk usage (%)")
tests.append("Test 8: Test option --fdnum threshold for used file descriptor")
tests.append("Test 9: Test option --jdnum threshold for number of unprocessed jobs (for jobdir)")
tests.append("Test 10: Test option --jdsize threshold for input jobdir size (KB)")
#tests.append("Test 11: Test option --flnum threshold for number of unprocessed jobs (for filelist)")
#tests.append("Test 12: Test option --flsize threshold for input filelist size (KB)")
utils = Test_utils.Test_utils(sys.argv[0],"WMS Limiter Mechanism")
utils.prepare(sys.argv[1:],tests)
signal.signal(signal.SIGINT,utils.exit_interrupt)
if utils.WMS_USERNAME=='' or utils.WMS_PASSWORD=='':
utils.warn("Please set the required variables WMS_USERNAME , WMS_PASSWORD in test's configuration file")
utils.show_progress("Please set the required variables WMS_USERNAME , WMS_PASSWORD in test's configuration file")
sys.exit(0)
utils.info("WMS Limiter Mechanism Testing")
all_tests=utils.is_all_enabled()
try:
ssh=SSH_utils.open_ssh(utils.get_WMS(),utils.WMS_USERNAME,utils.WMS_PASSWORD)
except (GeneralError) , e:
utils.log_error("Unable to connect to remote host: %s"%(utils.get_WMS()))
utils.log_error(e)
utils.exit_failure("Unable to connect to remote host: %s"%(utils.get_WMS()))
示例10: main
def main():
fails = []
tests = ["Test 1: Test purge , normal job cycle ( Submit to LCG CE )"]
tests.append("Test 2: Test purge, normal job cycle ( Submit to CREAM CE )")
tests.append("Test 3: Test proxy cache purging")
tests.append("Test 4: SandBoxDir cron purger ( Submit a job and force its purge before it finishes )")
tests.append("Test 5: SandBoxDir cron purger ( Purge a DONE job )")
tests.append("Test 6: SandBoxDir cron purger ( Purge only jobs older than 12 hours )")
tests.append("Test 7: SandBoxDir cron purger ( Purge a job which proxy is already expired )")
tests.append("Test 8: SandBoxDir cron purger ( Purge a DAG job )")
utils = Test_utils.Test_utils(sys.argv[0], "WMS Purge Mechanism")
utils.prepare(sys.argv[1:], tests)
signal.signal(signal.SIGINT, utils.exit_interrupt)
if utils.WMS_USERNAME == "" or utils.WMS_PASSWORD == "":
utils.warn("Please set the required variables WMS_USERNAME , WMS_PASSWORD in test's configuration file")
utils.show_progress(
"Please set the required variables WMS_USERNAME , WMS_PASSWORD in test's configuration file"
)
sys.exit(0)
utils.info("WMS Purge Mechanism Testing")
all_tests = utils.is_all_enabled()
try:
ssh = SSH_utils.open_ssh(utils.get_WMS(), utils.WMS_USERNAME, utils.WMS_PASSWORD)
except (GeneralError), e:
utils.log_error("Unable to connect to remote host: %s" % (utils.get_WMS()))
utils.log_error(e)
utils.exit_failure("Unable to connect to remote host %s" % (utils.get_WMS()))
示例11: test5
def test5(utils, ssh, title):
utils.show_progress(title)
utils.info(title)
try:
Job_utils.prepare_normal_job(utils, utils.get_jdl_file())
utils.info("Submit a job to a CREAM CE")
JOBID = Job_utils.submit_only_normal_job(utils)[1]
prefix = JOBID.split("https://%s:9000/" % (utils.get_WMS()))[1][0:2]
utils.info("Wait until job finishes")
utils.wait_until_job_finishes(JOBID)
utils.job_status(JOBID)
if utils.get_job_status().find("Done") != -1:
utils.info("Purge a done job")
# WARNING EXECUTE COMMAND AS root INSTEAD OF glite USER
utils.info(
"Execute '/usr/sbin/glite-wms-purgeStorage.sh -p /var/SandboxDir/%s -s' on remote host" % (prefix)
)
output = SSH_utils.execute_remote_cmd(
ssh, "/usr/sbin/glite-wms-purgeStorage.sh -p /var/SandboxDir/%s -s" % (prefix)
)
utils.info("Check glite-wms-purgeStorage.sh output")
if output.find("%s: removed DONE job" % (JOBID)) != -1:
utils.info("glite-wms-purgeStorage.sh successfully remove the DONE job %s" % (JOBID))
else:
utils.error("glite-wms-purgeStorage.sh didn't remove successfully the DONE job %s" % (JOBID))
raise GeneralError(
"Check glite-wms-purgeStorage.sh",
"glite-wms-purgeStorage.sh didn't remove successfully the DONE job %s" % (JOBID),
)
utils.info("Check again job's status")
utils.job_status(JOBID)
if utils.get_job_status().find("Cleared") != -1:
utils.info("Job's final status after purge is Cleared")
utils.info("Check job's status reason")
status = utils.get_job_status_reason(JOBID)
if status.find("timed out, resource purge forced") != -1:
utils.info("Status reason is 'timed out, resource purge forced' as expected")
else:
utils.error(
"Status reason is %s while the expected is 'timed out, resource purge forced'" % (status)
)
raise GeneralError(
"Check job's status reason",
"Status reason is %s while the expected is 'timed out, resource purge forced'" % (status),
)
else:
utils.error(
"Job's final status after purge is not Cleared , instead we get %s" % (utils.get_job_status())
)
raise GeneralError(
"Check job final status after purge",
"Job's final status after purge is not Cleared , instead we get %s" % (utils.get_job_status()),
)
else:
utils.error("Job finishes with status: %s while expected 'Done'" % (utils.get_job_status()))
raise GeneralError(
"Check job final status",
"Job finishes with status: %s while expected 'Done'" % (utils.get_job_status()),
)
utils.info("TEST OK")
except (RunCommandError, GeneralError, TimeOutError), e:
utils.log_error("%s" % (utils.get_current_test()))
utils.log_error("Command: %s" % (e.expression))
utils.log_error("Message: %s" % (e.message))
utils.log_traceback("%s" % (utils.get_current_test()))
utils.log_traceback(traceback.format_exc())
return 1
示例12: test3
def test3(utils, ssh, title):
utils.show_progress(title)
utils.info(title)
try:
wms_location_var = SSH_utils.execute_remote_cmd(ssh, "echo $WMS_LOCATION_VAR")[:-1]
utils.info("Check inside $WMS_LOCATION_VAR/proxycache for expired proxies for more than 6 hours")
proxies = SSH_utils.execute_remote_cmd(ssh, "find %s/proxycache/ -name \*.pem" % (wms_location_var)).split("\n")
for proxy in proxies:
if proxy.strip() != "":
expiry_date = (
SSH_utils.execute_remote_cmd(ssh, "openssl x509 -in %s -noout -enddate" % (proxy.strip()))
.split("=")[1]
.strip("\n")
)
ddate_str = time.strptime(expiry_date, "%b %d %H:%M:%S %Y %Z")[0:8]
dt = datetime.datetime(
ddate_str[0], ddate_str[1], ddate_str[2], ddate_str[3], ddate_str[4], ddate_str[5], ddate_str[6]
)
now_dt = datetime.datetime.utcnow()
diff = now_dt - dt
minutes, seconds = divmod(diff.seconds, 60)
hours, minutes = divmod(minutes, 60)
if diff.days >= 0:
# Maybe it is necessary to check and minutes
if hours >= 6:
utils.error("Find expired proxy for more than 6 hours. Proxy is %s" % (proxy))
raise GeneralError(
"Check for expired proxies for more than 6 hours",
"Find expired proxy for more than 6 hours. Proxy is %s" % (proxy),
)
utils.info("Check if there are empty directories")
dirs = SSH_utils.execute_remote_cmd(ssh, "ls /%s/proxycache" % (wms_location_var)).split(" ")
for dir in dirs:
dir = dir.strip(" \n\t")
if dir.find("cache") == -1:
utils.info("Check directory: %s" % (dir))
subdirs = SSH_utils.execute_remote_cmd(
ssh, "find /var/proxycache/%s -name userproxy.pem | wc -l" % (dir)
)
total_subdirs = SSH_utils.execute_remote_cmd(
ssh, "ls -l /var/proxycache/%s | grep glite | wc -l" % (dir)
)
if total_subdirs == subdirs:
utils.info("Check OK, there are no empty directories in %s" % (dir))
else:
utils.error("Test Failed. There are empty directories in %s" % (dir))
raise GeneralError(
"Check for emptry directories", "Test Failed. There are empty directories in %s" % (dir)
)
utils.info("TEST OK")
except (RunCommandError, GeneralError, TimeOutError), e:
utils.log_error("%s" % (utils.get_current_test()))
utils.log_error("Command: %s" % (e.expression))
utils.log_error("Message: %s" % (e.message))
utils.log_traceback("%s" % (utils.get_current_test()))
utils.log_traceback(traceback.format_exc())
return 1
示例13: test4
def test4(utils, ssh, title):
utils.show_progress(title)
utils.info(title)
try:
utils.set_long_jdl(utils.get_jdl_file())
utils.info("Submit a job")
JOBID = utils.run_command_continue_on_error(
"glite-wms-job-submit %s --config %s --nomsg %s"
% (utils.get_delegation_options(), utils.get_config_file(), utils.get_jdl_file())
)
utils.info("Job submitted successfuly. Returned JOBID: %s" % (JOBID))
prefix = JOBID.split("https://%s:9000/" % (utils.get_WMS()))[1][0:2]
utils.job_status(JOBID)
while utils.get_job_status().find("Waiting") != -1:
utils.info("Wait 60 secs. Job's status is Waiting")
time.sleep(60)
utils.job_status(JOBID)
utils.info("Purge the job")
# WARNING EXECUTE COMMAND AS root INSTEAD OF glite USER
utils.info("Execute '/usr/sbin/glite-wms-purgeStorage.sh -p /var/SandboxDir/%s -s' on remote host" % (prefix))
output = SSH_utils.execute_remote_cmd(
ssh, "/usr/sbin/glite-wms-purgeStorage.sh -p /var/SandboxDir/%s -s" % (prefix)
)
utils.info("Check glite-wms-purgeStorage.sh output")
if output.find("%s: removed" % (JOBID)) != -1:
utils.info("glite-wms-purgeStorage.sh successfully remove the job %s" % (JOBID))
else:
utils.error("glite-wms-purgeStorage.sh didn't remove successfully the job %s" % (JOBID))
raise GeneralError(
"Check glite-wms-purgeStorage.sh",
"glite-wms-purgeStorage.sh didn't remove successfully the job %s" % (JOBID),
)
utils.info("Wait 60 secs")
time.sleep(60)
utils.info("Check again job's status")
utils.job_status(JOBID)
if utils.get_job_status().find("Cleared") != -1:
utils.info("Job's final status after purge is Cleared")
utils.info("Check job's status reason")
status = utils.get_job_status_reason(JOBID)
if status.find("timed out, resource purge forced") != -1:
utils.info("Status reason is 'timed out, resource purge forced' as expected")
else:
utils.error("Status reason is %s while the expected is 'timed out, resource purge forced'" % (status))
raise GeneralError(
"Check job's status reason",
"Status reason is %s while the expected is 'timed out, resource purge forced'" % (status),
)
else:
utils.error("Job's final status after purge is not Cleared , instead we get %s" % (utils.get_job_status()))
raise GeneralError(
"Check job final status after purge",
"Job's final status after purge is not Cleared , instead we get %s" % (utils.get_job_status()),
)
utils.info("TEST OK")
except (RunCommandError, GeneralError, TimeOutError), e:
utils.log_error("%s" % (utils.get_current_test()))
utils.log_error("Command: %s" % (e.expression))
utils.log_error("Message: %s" % (e.message))
utils.log_traceback("%s" % (utils.get_current_test()))
utils.log_traceback(traceback.format_exc())
return 1
示例14: test1
def test1(utils, ssh, title):
utils.show_progress(title)
utils.info(title)
try:
Job_utils.prepare_normal_job(utils, utils.get_jdl_file(), "2119/jobmanager")
utils.info("Submit a job to a LCG CE")
JOBID = Job_utils.submit_only_normal_job(utils, "2119/jobmanager")[1]
utils.info("Check the SBD and the others file used by the services")
prefix = JOBID.split("https://%s:9000/" % (utils.get_WMS()))[1][0:2]
dir2 = "/var/jobcontrol/condorio/%s" % (prefix)
utils.info("Check files at %s" % (dir2))
condorio = SSH_utils.execute_remote_cmd(ssh, "ls -l %s" % (dir2))
for line in condorio.split("\n"):
if line.find(JOBID.split("https://%s:9000/" % (utils.get_WMS()))[1]) != -1:
target = "https_%s" % (line.lstrip().split("https_")[1])
dir1 = "/var/SandboxDir/%s/%s" % (prefix, target)
utils.info("Check files at %s" % (dir1))
SSH_utils.execute_remote_cmd(ssh, "ls -l %s" % (dir1))
dir3 = "/var/jobcontrol/submit/%s/" % (prefix)
utils.info("Check files at %s" % (dir3))
SSH_utils.execute_remote_cmd(ssh, "ls -l %s" % (dir3))
utils.info("Wait until job finishes")
utils.wait_until_job_finishes(JOBID)
utils.job_status(JOBID)
if utils.get_job_status().find("Done") != -1:
utils.info("Check on WMS auxiliary files should be removed")
utils.info("Check directory %s" % (dir3))
output = SSH_utils.execute_remote_cmd(ssh, "ls -l %s" % (dir3))
if output.find(target) != 1:
utils.error("Auxiliary files are not removed from directory %s" % (dir3))
raise GeneralError(
"Check for auxiliary files at %s" % (dir3),
"Auxiliary files are not removed from directory %s" % (dir3),
)
else:
utils.info("Auxiliary files are removed as expected from directory %s" % (dir3))
utils.info("Check directory %s" % (dir2))
output = SSH_utils.execute_remote_cmd(ssh, "ls -l %s" % (dir2))
if output.find(target) != 1:
utils.error("Auxiliary files are not removed from directory %s" % (dir2))
raise GeneralError(
"Check for auxiliary files at %s" % (dir2),
"Auxiliary files are not removed from directory %s" % (dir2),
)
else:
utils.info("Auxiliary files are removed as expected from directory %s" % (dir2))
utils.info("Retrieve job output")
utils.run_command_continue_on_error(
"glite-wms-job-output --nosubdir --noint --dir %s %s" % (utils.get_job_output_dir(), JOBID)
)
utils.info("Check that also the SBD has been removed on WMS")
utils.info("Check directory /var/SandboxDir/%s/" % (prefix))
output = SSH_utils.execute_remote_cmd(ssh, "ls -l /var/SandboxDir/%s/" % (prefix))
if output.find(target) != 1:
utils.error("SBD not removed from directory /var/SandboxDir/%s/" % (prefix))
raise GeneralError(
"Check for SBD at /var/SandboxDir/%s/" % (prefix),
"Auxiliary files are not removed from directory %s" % (dir2),
)
else:
utils.info("SBD has been removed as expected from directory /var/SandboxDir/%s/" % (prefix))
else:
utils.error("Job finishes with status: %s cannot retrieve output" % (utils.get_job_status()))
raise GeneralError(
"Check job final status",
#.........这里部分代码省略.........
示例15: test8
def test8(utils, ssh, title):
utils.show_progress(title)
utils.info(title)
try:
utils.set_dag_jdl(utils.get_jdl_file())
utils.info("Submit a DAG job")
JOBID = utils.run_command_continue_on_error(
"glite-wms-job-submit %s --config %s --nomsg %s"
% (utils.get_delegation_options(), utils.get_config_file(), utils.get_jdl_file())
)
utils.info("Job submitted successfuly. Returned JOBID: %s" % (JOBID))
output = utils.run_command_continue_on_error(
"glite-wms-job-status -c %s %s" % (utils.get_config_file(), JOBID)
).split("\n")
nodes_prefix = []
nodes_dir = []
for line in output:
if line.find("https://") != -1 and line.find(JOBID) == -1:
id = line.split("Status info for the Job : ")[1]
ndprefix = id.split("https://%s:9000/" % (utils.get_WMS()))[1][0:2]
nodes_prefix.append(ndprefix)
nodes_dir.append(SSH_utils.execute_remote_cmd(ssh, "ls /var/SandboxDir/%s" % (ndprefix)))
prefix = JOBID.split("https://%s:9000/" % (utils.get_WMS()))[1][0:2]
utils.info("Purge a DAG job")
# WARNING EXECUTE COMMAND AS root INSTEAD OF glite USER
utils.info("Execute '/usr/sbin/glite-wms-purgeStorage.sh -p /var/SandboxDir/%s -s' on remote host" % (prefix))
output = SSH_utils.execute_remote_cmd(
ssh, "/usr/sbin/glite-wms-purgeStorage.sh -p /var/SandboxDir/%s -s" % (prefix)
)
utils.info("Check glite-wms-purgeStorage.sh output")
if output.find("%s: 3/3 nodes removed" % (JOBID)) != -1:
utils.info("glite-wms-purgeStorage.sh successfully remove all the nodes of job %s" % (JOBID))
else:
utils.error("glite-wms-purgeStorage.sh didn't remove successfully all the nodes of job %s" % (JOBID))
raise GeneralError(
"Check glite-wms-purgeStorage.sh",
"glite-wms-purgeStorage.sh didn't remove successfully all the nodes of job %s" % (JOBID),
)
if output.find("%s: removed" % (JOBID)) != -1:
utils.info("glite-wms-purgeStorage.sh successfully remove the job %s" % (JOBID))
else:
utils.error("glite-wms-purgeStorage.sh didn't remove successfully the job %s" % (JOBID))
raise GeneralError(
"Check glite-wms-purgeStorage.sh",
"glite-wms-purgeStorage.sh didn't remove successfully the job %s" % (JOBID),
)
utils.info("Check the SandBoxDir of nodes")
x = 0
for ndprefix in nodes_prefix:
output = SSH_utils.execute_remote_cmd_failed(ssh, "ls -l /var/SandboxDir/%s/%s1" % (ndprefix, nodes_dir[x]))
if output.find("No such file or directory") == -1:
utils.error("Command failed for some other reason. Expected reasaon 'No such file or directory'")
raise GeneralError(
"Execute command ls -l /var/SandboxDir/%s/%s" % (ndprefix, nodes_dir[x]),
"Command failed for some other reason. Expected reasaon 'No such file or directory'",
)
x = x + 1
utils.info("Check job's final status")
utils.job_status(JOBID)
if utils.get_job_status().find("Cleared") != -1:
utils.info("Job's final status after purge is Cleared")
else:
utils.error("Job's final status after purge is not Cleared , instead we get %s" % (utils.get_job_status()))
raise GeneralError(
"Check job final status after purge",
"Job's final status after purge is not Cleared , instead we get %s" % (utils.get_job_status()),
)
utils.info("TEST OK")
except (RunCommandError, GeneralError, TimeOutError), e:
utils.log_error("%s" % (utils.get_current_test()))
#.........这里部分代码省略.........