aboutsummaryrefslogtreecommitdiffstats
path: root/web/api/read
diff options
context:
space:
mode:
Diffstat (limited to 'web/api/read')
-rwxr-xr-xweb/api/read/distro-management2
-rwxr-xr-x[-rw-r--r--]web/api/read/networks0
-rwxr-xr-xweb/api/read/switches-management10
-rwxr-xr-xweb/api/read/template-list21
4 files changed, 30 insertions, 3 deletions
diff --git a/web/api/read/distro-management b/web/api/read/distro-management
index 7fbebef..55ca07e 100755
--- a/web/api/read/distro-management
+++ b/web/api/read/distro-management
@@ -19,7 +19,7 @@ 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 and deleted = false');
+$q2 = $nms::web::dbh->prepare('SELECT distro_name,sysname,distro_phy_port FROM switches WHERE placement is not null AND distro_name is not null AND distro_phy_port is not null and deleted = false');
$q2->execute();
while (my $ref = $q2->fetchrow_hashref()) {
diff --git a/web/api/read/networks b/web/api/read/networks
index 870ae8c..870ae8c 100644..100755
--- a/web/api/read/networks
+++ b/web/api/read/networks
diff --git a/web/api/read/switches-management b/web/api/read/switches-management
index 77badf4..b42c84b 100755
--- a/web/api/read/switches-management
+++ b/web/api/read/switches-management
@@ -13,14 +13,20 @@ use Data::Dumper;
my $target = $ENV{REQUEST_URI};
$target =~ s/$ENV{SCRIPT_NAME}//;
$target =~ s/^\///;
-my ($switch, $port) = split(/\//,$target,2);
+my $switch;
+my $port;
+
+if ($target !~ m/now=/) {
+ ($switch, $port) = split(/\//,$target,2);
+}
+
my $q2;
$nms::web::cc{'max-age'} = "5";
$nms::web::cc{'stale-while-revalidate'} = "30";
if (!defined($switch)) {
- $q2 = $nms::web::dbh->prepare('select switches.sysname, host(switches.mgmt_v4_addr) as mgmt_v4_addr, host(switches.mgmt_v6_addr) as mgmt_v6_addr, switches.mgmt_vlan, switches.traffic_vlan, switches.poll_frequency, switches.last_updated, switches.distro_name, switches.distro_phy_port, switches.community, traffic_net.subnet4, traffic_net.subnet6, mgmt_net.gw4 as mgmt_v4_gw, mgmt_net.gw6 as mgmt_v6_gw from switches left join networks as traffic_net on (switches.traffic_vlan = traffic_net.name) left join networks as mgmt_net on (switches.mgmt_vlan = mgmt_net.name) where switches.placement is not null and switches.deleted = false;');
+ $q2 = $nms::web::dbh->prepare('select switches.sysname, host(switches.mgmt_v4_addr) as mgmt_v4_addr, host(switches.mgmt_v6_addr) as mgmt_v6_addr, switches.mgmt_vlan, switches.traffic_vlan, switches.poll_frequency, switches.last_updated, switches.distro_name, switches.distro_phy_port, switches.community, traffic_net.subnet4, traffic_net.subnet6, host(mgmt_net.gw4) as mgmt_v4_gw, host(mgmt_net.gw6) as mgmt_v6_gw from switches left join networks as traffic_net on (switches.traffic_vlan = traffic_net.name) left join networks as mgmt_net on (switches.mgmt_vlan = mgmt_net.name) where switches.placement is not null and switches.deleted = false;');
} else {
$q2 = $nms::web::dbh->prepare('select sysname,host(mgmt_v4_addr) as mgmt_v4_addr,host(mgmt_v6_addr) as mgmt_v6_addr,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null and sysname = ' . $nms::web::dbh->quote($switch) . ' and switches.deleted = false;');
}
diff --git a/web/api/read/template-list b/web/api/read/template-list
new file mode 100755
index 0000000..d1c8773
--- /dev/null
+++ b/web/api/read/template-list
@@ -0,0 +1,21 @@
+#! /usr/bin/perl
+# vim:ts=8:sw=8
+
+use lib '/opt/gondul/include';
+use nms::web;
+use strict;
+use warnings;
+
+my $template_dir = "/opt/gondul/web/templates";
+
+opendir (DIR, $template_dir) or die $!;
+
+while (my $file = readdir(DIR)) {
+ next if ($file =~ m/^\./);
+ my %meh;
+ $meh{'file'} = $file;
+
+ push @{$nms::web::json{'templates'}},\%meh;
+}
+
+nms::web::finalize_output();