From 4bfa23e1bb80eabf4fd6b4cef1cf3b673940298f Mon Sep 17 00:00:00 2001 From: xuweibj Date: Wed, 26 Sep 2018 10:30:41 +0800 Subject: [PATCH] fix issue 5633, enhance check tftp service (#5639) * fix issue 5633, enhance check tftp service --- xCAT-probe/lib/perl/probe_utils.pm | 12 +++++++----- xCAT-probe/subcmds/xcatmn | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index 21121c605..e68c005e5 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -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; } } diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 1eb1f4462..1621ecd5b 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -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 {