aboutsummaryrefslogtreecommitdiffstats
path: root/web/api
diff options
context:
space:
mode:
Diffstat (limited to 'web/api')
-rwxr-xr-xweb/api/read/distro-management31
1 files changed, 31 insertions, 0 deletions
diff --git a/web/api/read/distro-management b/web/api/read/distro-management
new file mode 100755
index 0000000..2aa3273
--- /dev/null
+++ b/web/api/read/distro-management
@@ -0,0 +1,31 @@
+#! /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;
+
+my $target = $ENV{REQUEST_URI};
+$target =~ s/$ENV{SCRIPT_NAME}//;
+$target =~ s/^\///;
+my ($switch, $port) = split(/\//,$target,2);
+my $q2;
+
+$nms::web::cc{'max-age'} = "5";
+$nms::web::cc{'stale-while-revalidate'} = "30";
+
+$q2 = $nms::web::dbh->prepare('SELECT distro_name,sysname,subnet4,subnet6,traffic_vlan,distro_phy_port 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 $distro = $ref->{'distro_name'};
+ $nms::web::json{'distros'}{$distro}{$sysname} = $ref;
+}
+
+finalize_output();