aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteinar H. Gunderson <sgunderson@bigfoot.com>2014-04-07 02:17:42 +0200
committerSteinar H. Gunderson <sgunderson@bigfoot.com>2014-04-07 02:17:42 +0200
commitb83b26425343dae0e587c759574e6193822ce7fa (patch)
treededf90243d4b96b6f1c0064def1009af8045916c
parent6734e3c36da77fe83cc512a047b84cd40986776c (diff)
Give newly discovered switch a location on the map.
-rwxr-xr-xclients/lldpdiscover.pl8
1 files changed, 8 insertions, 0 deletions
diff --git a/clients/lldpdiscover.pl b/clients/lldpdiscover.pl
index bfd4f84..3f24a63 100755
--- a/clients/lldpdiscover.pl
+++ b/clients/lldpdiscover.pl
@@ -199,6 +199,14 @@ sub add_switch {
$dbh->do('INSERT INTO portnames (switchtype, port, description) VALUES (?, ?, ?)',
undef, $switchtype, $port->{'ifIndex'}, $port->{'ifDescr'});
}
+
+ # Entirely random placement. Annoying? Fix it yourself.
+ my $x = int(rand 1200);
+ my $y = int(rand 650);
+ my $box = sprintf "((%d,%d),(%d,%d))", $x, $y, $x+40, $y+40;
+ $dbh->do("INSERT INTO placements (switch,placement) VALUES (CURRVAL('switches_switch_seq'), ?)",
+ undef, $box);
+
$dbh->commit;
}