2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-21 11:12:04 +00:00

fix issue 5633, enhance check tftp service (#5639)

* fix issue 5633, enhance check tftp service
This commit is contained in:
xuweibj 2018-09-26 10:30:41 +08:00 committed by Bin Xu
parent 827bdf3497
commit 4bfa23e1bb
2 changed files with 20 additions and 9 deletions

View File

@ -369,20 +369,22 @@ sub is_tftp_ready {
my $mnip = shift;
$mnip = shift if (($mnip) && ($mnip =~ /probe_utils/));
my $tftpdir = shift;
my $test_dir = $tftpdir . "/tftptest/";
system("mkdir -p $test_dir");
rename("/$tftpdir/tftptestt.tmp", "/$tftpdir/tftptestt.tmp.old") if (-e "/$tftpdir/tftptestt.tmp");
rename("/$test_dir/tftptestt.tmp", "/$test_dir/tftptestt.tmp.old") if (-e "/$test_dir/tftptestt.tmp");
rename("./tftptestt.tmp", "./tftptestt.tmp.old") if (-e "./tftptestt.tmp");
system("touch /$tftpdir/tftptestt.tmp");
my $output = `tftp -4 -v $mnip -c get tftptestt.tmp`;
system("touch /$test_dir/tftptestt.tmp");
my $output = `tftp -4 -v $mnip -c get /tftptest/tftptestt.tmp 2>&1`;
if ((!$?) && (-e "./tftptestt.tmp")) {
unlink("./tftptestt.tmp");
rename("./tftptestt.tmp.old", "./tftptestt.tmp") if (-e "./tftptestt.tmp.old");
rename("/$tftpdir/tftptestt.tmp.old", "/$tftpdir/tftptestt.tmp") if (-e "/$tftpdir/tftptestt.tmp.old");
rename("/$test_dir/tftptestt.tmp.old", "/$test_dir/tftptestt.tmp") if (-e "/$test_dir/tftptestt.tmp.old");
return 1;
} else {
rename("./tftptestt.tmp.old", "./tftptestt.tmp") if (-e "./tftptestt.tmp.old");
rename("/$tftpdir/tftptestt.tmp.old", "/$tftpdir/tftptestt.tmp") if (-e "/$tftpdir/tftptestt.tmp.old");
rename("/$test_dir/tftptestt.tmp.old", "/$test_dir/tftptestt.tmp") if (-e "/$test_dir/tftptestt.tmp.old");
return 0;
}
}

View File

@ -102,8 +102,9 @@ sub do_main_job {
$rc |= $rst;
#check tftp service
$rst = check_tftp_service($installnicip, \$checkpoint, \@error);
print_check_result($checkpoint, "f", $rst, \@error);
($rst, $flag) = check_tftp_service($installnicip, \$checkpoint, \@error);
print_check_result($checkpoint, $flag, $rst, \@error);
$rst = 0 if ($flag == "w");
$rc |= $rst;
#check DNS service
@ -696,6 +697,7 @@ sub check_tftp_service {
my $checkpoint_ref = shift;
my $error_ref = shift;
my $rst = 1;
my $flag = 'f';
$$checkpoint_ref = "Checking TFTP service is configured...";
@$error_ref = ();
@ -726,10 +728,17 @@ sub check_tftp_service {
push @$error_ref, "There isn't '$tftpdir' directory on current server";
last;
}
my $tftp_ps = `ps aux 2>&1| grep tftp | grep xcat |grep -v grep`;
if (!$tftp_ps) {
push @$error_ref, "TFTP service based on xCAT is not running";
$flag = 'w';
}
unless(probe_utils->is_tftp_ready("$serverip", $tftpdir)) {
push @$error_ref, "TFTP service isn't ready on $serverip";
push @$error_ref, "TFTP service isn't ready on $serverip, stop tftp service and start it by restarting xcatd";
$flag = 'f';
last;
}
last if ($flag eq 'w');
$rst = 0;
}
}
@ -737,7 +746,7 @@ sub check_tftp_service {
$rst = 2;
}
return $rst;
return ($rst, $flag);
}
sub check_rsyslog_service {