diff options
author | Lasse Haugen <haugen.lasse@gmail.com> | 2017-01-10 23:51:40 +0100 |
---|---|---|
committer | Lasse Haugen <haugen.lasse@gmail.com> | 2017-01-10 23:51:40 +0100 |
commit | 8fbd4f9ac58002f67eccc5fb78afc95d28584f52 (patch) | |
tree | ea85eb06b82b6797347deb8e75f341a558491f1c | |
parent | e905dd8398583c1fff37cf2876a3a8ccf7f0dcd3 (diff) |
Implement support for per-switch queries for switches-management
-rwxr-xr-x | web/api/read/switches-management | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/web/api/read/switches-management b/web/api/read/switches-management index 237ac2d..425262e 100755 --- a/web/api/read/switches-management +++ b/web/api/read/switches-management @@ -10,10 +10,20 @@ 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"; -my $q2 = $nms::web::dbh->prepare('select sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null'); +if (!defined($switch)) { + $q2 = $nms::web::dbh->prepare('select sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,mgmt_vlan,traffic_vlan,poll_frequency,last_updated,distro_name,distro_phy_port,community from switches where placement is not null'); +} else { + $q2 = $nms::web::dbh->prepare('select sysname,mgmt_v4_addr,subnet4,subnet6,mgmt_v6_addr,mgmt_v4_gw,mgmt_v6_gw,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) . ';'); +} $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { |