From 754e0dae66e55a326c288a01fecb5d7fe016c9b0 Mon Sep 17 00:00:00 2001 From: juanmanuelr Date: Tue, 29 Nov 2011 10:31:14 +0000 Subject: [PATCH] 2011-11-29 Juan Manuel Ramon * util/pandora_manage.pl: Added some checks that I forget in my last commit. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5194 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/util/pandora_manage.pl | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 5e003d795f..cba718f54e 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2011-11-29 Juan Manuel Ramon + + * util/pandora_manage.pl: Added some checks that I forget in my + last commit. + 2011-11-29 Juan Manuel Ramon * util/pandora_manage.pl: Added checks of agent and module names at diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index edc5442eb3..a18709b1a4 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -642,6 +642,10 @@ sub cli_create_network_module() { my $module_type_def; print "[INFO] Adding module '$module_name' to agent '$agent_name'\n\n"; + + my $agent_id = get_agent_id($dbh,$agent_name); + my $module_exists = get_agent_module_id($dbh, $module_name, $agent_id); + non_exist_check($module_exists, 'module name', $module_name); if ($module_type =~ m/.?snmp.?/) { print "[ERROR] '$module_type' is not a valid type. For snmp modules use --create_snmp_module parameter\n\n"; @@ -658,7 +662,6 @@ sub cli_create_network_module() { my $module_type_id = get_module_id($dbh,$module_type); exist_check($module_type_id,'module type',$module_type); - my $agent_id = get_agent_id($dbh,$agent_name); exist_check($agent_id,'agent',$agent_name); my $module_group_id = get_module_group_id($dbh,$module_group); @@ -717,11 +720,14 @@ sub cli_create_snmp_module() { print "[INFO] Adding snmp module '$module_name' to agent '$agent_name'\n\n"; + my $agent_id = get_agent_id($dbh,$agent_name); + my $module_exists = get_agent_module_id($dbh, $module_name, $agent_id); + non_exist_check($module_exists, 'module name', $module_name); + # The get_module_id has wrong name. Change in future my $module_type_id = get_module_id($dbh,$module_type); exist_check($module_type_id,'module type',$module_type); - my $agent_id = get_agent_id($dbh,$agent_name); exist_check($agent_id,'agent',$agent_name); my $module_group_id = get_module_group_id($dbh,$module_group); @@ -793,6 +799,10 @@ sub cli_create_plugin_module() { print "[INFO] Adding module '$module_name' to agent '$agent_name'\n\n"; + my $agent_id = get_agent_id($dbh,$agent_name); + my $module_exists = get_agent_module_id($dbh, $module_name, $agent_id); + non_exist_check($module_exists, 'module name', $module_name); + # The get_module_id has wrong name. Change in future my $module_type_id = get_module_id($dbh,$module_type); exist_check($module_type_id,'module type',$module_type); @@ -802,7 +812,6 @@ sub cli_create_plugin_module() { exit; } - my $agent_id = get_agent_id($dbh,$agent_name); exist_check($agent_id,'agent',$agent_name); my $module_group_id = get_module_group_id($dbh,$module_group);