From 8b8b932213d03a81e9b0df91a3e56777a65af254 Mon Sep 17 00:00:00 2001 From: sjing Date: Wed, 11 Sep 2013 05:24:57 -0400 Subject: [PATCH] Enhance usability of makedns with more checks and better messages. --- xCAT-server/lib/xcat/plugins/ddns.pm | 91 ++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 18 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 92620dfe8..78d655e3a 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -565,16 +565,55 @@ sub process_request { if ($ctx->{restartneeded}) { xCAT::SvrUtils::sendmsg("Restarting $service", $callback); - if (xCAT::Utils->isAIX()) - { - system("/usr/bin/stopsrc -s $service"); - system("/usr/bin/startsrc -s $service"); - } - else - { - system("service $service stop"); - system("service $service start"); - } + if (xCAT::Utils->isAIX()) + { + my $cmd = "/usr/bin/stopsrc -s $service"; + my @output=xCAT::Utils->runcmd($cmd, 0); + my $outp = join('', @output); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return; + } + + $cmd = "/usr/bin/startsrc -s $service"; + @output=xCAT::Utils->runcmd($cmd, 0); + $outp = join('', @output); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return; + } + } + else + { + my $cmd = "service $service stop"; + my @output=xCAT::Utils->runcmd($cmd, 0); + my $outp = join('', @output); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return; + } + + $cmd = "service $service start"; + @output=xCAT::Utils->runcmd($cmd, 0); + $outp = join('', @output); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return; + } + } + xCAT::SvrUtils::sendmsg("Restarting named complete", $callback); } } else { @@ -590,8 +629,16 @@ sub process_request { my @output=xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - system("/usr/bin/startsrc -s $service"); - xCAT::SvrUtils::sendmsg("Starting named complete", $callback); + $cmd = "/usr/bin/startsrc -s $service"; + @output=xCAT::Utils->runcmd($cmd, 0); + my $outp = join('', @output); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return; + } } } else @@ -600,11 +647,19 @@ sub process_request { my @output=xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - system("service $service start"); - xCAT::SvrUtils::sendmsg("Starting named complete", $callback); + $cmd = "service $service start"; + @output=xCAT::Utils->runcmd($cmd, 0); + my $outp = join('', @output); + if ($::RUNCMD_RC != 0) + { + my $rsp = {}; + $rsp->{data}->[0] = "Command failed: $cmd. Error message: $outp.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return; + } } - } - + } + #now we stick to Net::DNS style updates, with TSIG if possible. TODO: kerberized (i.e. Windows) DNS server support, maybe needing to use nsupdate -g.... if ($external) { @@ -1099,7 +1154,7 @@ sub add_or_delete_records { { if ($reply->header->rcode ne 'NOERROR') { - xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode], $callback); + xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode.". See more details in system log."], $callback); } } else @@ -1117,7 +1172,7 @@ sub add_or_delete_records { { if ($reply->header->rcode ne 'NOERROR') { - xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode], $callback); + xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode.". See more details in system log."], $callback); } } else