Merge branch '1885-ue-configurador-automatico-de-agentes' into 'develop'
Added DB changes to support ProvisioningServer 2 See merge request artica/pandorafms!1587
This commit is contained in:
commit
5bfeac1b87
|
@ -15,7 +15,9 @@ ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL DEFAULT '0';
|
||||||
ALTER TABLE `tpolicy_modules` ADD COLUMN `cps` int NOT NULL DEFAULT '0';
|
ALTER TABLE `tpolicy_modules` ADD COLUMN `cps` int NOT NULL DEFAULT '0';
|
||||||
|
|
||||||
DROP INDEX id_policy ON `tpolicy_agents`;
|
DROP INDEX id_policy ON `tpolicy_agents`;
|
||||||
|
|
||||||
ALTER TABLE `tpolicy_agents` ADD COLUMN `id_node` int(10) NOT NULL DEFAULT '0';
|
ALTER TABLE `tpolicy_agents` ADD COLUMN `id_node` int(10) NOT NULL DEFAULT '0';
|
||||||
|
|
||||||
ALTER TABLE `tpolicy_agents` ADD UNIQUE(`id_policy`, `id_agent`, `id_node`);
|
ALTER TABLE `tpolicy_agents` ADD UNIQUE(`id_policy`, `id_agent`, `id_node`);
|
||||||
|
|
||||||
ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL;
|
ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL;
|
||||||
|
@ -30,4 +32,40 @@ ALTER TABLE `tmetaconsole_event` ADD COLUMN `module_status` int(4) NOT NULL defa
|
||||||
|
|
||||||
ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `module_status` int(4) NOT NULL default '0';
|
ALTER TABLE `tmetaconsole_event_history` ADD COLUMN `module_status` int(4) NOT NULL default '0';
|
||||||
|
|
||||||
COMMIT;
|
CREATE TABLE `tautoconfig` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(100) NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`description` text,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `tautoconfig_rules` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`operator` enum('AND','OR') DEFAULT 'OR',
|
||||||
|
`type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias',
|
||||||
|
`value` text,
|
||||||
|
`custom` text,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
|
CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `tautoconfig_actions` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event',
|
||||||
|
`value` text,
|
||||||
|
`custom` text,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
|
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
|
@ -1669,3 +1669,47 @@ create table IF NOT EXISTS `tmetaconsole_agent_secondary_group`(
|
||||||
ALTER TABLE tagente ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0';
|
ALTER TABLE tagente ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0';
|
||||||
ALTER TABLE tmetaconsole_agent ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0';
|
ALTER TABLE tmetaconsole_agent ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0';
|
||||||
ALTER TABLE tusuario_perfil ADD COLUMN `is_secondary` tinyint(1) NOT NULL default '0';
|
ALTER TABLE tusuario_perfil ADD COLUMN `is_secondary` tinyint(1) NOT NULL default '0';
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tautoconfig`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `tautoconfig` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(100) NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`description` text,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tautoconfig_rules`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `tautoconfig_rules` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`operator` enum('AND','OR') DEFAULT 'OR',
|
||||||
|
`type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias',
|
||||||
|
`value` text,
|
||||||
|
`custom` text,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
|
CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tautoconfig_actions`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `tautoconfig_actions` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event',
|
||||||
|
`value` text,
|
||||||
|
`custom` text,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
|
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,12 +101,12 @@ if (check_acl ($config['id_user'], 0, "PM")) {
|
||||||
$sub["godmode/modules/manage_network_templates"]["text"] = __('Module templates');
|
$sub["godmode/modules/manage_network_templates"]["text"] = __('Module templates');
|
||||||
$sub["godmode/modules/manage_network_templates"]["id"] = 'Module templates';
|
$sub["godmode/modules/manage_network_templates"]["id"] = 'Module templates';
|
||||||
enterprise_hook ('inventory_submenu');
|
enterprise_hook ('inventory_submenu');
|
||||||
|
enterprise_hook ('autoconfiguration_menu');
|
||||||
}
|
}
|
||||||
if (check_acl ($config['id_user'], 0, "AW")) {
|
if (check_acl ($config['id_user'], 0, "AW")) {
|
||||||
enterprise_hook ('policies_menu');
|
enterprise_hook ('policies_menu');
|
||||||
enterprise_hook('agents_submenu');
|
enterprise_hook('agents_submenu');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_acl ($config['id_user'], 0, "AW")) {
|
if (check_acl ($config['id_user'], 0, "AW")) {
|
||||||
$sub["gmassive"]["text"] = __('Bulk operations');
|
$sub["gmassive"]["text"] = __('Bulk operations');
|
||||||
$sub["gmassive"]["id"] = 'Bulk operations';
|
$sub["gmassive"]["id"] = 'Bulk operations';
|
||||||
|
|
|
@ -1363,6 +1363,18 @@ function is_metaconsole() {
|
||||||
return (bool) $config['metaconsole'];
|
return (bool) $config['metaconsole'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if there is management operations are allowed in current context
|
||||||
|
* (node // meta)
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function is_management_allowed() {
|
||||||
|
global $config;
|
||||||
|
return ( (is_metaconsole() && $config["centralized_management"])
|
||||||
|
|| (!is_metaconsole() && !$config["centralized_management"]));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if there is centralized management in metaconsole environment.
|
* @brief Check if there is centralized management in metaconsole environment.
|
||||||
* Usefull to display some policy features on metaconsole.
|
* Usefull to display some policy features on metaconsole.
|
||||||
|
|
|
@ -3204,3 +3204,46 @@ create table IF NOT EXISTS `tmetaconsole_agent_secondary_group`(
|
||||||
ON DELETE CASCADE
|
ON DELETE CASCADE
|
||||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tautoconfig`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `tautoconfig` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(100) NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`description` text,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tautoconfig_rules`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `tautoconfig_rules` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`operator` enum('AND','OR') DEFAULT 'OR',
|
||||||
|
`type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias',
|
||||||
|
`value` text,
|
||||||
|
`custom` text,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
|
CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tautoconfig_actions`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `tautoconfig_actions` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_autoconfig` int(10) unsigned NOT NULL,
|
||||||
|
`order` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event',
|
||||||
|
`value` text,
|
||||||
|
`custom` text,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `id_autoconfig` (`id_autoconfig`),
|
||||||
|
CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -486,6 +486,8 @@ sub pandora_load_config {
|
||||||
$pa_config->{"provisioningserver_threads"} = 1; # 7.0 720
|
$pa_config->{"provisioningserver_threads"} = 1; # 7.0 720
|
||||||
$pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720
|
$pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720
|
||||||
|
|
||||||
|
$pa_config->{"autoconfigure_agents"} = 1; # 7.0 725
|
||||||
|
|
||||||
# Check for UID0
|
# Check for UID0
|
||||||
if ($pa_config->{"quiet"} != 0){
|
if ($pa_config->{"quiet"} != 0){
|
||||||
if ($> == 0){
|
if ($> == 0){
|
||||||
|
@ -1113,6 +1115,9 @@ sub pandora_load_config {
|
||||||
elsif ($parametro =~ m/^provisioning_cache_interval\s+([0-9]*)/i){
|
elsif ($parametro =~ m/^provisioning_cache_interval\s+([0-9]*)/i){
|
||||||
$pa_config->{'provisioning_cache_interval'}= clean_blank($1);
|
$pa_config->{'provisioning_cache_interval'}= clean_blank($1);
|
||||||
}
|
}
|
||||||
|
elsif ($parametro =~ m/^autoconfigure_agents\s+([0-1])/i){
|
||||||
|
$pa_config->{'autoconfigure_agents'}= clean_blank($1);
|
||||||
|
}
|
||||||
} # end of loop for parameter #
|
} # end of loop for parameter #
|
||||||
|
|
||||||
# Set to RDBMS' standard port
|
# Set to RDBMS' standard port
|
||||||
|
|
|
@ -50,6 +50,7 @@ our @EXPORT = qw(
|
||||||
db_text
|
db_text
|
||||||
db_update
|
db_update
|
||||||
db_update_get_values
|
db_update_get_values
|
||||||
|
set_update_agent
|
||||||
get_action_id
|
get_action_id
|
||||||
get_addr_id
|
get_addr_id
|
||||||
get_agent_addr_id
|
get_agent_addr_id
|
||||||
|
@ -801,6 +802,35 @@ sub get_db_rows_limit ($$$;@) {
|
||||||
return @rows;
|
return @rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
## Updates agent fields using field => value
|
||||||
|
## Be careful, no filter is done.
|
||||||
|
##########################################################################
|
||||||
|
sub set_update_agent {
|
||||||
|
my ($dbh, $agent_id, $data) = @_;
|
||||||
|
|
||||||
|
return undef unless (defined($agent_id) && $agent_id > 0);
|
||||||
|
return undef unless (ref($data) eq "HASH");
|
||||||
|
|
||||||
|
# Build update query
|
||||||
|
my $query = 'UPDATE tagente SET ';
|
||||||
|
|
||||||
|
my @values;
|
||||||
|
foreach my $field (keys %{$data}) {
|
||||||
|
push @values, $data->{$field};
|
||||||
|
|
||||||
|
$query .= ' ' . $field . ' = ?,';
|
||||||
|
}
|
||||||
|
|
||||||
|
chop($query);
|
||||||
|
|
||||||
|
$query .= ' WHERE id_agente = ? ';
|
||||||
|
push @values, $agent_id;
|
||||||
|
|
||||||
|
return db_update($dbh, $query, @values);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
## SQL delete with a LIMIT clause.
|
## SQL delete with a LIMIT clause.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -413,6 +413,12 @@ sub process_xml_data ($$$$$) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined($pa_config->{'autoconfigure_agents'}) && $pa_config->{'autoconfigure_agents'} == 1) {
|
||||||
|
# Update agent configuration once, before create agent - MetaConsole port to Node
|
||||||
|
enterprise_hook('autoconfigure_agent', [$pa_config, $agent_name, $agent_id, $data, $dbh]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the data of the agent, if fail return
|
# Get the data of the agent, if fail return
|
||||||
|
|
|
@ -990,6 +990,18 @@ sub init {
|
||||||
return $conf;
|
return $conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Update internal UA timeout
|
||||||
|
################################################################################
|
||||||
|
sub ua_set_timeout {
|
||||||
|
my ($config, $timeout) = @_;
|
||||||
|
return unless looks_like_number($timeout) and $timeout > 0;
|
||||||
|
my $sys = get_sys_environment($config);
|
||||||
|
|
||||||
|
return unless defined($sys->{'ua'});
|
||||||
|
$sys->{'ua'}->timeout($timeout);
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# initialize plugin (basic)
|
# initialize plugin (basic)
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Reference in New Issue