From e0b69bbe3edb14785f0a7835480935f74e8943c0 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Fri, 20 Mar 2020 12:34:58 +0100 Subject: [PATCH] Ent 5101 9223 eliminacion de agentes en nodo no elimina agentes en politica de meta --- pandora_console/godmode/agentes/agent_manager.php | 4 +++- pandora_console/godmode/agentes/modificar_agente.php | 6 +++++- .../godmode/massive/massive_delete_agents.php | 10 ++++++---- pandora_console/godmode/massive/massive_operations.php | 4 ++++ pandora_console/include/functions_api.php | 6 ++++++ pandora_server/util/pandora_manage.pl | 5 +++++ 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index d4292bc465..e5a10f0a53 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -227,7 +227,9 @@ if (!$new_agent && $alias != '') { $agent_options_update = 'agent_options_update'; // Delete link from here. - $table_agent_name .= "".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; + if (!is_central_policies_on_node()) { + $table_agent_name .= "".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; + } // Remote configuration available. if (isset($filename)) { diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 3d2db9994a..244e1d8618 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -62,6 +62,10 @@ $onheader = ['view' => $viewtab]; // Header. ui_print_page_header(__('Agents defined in %s', get_product_name()), 'images/agent_mc.png', false, '', true, $onheader); +if (is_central_policies_on_node()) { + ui_print_warning_message(__('This node is configured with centralized mode. To delete an agent go to metaconsole.')); +} + // Perform actions. $agent_to_delete = (int) get_parameter('borrar_agente'); $enable_agent = (int) get_parameter('enable_agent'); @@ -694,7 +698,7 @@ if ($agents !== false) { echo html_print_image('images/lightbulb.png', true, ['alt' => __('Disable agent'), 'title' => __('Disable agent')]).''; } - if ($check_aw) { + if ($check_aw && !is_central_policies_on_node()) { echo "data[2][1] = html_print_select( echo '
'; html_print_table($table); +if (!is_central_policies_on_node()) { + echo '
'; + html_print_input_hidden('delete', 1); + html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"'); + echo '
'; +} -echo '
'; -html_print_input_hidden('delete', 1); -html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"'); -echo '
'; echo '
'; echo ''; diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 9e81bd3aaa..0fb08d0034 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -305,6 +305,10 @@ echo ''; '; echo '
'; echo '
'; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 4c09cde9ae..e18cfbd094 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1868,6 +1868,12 @@ function api_set_delete_agent($id, $thrash1, $other, $thrash3) } } } else { + // Delete only if the centralised mode is disabled. + if (is_central_policies_on_node()) { + returnError('centralized'); + exit; + } + if ($agent_by_alias) { $idsAgents = agents_get_agent_id_by_alias(io_safe_input($id)); } else { diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index f328000d44..f532fa5208 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -1143,6 +1143,11 @@ sub cli_delete_agent() { $agent_name = decode_entities($agent_name); + if(is_metaconsole($conf) != 1 and pandora_get_tconfig_token ($dbh, 'centralized_management', '')) { + print_log "[ERROR] This node is configured with centralized mode. To delete an agent go to metaconsole. \n\n"; + exit; + } + if (is_metaconsole($conf) == 1) { if (not defined $use_alias) { my $agents_groups = enterprise_hook('get_metaconsole_agent',[$dbh, $agent_name]);