aboutsummaryrefslogtreecommitdiffstats
path: root/web/api/read/distro-management
diff options
context:
space:
mode:
authorOle Mathias Heggem <ole@sdok.no>2017-04-19 23:16:07 +0200
committerOle Mathias Heggem <ole@sdok.no>2017-04-19 23:16:07 +0200
commit7b97188b728c85c498acc8acdce1750c472f2c85 (patch)
tree12c1436ab7eb97e9434e774671e8ffea134d61db /web/api/read/distro-management
parentf70f65f7466a480a45a8260b35887cb7ed36b466 (diff)
parent7d404abf07d865d253ac2cfc353741e8d4af4867 (diff)
Merge remote-tracking branch 'refs/remotes/tech-server/master'
Diffstat (limited to 'web/api/read/distro-management')
-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();