From 53345329d3216884ae1cab67a751ce6eeb7d928c Mon Sep 17 00:00:00 2001 From: lissav Date: Sun, 7 Aug 2011 11:24:49 +0000 Subject: [PATCH] add warning if nameserver site.master not found in /etc/resolv.conf git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10238 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/ddns.pm | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 09c0e12b6..03cd0b133 100644 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -223,7 +223,7 @@ sub process_request { } $ctx->{deletemode}=$deletemode; - + # check for site.domain my $sitetab = xCAT::Table->new('site'); my $stab = $sitetab->getAttribs({key=>'domain'},['value']); unless ($stab and $stab->{value}) { @@ -231,7 +231,34 @@ sub process_request { return; } $ctx->{domain} = $stab->{value}; - + # get site.master + # check to see if /etc/resolv.conf has nameserver=site.master, if no + # put out a warning + my $master = $sitetab->getAttribs({key=>'master'},['value']); + unless ($master and $master->{value}) { + xCAT::SvrUtils::sendmsg([1,"master not defined in site table"], $callback); + return; + } + my $resolv="/etc/resolv.conf"; + my $found=0; + my $nameserver=$master->{value}; + my $cmd="grep $nameserver $resolv"; + my @output=xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + $found=0; + } else { # if it is there check it is a nameserver + foreach my $line (@output) { + if ($line =~ /^nameserver/) { # line is a nameserver line + $found=1; + last; + } + } + } + if ($found == 0) { # not nameserver master found + xCAT::SvrUtils::sendmsg([0,"Warning:The management node is not defined as a nameserver in /etc/resolv.conf. Add \"nameserver $nameserver\" to /etc/resolv.conf and run makedns again."], $callback); + } + my $networkstab = xCAT::Table->new('networks',-create=>0); unless ($networkstab) { xCAT::SvrUtils::sendmsg([1,'Unable to enumerate networks, try to run makenetworks'], $callback); } my @networks = $networkstab->getAllAttribs('net','mask','ddnsdomain');