Support dns master/slave configuration

This commit is contained in:
sjing 2013-12-26 22:52:41 -05:00
parent a2aee1a0bb
commit 62a0cb6350

View File

@ -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}}) {