From fc7d8ecee528a04cb7d0efb0d514105f93d4db8a Mon Sep 17 00:00:00 2001 From: sjing Date: Thu, 26 Dec 2013 22:57:24 -0500 Subject: [PATCH] Support dns master/slave configuration --- xCAT-server/lib/xcat/plugins/ddns.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 9249d2ed5..84b73b652 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -559,7 +559,7 @@ sub process_request { my @nservers = split /[ ,]/,$site_entry; $ctx->{dnsupdaters} = \@nservers; } - if ($zapfiles) { #here, we unlink all the existing files to start fresh + if ($zapfiles || $slave) { #here, we unlink all the existing files to start fresh if (xCAT::Utils->isAIX()) { system("/usr/bin/stopsrc -s $service"); @@ -998,8 +998,11 @@ sub update_namedconf { } } unless ($gotoptions) { - push @newnamed,"options {\n","\tdirectory \"".$ctx->{zonesdir}."\";\n"; - push @newnamed,"\t\t//listen-on-v6 { any; };\n"; + push @newnamed,"options {\n"; + unless ($slave) { + push @newnamed,"\tdirectory \"".$ctx->{zonesdir}."\";\n"; + } + push @newnamed,"\t\t//listen-on-v6 { any; };\n"; if ($ctx->{forwarders}) { push @newnamed,"\tforwarders {\n"; foreach (@{$ctx->{forwarders}}) { @@ -1038,8 +1041,8 @@ sub update_namedconf { } } - my $cmd = "grep '^nameserver' /etc/resolv.conf | awk '{print $2}'"; - my @output=xCAT::Utils->runcmd($cmd, 0); + my $cmd = "grep '^nameserver' /etc/resolv.conf | awk '{print \$2}'"; + my @output = xCAT::Utils->runcmd($cmd, 0); my $zone; foreach $zone (keys %{$ctx->{zonestotouch}}) { if ($didzones{$zone}) { next; } @@ -1049,7 +1052,7 @@ sub update_namedconf { push @newnamed,"\ttype slave;\n"; push @newnamed,"\tmasters { $output[0]; };\n"; } else { - push @newnamed,"\ttype master;\n","\tallow-update {\n","\t\tkey xcat_key;\n"; + push @newnamed,"\ttype master;\n","\tallow-update {\n","\t\tkey xcat_key;\n","\t};\n"; foreach (@{$ctx->{dnsupdaters}}) { push @newnamed,"\t\t$_;\n"; } @@ -1059,12 +1062,12 @@ sub update_namedconf { $net =~ s/.IN-ADDR\.ARPA.*//; my @octets = split/\./,$net; $net = join('.',reverse(@octets)); - push @newnamed,"\t};\n","\tfile \"db.$net\";\n","};\n"; + push @newnamed,"\tfile \"db.$net\";\n","};\n"; } else { my $zfilename = $zone; #$zfilename =~ s/\..*//; - push @newnamed,"\t};\n","\tfile \"db.$zfilename\";\n","};\n"; + push @newnamed,"\tfile \"db.$zfilename\";\n","};\n"; } } foreach $zone (keys %{$ctx->{adzones}}) {