diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2016-11-08 12:29:50 +0100 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2016-11-08 12:29:50 +0100 |
commit | 6cdda4fac97792256d170f6396e333c43f7c9fd7 (patch) | |
tree | d5cf491e69e827438ab5c7697d742ea048e29c2a | |
parent | f9e79c6d8e7484e00e493d1b3436d5c6bc05be3e (diff) |
Add distro-tree endpoint
Fixes #139
References #148
New problem: Test data is insufficient.
-rwxr-xr-x | web/api/read/distro-tree | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/web/api/read/distro-tree b/web/api/read/distro-tree new file mode 100755 index 0000000..5d93e1b --- /dev/null +++ b/web/api/read/distro-tree @@ -0,0 +1,25 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use CGI qw(fatalsToBrowser); +use DBI; +use lib '/opt/gondul/include'; +use nms; +use nms::web; +use strict; +use warnings; +use Data::Dumper; + +$nms::web::cc{'max-age'} = "20"; + +my $q2 = $nms::web::dbh->prepare('select sysname,distro_phy_port,distro_name from switches where placement is not null and distro_name is not null and distro_phy_port is not null'); + +$q2->execute(); +while (my $ref = $q2->fetchrow_hashref()) { + my $sysname = $ref->{'sysname'}; + my $phy = $ref->{'distro_phy_port'}; + my $distro = $ref->{'distro_name'}; + $nms::web::json{'distro-tree'}{$distro}{$phy} = $sysname; +} + +finalize_output(); |