]> git.sesse.net Git - nms/blobdiff - web/make-switches.pl
Added Chillout.
[nms] / web / make-switches.pl
index a728ec23c9d5b5a9771c016785edd02d151c518d..9283546e2e0cf7023706f752305582c7af6de9e8 100644 (file)
@@ -1,5 +1,6 @@
 #! /usr/bin/perl
 
+print "begin;\n";
 print "delete from temppoll;\n";
 print "delete from placements;\n";
 print "delete from dhcp;\n";
@@ -7,79 +8,66 @@ print "delete from switches;\n";
 print "SELECT pg_catalog.setval('switches_switch_seq', 1, false);\n";
 print "SELECT pg_catalog.setval('polls_poll_seq', 1, false);\n";
 
-my $cc = 241;
-my $dd = 0;
+open PATCHLIST, "patchlist.txt"
+       or die "patchlist.txt: $!";
 
 my $i = 1;
-for $e (1..73) {
-       next if ($e % 2 == 0);
+while (<PATCHLIST>) {
+       chomp;
+       my ($name, $distro, $port) = split / /;
 
-       for $s (1..6) {
-               next if ($s <  4 && $e < 5);
-               next if ($s >= 4 && $e > 72);
+       $name =~ /e(\d+)-(\d+)/;
+       my ($e, $s) = ($1, $2);
 
-               next if ($e >= 69 && ($s == 1 || $s == 6));
-       
-               my $x = int(285 + $e * 9.45);
-               my $y;
+       my $x = int(244 + $e * 9.87);
+       my $y;
 
-               $x += 7 if ($e >= 19);
-               $x += 14 if ($e >= 35);
-               $x += 9 if ($e >= 51);
-               $x += 9 if ($e >= 68 && $s < 4);
-               
-               my ($c, $d);
-               if ($s <= 3) {
-                       $c = $e;
-                       $d = ($s - 1) * 64;
+       $x += 7 if ($e >= 19);
+       $x += 14 if ($e >= 35);
+       $x += 9 if ($e >= 51);
+       $x += 9 if ($e >= 68 && $s < 4);
 
-                       $y = 470 - $s * 48;
-               } else {
-                       $c = $e + 1;
-                       $d = ($s - 4) * 64;
-                       
-                       $y = 450 - $s * 48 - ($s - 3) * 2;
-               }
+       my ($c, $d);
+       if ($s <= 3) {
+               $c = $e;
+               $d = ($s - 1) * 64;
 
-               my $xx = $x + 12;
-               my $yy = $y + (($s > 3) ? 50 : 48);
-       
-               $dk = $dd + 7 + ($cc - 241) * 42;
+               $y = 455 - $s * 48;
+       } else {
+               $c = $e + 1;
+               $d = ($s - 4) * 64;
 
-               # lasses magic-factor =)
-               $dk += 4;
-               if ($dk > 13) {
-                       $dk += 3;
-               }       
+               $y = 424 - $s * 48 - ($s - 3) * 2;
+       }
 
-               print "insert into switches (ip, sysname, switchtype) values ('81.162.$cc.$dk', 'e$e-${s}sw', 'es3024');\n";
-               print "insert into placements (switch, placement) values ($i, box '(($x,$y),($xx,$yy))');\n";
-               print "insert into dhcp (switch, network) values ($i, '81.162.$c.$d/26');\n";
-               $i++;
+       my $xx = $x + 12;
+       my $yy = $y + (($s > 3) ? 50 : 48);
 
-               $dd++;
-               if ($dd == 42) {
-                       $cc++;
-                       $dd = 0;
-               }
+       my ($ip, $range);
+       if ($s == 1) {
+               $ip = "87.76." . ($e) . ".2";
+               $range = "87.76." . ($e) . ".0";
+       } elsif ($s == 2) {
+               $ip = "87.76." . ($e) . ".66";
+               $range = "87.76." . ($e) . ".64";
+       } elsif ($s == 3) {
+               $ip = "87.76." . ($e) . ".130";
+               $range = "87.76." . ($e) . ".128";
+       } elsif ($s == 4) {
+               $ip = "87.76." . ($e + 1) . ".2";
+               $range = "87.76." . ($e + 1) . ".0";
+       } elsif ($s == 5) {
+               $ip = "87.76." . ($e + 1) . ".66";
+               $range = "87.76." . ($e + 1) . ".64";
+       } elsif ($s == 6) {
+               $ip = "87.76." . ($e + 1) . ".130";
+               $range = "87.76." . ($e + 1) . ".128";
        }
-}
 
-my @k = qw(
-           81.162.212.0/24|81.162.212.1|game|es3024|((1100,200),(1125,225))
-           81.162.250.0/24|81.162.250.1|noc|es3024|((630,520),(680,550))
-           81.162.252.0/24|81.162.252.1|presse|es3024|((560,520),(610,550))
-           81.162.203.0/24|81.162.203.1|info-desk|es3024|((270,350),(305,385))
-           81.162.213.0/24|81.162.213.1|logistics|es3024|((800,75),(900,100))
-           81.162.213.0/24|81.162.213.1|logistics|es3024|((800,75),(900,100))
-           81.162.200.0/24|81.162.200.1|vision|es3024|((170,240),(200,270))
-           81.162.202.0/24|81.162.202.1|vision-sponsor|es3024|((220,150),(250,180))
-         );
-          
-for my $x (@k) {
-       my ($net,$mip,$sysname,$switchtype,$box) = split /\|/, $x;
-       print "insert into switches (ip, sysname, switchtype) values ('$mip', '$sysname', '$switchtype');\n";
-       print "insert into placements (switch, placement) values ($i, box '$box');\n";
-       print "insert into dhcp (switch, network) values ($i, '$net');\n";
+       print "insert into switches (ip, sysname, switchtype) values ('$ip', 'e$e-${s}sw', 'es3024');\n";
+       print "insert into placements (switch, placement) values ($i, box '(($x,$y),($xx,$yy))');\n";
+       print "insert into dhcp (switch, network) values ($i, '87.76.$c.$d/26');\n";
        $i++;
 }
+
+print "end;\n";