diff options
author | root <root@riffraff.tg14.gathering.org> | 2014-04-20 02:58:05 +0200 |
---|---|---|
committer | root <root@riffraff.tg14.gathering.org> | 2014-04-20 02:58:05 +0200 |
commit | 8f4ae8e5833f0d26be5fad5160ae6ee0479b0712 (patch) | |
tree | da5089e91fbe52fd7da57a1c431c9af64f6ac8af /clients/flatify.pl | |
parent | 37a3b5d6ed97367989aecc875f1db1e9eb0458df (diff) | |
parent | 19cd0064816a577b72577b9f21a5a946eb746f64 (diff) |
Merge branch 'master' of https://github.com/tech-server/tgmanage
Diffstat (limited to 'clients/flatify.pl')
-rwxr-xr-x | clients/flatify.pl | 21 |
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. +} |