diff options
-rwxr-xr-x | web/nms.gathering.org/api/private/switch-add | 11 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/private/switches-management | 8 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/public/switches | 2 |
3 files changed, 12 insertions, 9 deletions
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'}; diff --git a/web/nms.gathering.org/api/private/switches-management b/web/nms.gathering.org/api/private/switches-management index f007ad6..474f674 100755 --- a/web/nms.gathering.org/api/private/switches-management +++ b/web/nms.gathering.org/api/private/switches-management @@ -12,16 +12,12 @@ use Data::Dumper; $nms::web::cc{'max-age'} = "60"; -my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,ip,switchtype,poll_frequency,community,last_updated from switches natural join placements'); +my $q2 = $nms::web::dbh->prepare('select sysname,ip,switchtype,poll_frequency,community,last_updated from switches '); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { my $sysname = $ref->{'sysname'}; - $nms::web::json{'switches'}{$ref->{'sysname'}}{'switchtype'} = $ref->{'switchtype'}; - $nms::web::json{'switches'}{$ref->{'sysname'}}{'management'}{'ip'} = $ref->{'ip'}; - $nms::web::json{'switches'}{$ref->{'sysname'}}{'management'}{'poll_frequency'} = $ref->{'poll_frequency'}; - $nms::web::json{'switches'}{$ref->{'sysname'}}{'management'}{'community'} = $ref->{'community'}; - $nms::web::json{'switches'}{$ref->{'sysname'}}{'management'}{'last_updated'} = $ref->{'last_updated'}; + $nms::web::json{'switches'}{$ref->{'sysname'}} = $ref; } my $q4 = $nms::web::dbh->prepare('select linknet, (select sysname from switches where switch = switch1) as sysname1, addr1, (select sysname from switches where switch = switch2) as sysname2,addr2 from linknets'); diff --git a/web/nms.gathering.org/api/public/switches b/web/nms.gathering.org/api/public/switches index 8cf8740..d62169c 100755 --- a/web/nms.gathering.org/api/public/switches +++ b/web/nms.gathering.org/api/public/switches @@ -12,7 +12,7 @@ use Data::Dumper; $nms::web::cc{'max-age'} = "60"; -my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,ip,switchtype,poll_frequency,community,last_updated from switches natural join placements'); +my $q2 = $nms::web::dbh->prepare('select switch,sysname,placement,ip,switchtype,poll_frequency,community,last_updated from switches'); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { |