diff options
Diffstat (limited to 'include/nms/util.pm')
-rw-r--r-- | include/nms/util.pm | 74 |
1 files changed, 70 insertions, 4 deletions
diff --git a/include/nms/util.pm b/include/nms/util.pm index d2382f9..f79df50 100644 --- a/include/nms/util.pm +++ b/include/nms/util.pm @@ -10,7 +10,6 @@ our @EXPORT = qw(guess_placement parse_switches_txt parse_switches parse_switch) # Parse a single switches.txt-formatted switch sub parse_switch { my ($switch, $subnet4, $subnet6, $mgtmt4, $mgtmt6, $lolid, $distro) = split(/ /); - my %foo = guess_placement($switch); my %ret = ( 'sysname' => "$switch", 'subnet4' => "$subnet4", @@ -50,10 +49,77 @@ sub parse_switches { return @switches; } -# Guesses placement from name to get a starting point -# -# FIXME: Move to configuration +# FIXME: Derive which function from the config/db using the shortname. +# If we care. sub guess_placement { + return guess_placement_dx($_[0]); +} +# Guesses placement from name to get a starting point +# Digitality X layout +# FIXME: Basically a stub, since MRGLASS is too slow with the map. +sub guess_placement_dx { + my ($x, $y, $xx, $yy); + + my $name = $_[0]; + my $src = "unknown"; + if ($name =~ /^row\d+-\d+$/) { + $name =~ /row(\d+)-(\d+)/; + my ($e, $s) = ($1, $2); + $src = "main"; + + $x = int(1523 - (($e-1)/2) * 61); + $y = undef; + + if ($s > 1) { + $y = 137; + } else { + $y = 410; + } + + $xx = $x + 32; + $yy = $y + 200; + + } elsif ($name =~ /^core$/) { + $src = "core"; + $x = 1100; + $y = 650; + $xx = $x + 200; + $yy = $y + 100; + } elsif ($name =~ /^noc$/) { + $src = "noc"; + $x = 300; + $y = 800; + $xx = $x + 230; + $yy = $y + 40; + } elsif ($name =~ /^distro(\d)$/) { + my $d = ($1); + $src = "distro"; + $x = 1200 - $d * 700; + $y = 355; + $xx = $x + 230; + $yy = $y + 40; + } else { + # Fallback to have _some_ position + $src = "random"; + $x = int(rand(1900)); + $y = int(rand(900)); + $xx = $x + 230; + $yy = $y + 40; + }; + + + my %box = ( + 'src' => "$src", + 'x1' => $x, + 'y1' => $y, + 'xx' => $xx, + 'yy' => $yy + ); + return %box; +} + +# Last updated for TG16 +sub guess_placement_tg { my ($x, $y, $xx, $yy); my $name = $_[0]; |