From 6cdda4fac97792256d170f6396e333c43f7c9fd7 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 8 Nov 2016 12:29:50 +0100 Subject: Add distro-tree endpoint Fixes #139 References #148 New problem: Test data is insufficient. --- web/api/read/distro-tree | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 web/api/read/distro-tree (limited to 'web/api/read') 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(); -- cgit v1.2.3