From 62a0cb63509c0ee28272b1ae2aa396173e17a444 Mon Sep 17 00:00:00 2001 From: sjing Date: Thu, 26 Dec 2013 22:52:41 -0500 Subject: [PATCH] Support dns master/slave configuration --- xCAT-server/lib/xcat/plugins/ddns.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 145bf511c..aa0424bd5 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -561,7 +561,7 @@ sub process_request { $ctx->{dnsupdaters} = \@nservers; } unless ($external) { - 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"); @@ -1002,8 +1002,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}}) { @@ -1011,6 +1014,7 @@ sub update_namedconf { } push @newnamed,"\t};\n"; } + if ($slave) { push @newnamed,"\tallow-transfer { any; };\n"; } else { @@ -1042,8 +1046,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; } @@ -1053,7 +1057,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"; } @@ -1063,12 +1067,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}}) {