aboutsummaryrefslogtreecommitdiffstats
path: root/web/api
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2019-01-09 01:16:16 +0100
committerKristian Lyngstol <kly@kly.no>2019-01-09 01:16:16 +0100
commit16fa2623327192ca44263ad77c19e45c03d5df11 (patch)
treefcaea77a92deb7efba5f042c8205d526a3e82d0c /web/api
parent9a93c82da5d7de308e810d3f63c94e0b2569a4b6 (diff)
Expose new-style edit-stuff in old-style panel
The integration is a hack, but a first step. I will eventually remove all the code in nms-info-box, but I needed a simple test. This also demonstrates how to add a new switch.... simply hit edit, then change the name. It aint pretty, and shouldn't work like it does today, but it's a decent example. Also, had to fix the backend again now that I actually tested the write-api :D
Diffstat (limited to 'web/api')
-rwxr-xr-xweb/api/write/switches24
1 files changed, 6 insertions, 18 deletions
diff --git a/web/api/write/switches b/web/api/write/switches
index 947404d..e42c4b3 100755
--- a/web/api/write/switches
+++ b/web/api/write/switches
@@ -63,28 +63,22 @@ foreach my $tmp2 (@tmp) {
} else {
%placement = %{convertplace($switch{'placement'})};
}
- if (not defined($switch{'ip'}) and defined($switch{'mgtmt4'})) {
- $switch{'ip'} = $switch{'mgtmt4'};
- }
- if (not defined($switch{'secondary_ip'}) and defined($switch{'mgtmt6'})) {
- $switch{'secondary_ip'} = $switch{'mgtmt6'};
- }
my ($x1,$x2,$y1,$y2);
$x1 = $placement{'x1'};
$y1 = $placement{'y1'};
$x2 = $placement{'xx'};
$y2 = $placement{'yy'};
$switch{'placement'} = "(($x1,$y1),($x2,$y2))";
-
+ my @names;
+ my @values;
map {
if (defined ($template{$_})) {
- $template{$_} = $dbh->quote($switch{$_});
+ push @names,$_;
+ push @values,$dbh->quote($switch{$_});
}
} keys %switch;
-
-
- $nms::web::dbh->do("INSERT INTO SWITCHES (ip, sysname, last_updated, locked, poll_frequency, tags, community, secondary_ip, placement,subnet4,subnet6,distro) VALUES ($template{'ip'}, $template{'sysname'}, $template{'last_updated'}, $template{'locked'}, $template{'poll_frequency'}, $template{'tags'}, $template{'community'}, $template{'secondary_ip'}, $template{'placement'},$template{'subnet4'},$template{'subnet6'},$template{'distro'});");
- push @added, $switch{'sysname'};
+ $nms::web::dbh->do("INSERT INTO SWITCHES (" . join(",",@names) . ") VALUES (". join(",",@values).");");
+ push @added, $switch{'sysname'};
oplog("\"" . $switch{'sysname'} . "\"", "Switch added: " . $switch{'sysname'});
} else {
if (defined($switch{'placement'})) {
@@ -105,12 +99,6 @@ foreach my $tmp2 (@tmp) {
if (defined($switch{'tags'})) {
$switch{'tags'} =~ s/'/"/g;
}
- if (not defined($switch{'ip'}) and defined($switch{'mgtmt4'})) {
- $switch{'ip'} = $switch{'mgtmt4'};
- }
- if (not defined($switch{'secondary_ip'}) and defined($switch{'mgtmt6'})) {
- $switch{'secondary_ip'} = $switch{'mgtmt6'};
- }
my @set;
map {
if (defined($template{$_})) {