diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-03-04 17:47:56 +0000 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-03-04 17:47:56 +0000 |
commit | aafd5a80db7b5ee27d1c432a4db93da48fbecb8a (patch) | |
tree | 3235337d8488228ea54a5c9dd6a1b6b67474aaa2 /web/nms.gathering.org/switches_add.pl | |
parent | 289a855db874aefa4ae90f0029555ada4383fbbc (diff) |
nms: Rename API end points and separate public/private
Diffstat (limited to 'web/nms.gathering.org/switches_add.pl')
-rwxr-xr-x | web/nms.gathering.org/switches_add.pl | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/web/nms.gathering.org/switches_add.pl b/web/nms.gathering.org/switches_add.pl deleted file mode 100755 index fe23049..0000000 --- a/web/nms.gathering.org/switches_add.pl +++ /dev/null @@ -1,44 +0,0 @@ -#! /usr/bin/perl -# vim:ts=8:sw=8 - -#use CGI qw(fatalsToBrowser); -use DBI; -use lib '../../include'; -use nms; -use nms::web qw(%get_params %json finalize_output get_input); -use strict; -use warnings; -use JSON; -use Data::Dumper; - -$nms::web::cc{'max-age'} = "0"; - -my $in = get_input(); -my @tmp = @{JSON::XS::decode_json($in)}; - -my @added; -my @dups; - -my $sth = $nms::web::dbh->prepare("SELECT sysname FROM switches WHERE sysname=?"); -my $insert = $nms::web::dbh->prepare("INSERT INTO SWITCHES (ip, sysname, switchtype) VALUES(?,?,'ex2200');"); - -foreach my $tmp2 (@tmp) { - my %switch = %{$tmp2}; - my $affected = 0; - - $sth->execute( $switch{'sysname'}); - while ( my @row = $sth->fetchrow_array ) { - $affected += 1; - } - - if ($affected == 0) { - $insert->execute($switch{'mgtmt4'}, $switch{'sysname'}); - push @added, $switch{'sysname'}; - } else { - push @dups, $switch{'sysname'}; - } -} -$json{'switches_addded'} = \@added; -$json{'switches_duplicate'} = \@dups; - -finalize_output(); |