Merge branch 'ent-7683-switch-en-consola-para-desactivar-la-actualizacion-automatica-de-la-ip-principal' into 'develop'

Added switch to agetn conf to avoid automatic Ip update

ref: pandora_enterprise#7683

See merge request artica/pandorafms!5019
This commit is contained in:
Jimmy Olano 2022-08-11 14:55:40 +00:00
commit e8f84e6293
5 changed files with 34 additions and 2 deletions

View File

@ -1,3 +1,4 @@
-- Active: 1653046769261@@127.0.0.1@3306@pandora
START TRANSACTION;
CREATE TABLE IF NOT EXISTS `tuser_task` (
@ -38,6 +39,7 @@ ALTER TABLE `tautoconfig` ADD COLUMN `executed` TINYINT UNSIGNED NOT NULL DEFAUL
ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`;
ALTER TABLE `tagente` ADD COLUMN `fixed_ip` TINYINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `tipam_network` DROP FOREIGN KEY `tipam_network_ibfk_1`;
ALTER TABLE `tipam_network` MODIFY COLUMN `id_recon_task` INT UNSIGNED DEFAULT 0;
ALTER TABLE `tipam_network` ADD CONSTRAINT `tipam_network_ibfk_1` FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -302,6 +302,15 @@ $table_ip = '<div class="label_select"><p class="input_label">'.__('IP Address')
$table_ip .= '<div class="label_select_parent">';
$table_ip .= '<div class="label_select_child_left">'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'</div>';
$table_ip .= '<div class="label_select_child_right">'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').'</div>';
$table_ip .= '<div class="label_select_child_right">'.html_print_input(
[
'type' => 'switch',
'id' => 'fixed_ip',
'name' => 'fixed_ip',
'value' => $fixed_ip,
],
).__('Fix IP address').ui_print_help_tip(__('Avoid automatic IP address update when agent IP changes.'), true).'</div>';
$table_ip .= '</div></div>';
if ($id_agente) {
@ -1114,5 +1123,19 @@ ui_require_jquery_file('bgiframe');
}
$("#text-agente").prop('readonly', true);
// Disable fixed ip button if empty.
if($("#text-direccion").val() == '') {
$("#fixed_ip").prop('disabled',true);
}
$("#text-direccion").on('input',function(e){
if($("#text-direccion").val() == '') {
$("#fixed_ip").prop('disabled',true);
} else {
$("#fixed_ip").prop('disabled',false);
}
});
});
</script>

View File

@ -173,6 +173,7 @@ $url_description = '';
$quiet = 0;
$macros = '';
$cps = 0;
$fixed_ip = 0;
$create_agent = (bool) get_parameter('create_agent');
$module_macros = [];
@ -225,6 +226,7 @@ if ($create_agent) {
$url_description = (string) get_parameter('url_description');
$quiet = (int) get_parameter('quiet', 0);
$cps = (int) get_parameter_switch('cps', -1);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
$secondary_groups = (string) get_parameter('secondary_hidden', '');
$fields = db_get_all_fields_in_table('tagent_custom_fields');
@ -282,6 +284,7 @@ if ($create_agent) {
'url_address' => $url_description,
'quiet' => $quiet,
'cps' => $cps,
'fixed_ip' => $fixed_ip,
]
);
enterprise_hook('update_agent', [$id_agente]);
@ -326,7 +329,7 @@ if ($create_agent) {
"Update GIS data":"'.$update_gis_data.'",
"Url description":"'.$url_description.'",
"Quiet":"'.(int) $quiet.'",
"Cps":"'.(int) $cps.'"}';
"Cps":"'.(int) $cps.'",}';
// Create the secondary groups.
enterprise_hook(
@ -987,6 +990,7 @@ if ($update_agent) {
$fields = db_get_all_fields_in_table('tagent_custom_fields');
$secondary_groups = (string) get_parameter('secondary_hidden', '');
$satellite_server = (int) get_parameter('satellite_server', 0);
$fixed_ip = (int) get_parameter_switch('fixed_ip', 0);
if ($fields === false) {
$fields = [];
@ -1095,6 +1099,7 @@ if ($update_agent) {
'cps' => $cps,
'safe_mode_module' => $safe_mode_module,
'satellite_server' => $satellite_server,
'fixed_ip' => $fixed_ip,
];
if ($config['metaconsole_agent_cache'] == 1) {
@ -1234,6 +1239,7 @@ if ($id_agente) {
$safe_mode_module = $agent['safe_mode_module'];
$safe_mode = ($safe_mode_module) ? 1 : 0;
$satellite_server = (int) $agent['satellite_server'];
$fixed_ip = (int) $agent['fixed_ip'];
}
$update_module = (bool) get_parameter('update_module');

View File

@ -89,6 +89,7 @@ CREATE TABLE IF NOT EXISTS `tagente` (
`safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0,
`cps` INT NOT NULL DEFAULT 0,
`satellite_server` INT NOT NULL DEFAULT 0,
`fixed_ip` TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id_agente`),
KEY `nombre` (`nombre`(255)),
KEY `direccion` (`direccion`),

View File

@ -487,7 +487,7 @@ sub process_xml_data ($$$$$) {
# Update the main address
if ($address ne '' && $address ne $agent->{'direccion'}) {
pandora_update_agent_address ($pa_config, $agent_id, $agent_name, $address, $dbh);
pandora_update_agent_address ($pa_config, $agent_id, $agent_name, $address, $dbh) unless $agent->{'fixed_ip'} == 1;
pandora_add_agent_address($pa_config, $agent_id, $agent_name, $address, $dbh);
}