mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-11-04 13:22:36 +00:00 
			
		
		
		
	Enhance usability of makedns with more checks and better messages.
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user