my $source = shift @ARGV;
my $zone = shift @ARGV;
my $clusters = YAML::LoadFile("src/${source}");
-my $servers = {};
+my @servers;
# Initialise cluster details
while (my($name,$cluster) = each %$clusters)
{
$cluster->{bandwidth} = 0;
- while (my($name,$server) = each %{$cluster->{servers}})
+ foreach my $server (@{$cluster->{servers}})
{
$server->{cluster} = $cluster;
$cluster->{bandwidth} = $cluster->{bandwidth} + $server->{bandwidth};
- $servers->{$name} = $server;
+ push @servers, $server;
}
}
else
{
- $servers->{$name} = {
+ my $server = {
cluster => $cluster,
pingdom => $cluster->{pingdom},
- bandwidth => $cluster->{bandwidth}
+ bandwidth => $cluster->{bandwidth},
+ ipv4 => $cluster->{ipv4},
+ ipv6 => $cluster->{ipv6}
};
- $cluster->{servers} = {
- $name => $servers->{$name}
- };
+ $cluster->{servers} = [ $server ];
+
+ push @servers, $server;
}
$cluster->{name} = $name;
}
# Initialise server details
-while (my($name,$server) = each %$servers)
+foreach my $server (@servers)
{
- $server->{name} = $name;
-
if ($ENV{PINGDOM_USERNAME} && $ENV{PINGDOM_PASSWORD})
{
$server->{status} = "down";
$ua->default_header("App-Key", "2cohi62u5haxvqmypk3ljqqrze1jufrh");
$ua->credentials("api.pingdom.com:443", "Pingdom API", $ENV{PINGDOM_USERNAME}, $ENV{PINGDOM_PASSWORD});
- foreach my $server (values %$servers)
+ foreach my $server (@servers)
{
if (my $checkid = $server->{pingdom})
{
}
$zonefile->print("# $country->{name}\n");
-
- while (my($name,$server) = each %{$cluster->{servers}})
- {
- if ($server->{status} eq "up")
- {
- $zonefile->print("C\L$country->{code}\E.${zone}:$server->{name}.${zone}:600\n");
- }
- }
+ $zonefile->print("C\L$country->{code}\E.${zone}:$cluster->{name}.${zone}:600\n");
push @json, {
type => "Feature",
}
# Output default records for IPs that can't be mapped to a country
-foreach my $cluster (grep { $_->{default} } values %$clusters)
+foreach my $cluster (grep { $clusters->{$_}->{default} } keys %$clusters)
{
$zonefile->print("# Unknown countries\n");
+ $zonefile->print("Cxx.${zone}:${cluster}.${zone}:600\n");
+}
- while (my($name,$server) = each %{$cluster->{servers}})
+$zonefile->print("# Servers\n");
+
+# Output A records for each cluster
+while (my($name,$cluster) = each %$clusters)
+{
+ foreach my $server (@{$cluster->{servers}})
{
- $zonefile->print("Cxx.${zone}:${name}.${zone}:600\n");
+ if ($server->{status} eq "up")
+ {
+ $zonefile->print("+${name}.${zone}:$server->{ipv4}:600\n");
+
+ if ($server->{ipv6})
+ {
+# $zonefile->print("3${name}.${zone}:$server->{ipv6}:600\n");
+ }
+ }
}
}
+yevaud.ucl.openstreetmap:10.0.0.15
+yevaud.oob.openstreetmap:10.0.1.15
-# Map geographic zones to tile servers
-
-+sjobo.tile.openstreetmap:85.30.190.241:3600
-# 3sjobo.tile.openstreetmap:2a02008000003ff8022264fffe2a2714:3600
-+moscow.tile.openstreetmap:130.193.62.73:3600
-+brisbane.tile.openstreetmap:203.26.72.12:3600
-# 3brisbane.tile.openstreetmap:2402640000010006021708fffe5640c3:3600
-+pau.tile.openstreetmap:193.55.222.229:3600
-+amsterdam.tile.openstreetmap:134.90.146.26:3600
-+oslo.tile.openstreetmap:31.169.50.10:3600
-+sanfrancisco.tile.openstreetmap:64.62.205.202:3600
-+lyon.tile.openstreetmap:77.95.70.166:3600
-# 3lyon.openstreetmap:200107f80047002100000000000000a6:3600
-+beauharnois.tile.openstreetmap:142.4.213.166:3600
-# 3beauharnois.tile.openstreetmap:26075300006012a60000000000000001:3600
-+falkenstein.tile.openstreetmap:5.9.150.236:3600
-# 3falkenstein.openstreetmap:2a0104f8019033eb0000000000000002:3600
-+provo-01.tile.openstreetmap:192.163.219.36
-+provo-02.tile.openstreetmap:192.163.219.40
-
# Services machine
+horntail.openstreetmap:193.63.75.101