From 746e73a9ea27dc90047ac26950c21f963bf99af5 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Fri, 20 May 2016 16:48:03 +0200 Subject: Add system-generated op logs First up: Add a switch, get a log entry. This might require some filtering in the GUI eventually. This is why the user is set to 'system', even when we have an actual user that triggered the event. --- web/api/write/switch-add | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'web/api/write/switch-add') diff --git a/web/api/write/switch-add b/web/api/write/switch-add index 56e5cb2..d210567 100755 --- a/web/api/write/switch-add +++ b/web/api/write/switch-add @@ -11,6 +11,7 @@ use strict; use warnings; use JSON; use Data::Dumper; +use nms::oplog qw(oplog); $nms::web::cc{'max-age'} = "0"; @@ -83,10 +84,11 @@ foreach my $tmp2 (@tmp) { $nms::web::dbh->do("INSERT INTO SWITCHES (mgmt_v4_addr, sysname, poll_frequency, community, lldp_chassis_id, mgmt_v6_addr, placement,subnet4,subnet6,distro_name) VALUES ($template{'mgmt_v4_addr'}, $template{'sysname'}, $template{'poll_frequency'}, $template{'community'}, $template{'lldp_chassis_id'}, $template{'mgmt_v6_addr'}, $template{'placement'},$template{'subnet4'},$template{'subnet6'},$template{'distro_name'});"); push @added, $switch{'sysname'}; + oplog($switch{'sysname'}, "Switch added: " . $switch{'sysname'}); } } $json{'switches_addded'} = \@added; -print "X-ban: /api/.*switches.*\n"; +print "X-ban: /api/.*\n"; finalize_output(); -- cgit v1.2.3