2011-12-12 Sergio Martin <sergio.martin@artica.es>
* lib/PandoraFMS/Tools.pm util/pandora_db.pl: Moved is_policy_module function from db script to Enteprise and call it through enterprise hook git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5245 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
345c3de2cd
commit
f8dd9e452e
|
@ -1,3 +1,9 @@
|
||||||
|
2011-12-12 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Tools.pm
|
||||||
|
util/pandora_db.pl: Moved is_policy_module function from
|
||||||
|
db script to Enteprise and call it through enterprise hook
|
||||||
|
|
||||||
2011-12-05 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
2011-12-05 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
* pandora_server_upgrade: Removed rm of pandora_exec and
|
* pandora_server_upgrade: Removed rm of pandora_exec and
|
||||||
|
|
|
@ -539,6 +539,8 @@ sub enterprise_hook ($$) {
|
||||||
|
|
||||||
# Prepend the package name
|
# Prepend the package name
|
||||||
$func = 'PandoraFMS::Enterprise::' . $func;
|
$func = 'PandoraFMS::Enterprise::' . $func;
|
||||||
|
|
||||||
|
# undef is returned only if the enterprise function was not found
|
||||||
return undef unless (defined (&$func));
|
return undef unless (defined (&$func));
|
||||||
|
|
||||||
# Try to call the function
|
# Try to call the function
|
||||||
|
@ -546,8 +548,6 @@ sub enterprise_hook ($$) {
|
||||||
|
|
||||||
# Check for errors
|
# Check for errors
|
||||||
#return undef if ($@);
|
#return undef if ($@);
|
||||||
|
|
||||||
# undef is returned only if the enterprise function was not found
|
|
||||||
return '' unless defined ($output);
|
return '' unless defined ($output);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
|
|
@ -440,7 +440,8 @@ sub pandora_checkdb_consistency {
|
||||||
my $id_agente_modulo = $module->{'id_agente_modulo'};
|
my $id_agente_modulo = $module->{'id_agente_modulo'};
|
||||||
|
|
||||||
# Skip policy modules
|
# Skip policy modules
|
||||||
next if (is_policy_module ($dbh, $id_agente_modulo));
|
my $is_policy_module = enterprise_hook ('is_policy_module', [$dbh, $id_agente_modulo]);
|
||||||
|
next if (defined($is_policy_module) && $is_policy_module);
|
||||||
|
|
||||||
# Delete the module
|
# Delete the module
|
||||||
db_do ($dbh, 'DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = ?', $id_agente_modulo);;
|
db_do ($dbh, 'DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = ?', $id_agente_modulo);;
|
||||||
|
@ -456,7 +457,8 @@ sub pandora_checkdb_consistency {
|
||||||
my $id_agente_modulo = $module->{'id_agente_modulo'};
|
my $id_agente_modulo = $module->{'id_agente_modulo'};
|
||||||
|
|
||||||
# Skip policy modules
|
# Skip policy modules
|
||||||
next if (is_policy_module ($dbh, $id_agente_modulo));
|
my $is_policy_module = enterprise_hook ('is_policy_module', [$dbh, $id_agente_modulo]);
|
||||||
|
next if (defined($is_policy_module) && $is_policy_module);
|
||||||
|
|
||||||
# Delete the module
|
# Delete the module
|
||||||
db_do ($dbh, 'DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = ?', $id_agente_modulo);;
|
db_do ($dbh, 'DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = ?', $id_agente_modulo);;
|
||||||
|
@ -496,37 +498,6 @@ sub pandora_checkdb_consistency {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Returns undef if the given module is not a policy module.
|
|
||||||
###############################################################################
|
|
||||||
sub is_policy_module ($$) {
|
|
||||||
my ($dbh, $module_id) = @_;
|
|
||||||
|
|
||||||
eval {
|
|
||||||
my $count = get_db_value ($dbh, 'SELECT COUNT(*) FROM tpolicies');
|
|
||||||
};
|
|
||||||
|
|
||||||
# Not running Pandora FMS Enterprise
|
|
||||||
return undef if ($@);
|
|
||||||
|
|
||||||
# Get agent id
|
|
||||||
my $agent_id = get_db_value ($dbh, 'SELECT id_agente FROM tagente_modulo WHERE id_agente_modulo = ?', $module_id);
|
|
||||||
return undef unless defined ($agent_id);
|
|
||||||
|
|
||||||
# Get module name
|
|
||||||
my $module_name = get_db_value ($dbh, 'SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = ?', $module_id);
|
|
||||||
return undef unless defined ($module_name);
|
|
||||||
|
|
||||||
# Search policies
|
|
||||||
my $policy_id = get_db_value ($dbh, 'SELECT t3.id FROM tpolicy_agents AS t1 INNER JOIN tpolicy_modules AS t2 ON t1.id_policy = t2.id_policy
|
|
||||||
INNER JOIN tpolicies AS t3 ON t1.id_policy = t3.id WHERE t1.id_agent = ? AND t2.name LIKE ?', $agent_id, $module_name);
|
|
||||||
|
|
||||||
# Not a policy module
|
|
||||||
return undef unless defined ($policy_id);
|
|
||||||
|
|
||||||
return $policy_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Print a help screen and exit.
|
# Print a help screen and exit.
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
Loading…
Reference in New Issue