From 7c32c54593ca841c7b557a95cca247da6609c601 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Fri, 4 Mar 2016 19:29:23 +0000 Subject: nms: Further simplify and fix the API Now this works: tools/add_switches.txt.pl < switches.txt | POST http://demo:demo@localhost/private/switch-add --- web/nms.gathering.org/api/private/switch-add | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'web/nms.gathering.org/api/private/switch-add') diff --git a/web/nms.gathering.org/api/private/switch-add b/web/nms.gathering.org/api/private/switch-add index 1dc331f..2b1f306 100755 --- a/web/nms.gathering.org/api/private/switch-add +++ b/web/nms.gathering.org/api/private/switch-add @@ -20,7 +20,7 @@ my @added; my @dups; my $sth = $nms::web::dbh->prepare("SELECT sysname FROM switches WHERE sysname=?"); -my $insert = $nms::web::dbh->prepare("INSERT INTO SWITCHES (ip, sysname, switchtype) VALUES(?,?,'ex2200');"); +my $insert = $nms::web::dbh->prepare("INSERT INTO SWITCHES (ip, sysname, switchtype,placement) VALUES(?,?,'ex2200',?);"); foreach my $tmp2 (@tmp) { my %switch = %{$tmp2}; @@ -32,7 +32,14 @@ foreach my $tmp2 (@tmp) { } if ($affected == 0) { - $insert->execute($switch{'mgtmt4'}, $switch{'sysname'}); + my ($x1,$x2,$y1,$y2); + $x1 = $switch{'placement'}{'x1'}; + $y1 = $switch{'placement'}{'y1'}; + $x2 = $switch{'placement'}{'xx'}; + $y2 = $switch{'placement'}{'yy'}; + my $place = "(($x1,$y1),($x2,$y2))"; + $json{'foo'} = $place . "foo"; + $insert->execute($switch{'mgtmt4'}, $switch{'sysname'},$place); push @added, $switch{'sysname'}; } else { push @dups, $switch{'sysname'}; -- cgit v1.2.3