2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 09:13:08 +00:00

add cleanup function

This commit is contained in:
XuWei 2016-08-11 23:33:32 -04:00
parent c6684895eb
commit f7aa0cc2fa

View File

@ -725,6 +725,9 @@ sub do_main_job {
#-------------------------------------
sub summary_all_jobs_output {
if ($terminal) {
return 0;
}
print "\n======================do summary=====================\n";
my @summary;
@ -787,6 +790,24 @@ sub summary_all_jobs_output {
}
#-------------------------------------
# Clean up test environment
# -------------------------------------
sub cleanup {
my $tmptest = `lsdef xcatmntest 2>&1`;
if ($tmptest =~ /Error: Could not find an object named 'xcatmntest' of type 'node'./) {
if (-e "/etc/hosts.bak.probe") {
`rm /etc/hosts > /dev/null 2>&1`;
`mv /etc/hosts.bak.probe /etc/hosts > /dev/null 2>&1`;
`makedns -n 2>&1`;
}
} else {
`makedhcp -d xcatmntest && rmdef xcatmntest`;
`rm /etc/hosts`;
`mv /etc/hosts.bak.probe /etc/hosts`;
}
}
#-------------------------------------
# Each probe sub command is supposed to support hierarchical.
# This funtion is used to caclulate which SN should be dispatched which command
@ -894,6 +915,7 @@ if ($test) {
$SIG{TERM} = $SIG{INT} = sub {
$terminal = 1;
cleanup();
};
#--------------------------------------------