aboutsummaryrefslogtreecommitdiffstats
path: root/clients/flatify.pl
diff options
context:
space:
mode:
authorroot <root@riffraff.tg14.gathering.org>2014-04-20 02:58:05 +0200
committerroot <root@riffraff.tg14.gathering.org>2014-04-20 02:58:05 +0200
commit8f4ae8e5833f0d26be5fad5160ae6ee0479b0712 (patch)
treeda5089e91fbe52fd7da57a1c431c9af64f6ac8af /clients/flatify.pl
parent37a3b5d6ed97367989aecc875f1db1e9eb0458df (diff)
parent19cd0064816a577b72577b9f21a5a946eb746f64 (diff)
Merge branch 'master' of https://github.com/tech-server/tgmanage
Diffstat (limited to 'clients/flatify.pl')
-rwxr-xr-xclients/flatify.pl21
1 files changed, 21 insertions, 0 deletions
diff --git a/clients/flatify.pl b/clients/flatify.pl
new file mode 100755
index 0000000..f2aa18a
--- /dev/null
+++ b/clients/flatify.pl
@@ -0,0 +1,21 @@
+#! /usr/bin/perl
+
+# Make the given switch into a D-Link placement-wise.
+
+use strict;
+use warnings;
+use lib '../include';
+use nms;
+
+my $dbh = nms::db_connect();
+my $q = $dbh->prepare('SELECT switch,placement FROM switches NATURAL JOIN placements WHERE sysname LIKE ?');
+$q->execute('%'.$ARGV[0].'%');
+
+while (my $ref = $q->fetchrow_hashref) {
+ $ref->{'placement'} =~ /\((\d+),(\d+)\),\((\d+),(\d+)\)/ or die;
+ my ($x1,$y1,$x2,$y2) = ($1, $2, $3, $4);
+ my $placement = sprintf "(%d,%d),(%d,%d)", $x2 - 100, $y2 - 16, $x2, $y2;
+ $dbh->do("UPDATE placements SET placement=? WHERE switch=?",
+ undef, $placement, $ref->{'switch'});
+ last; # Take only one.
+}