#!/usr/bin/perl
+use v5.12;
+
use strict;
use warnings;
my $name = $cluster->{name};
output_server($zonefile, "${name}.${zone}", $cluster);
+
+ if (@{$cluster->{servers}} > 1)
+ {
+ output_server($zonefile, "${name}-%02d.${zone}", $cluster);
+ }
}
# Output the GeoJSON text
{
my $gdnsmapfile = IO::File->new("> gdns/${gdnsname}.map") || die "$!";
my $gdnsresourcefile = IO::File->new("> gdns/${gdnsname}.resource") || die "$!";
+ my $gdnsweightedfile = IO::File->new("> gdns/${gdnsname}.weighted") || die "$!";
my $continent = "";
$gdnsmapfile->print("${gdnsname} => {\n");
{
my $name = $cluster->{name};
- $gdnsresourcefile->print(" ${name} => ${name}.tile.openstreetmap.org.\n");
+ $gdnsresourcefile->print(" ${name} => ${name}.${zone}.\n");
+
+ if (@{$cluster->{servers}} > 1)
+ {
+ $gdnsweightedfile->print("${name} => {\n");
+
+ while (my($index,$server) = each @{$cluster->{servers}})
+ {
+ my $number = sprintf("%02d", $index + 1);
+ my $bandwidth = $server->{bandwidth};
+
+ $gdnsweightedfile->print(" ${name}-${number} = [ ${name}-${number}.${zone}., ${bandwidth} ]\n");
+ }
+
+ $gdnsweightedfile->print("}\n");
+ }
}
$gdnsresourcefile->print(" }\n");
$gdnsresourcefile->print("}\n");
+ $gdnsweightedfile->close();
$gdnsresourcefile->close();
$gdnsmapfile->close();
}
my $name = shift;
my $cluster = shift;
- foreach my $server (@{$cluster->{servers}})
+ while (my($index,$server) = each @{$cluster->{servers}})
{
if ($server->{status} eq "up")
{
- $zonefile->print("+${name}:$server->{ipv4}:600\n");
+ $zonefile->printf("+${name}:$server->{ipv4}:600\n", $index + 1);
if ($server->{ipv6})
{
-# $zonefile->print("3${name}:$server->{ipv6}:600\n");
+# $zonefile->printf("3${name}:$server->{ipv6}:600\n", $index + 1);
}
}
}