X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=web%2Fmake-switches.pl;h=9283546e2e0cf7023706f752305582c7af6de9e8;hb=1e7869f8141084245dcd34fb065f38a418517e7b;hp=2829ed7fb28daf60f57c821d7ebdb61e3f192f95;hpb=b11cda49056ea814b9754f9d20de8cdcad76a053;p=nms diff --git a/web/make-switches.pl b/web/make-switches.pl index 2829ed7..9283546 100644 --- a/web/make-switches.pl +++ b/web/make-switches.pl @@ -11,9 +11,6 @@ print "SELECT pg_catalog.setval('polls_poll_seq', 1, false);\n"; open PATCHLIST, "patchlist.txt" or die "patchlist.txt: $!"; -my $cc = 241; -my $dd = 0; - my $i = 1; while () { chomp; @@ -22,7 +19,7 @@ while () { $name =~ /e(\d+)-(\d+)/; my ($e, $s) = ($1, $2); - my $x = int(202 + $e * 8.25); + my $x = int(244 + $e * 9.87); my $y; $x += 7 if ($e >= 19); @@ -35,35 +32,42 @@ while () { $c = $e; $d = ($s - 1) * 64; - $y = 470 - $s * 48; + $y = 455 - $s * 48; } else { $c = $e + 1; $d = ($s - 4) * 64; - $y = 400 - $s * 48 - ($s - 3) * 2; + $y = 424 - $s * 48 - ($s - 3) * 2; } my $xx = $x + 12; my $yy = $y + (($s > 3) ? 50 : 48); - $dk = $dd + 7 + ($cc - 241) * 42; - -# lasses magic-factor =) - $dk += 4; - if ($dk > 13) { - $dk += 3; - } + 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"; + } - print "insert into switches (ip, sysname, switchtype) values ('87.76.$cc.$dk', 'e$e-${s}sw', 'es3024');\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++; - - $dd++; - if ($dd == 42) { - $cc++; - $dd = 0; - } } print "end;\n";