From e8d2cbde2ca6c6fb1a2867342132c5d7b93a5bd9 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 14 Aug 2013 10:51:12 +0100 Subject: [PATCH] Output all target origins even if they have nothing assigned --- bin/mkgeo | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/bin/mkgeo b/bin/mkgeo index 8dbe80a..4dceb1d 100755 --- a/bin/mkgeo +++ b/bin/mkgeo @@ -105,11 +105,22 @@ if ($ENV{PINGDOM_USERNAME} && $ENV{PINGDOM_PASSWORD}) } } +# Create target origins object +my $targetorigins = {}; + # Initialise cluster details while (my($name,$cluster) = each %$clusters) { $cluster->{bandwidth_limit} = $cluster->{bandwidth} * 1024 * 1024; $cluster->{bandwidth_used} = 0; + + $targetorigins->{$cluster->{name}} = { + code => $cluster->{name}, + name => $cluster->{name}, + lat => $cluster->{lat}, + lon => $cluster->{lon}, + bandwidth => 0 + }; } my @mappings = (); @@ -162,9 +173,6 @@ while (grep { !exists($_->{cluster}) } values %$origins) # Create JSON collection object my @json; -# Create target origins object -my $targetorigins = {}; - # Open output files my $zonefile = IO::File->new("> data/${zone}") || die "$!"; my $jsonfile = IO::File->new("> json/${zone}.json") || die "$!"; @@ -203,17 +211,6 @@ foreach my $origin (values %$origins) } }; - unless (exists($targetorigins->{$cluster->{name}})) - { - $targetorigins->{$cluster->{name}} = { - code => $cluster->{name}, - name => $cluster->{name}, - lat => $cluster->{lat}, - lon => $cluster->{lon}, - bandwidth => 0 - }; - } - $targetorigins->{$cluster->{name}}->{bandwidth} += $origin->{bandwidth}; } -- 2.39.5