Merge branch 'ent-5101-9223-Eliminacion-de-agentes-en-nodo-no-elimina-agentes-en-politica-de-meta' into 'develop'

Ent 5101 9223 eliminacion de agentes en nodo no elimina agentes en politica de meta

See merge request artica/pandorafms!3107
This commit is contained in:
Daniel Rodriguez 2020-03-20 12:34:58 +01:00
commit 1d7d6fb15d
6 changed files with 29 additions and 6 deletions

View File

@ -227,7 +227,9 @@ if (!$new_agent && $alias != '') {
$agent_options_update = 'agent_options_update';
// Delete link from here.
$table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=".$id_agente."&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>';
if (!is_central_policies_on_node()) {
$table_agent_name .= "<a onClick=\"if (!confirm('".__('Are you sure?')."')) return false;\" href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente=".$id_agente."&search=&offset=0&sort_field=&sort=none'>".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).'</a>';
}
// Remote configuration available.
if (isset($filename)) {

View File

@ -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')]).'</a>';
}
if ($check_aw) {
if ($check_aw && !is_central_policies_on_node()) {
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&
borrar_agente=".$agent['id_agente']."&group_id=$ag_group&recursion=$recursion&search=$search&offset=$offsetArg&sort_field=$sortField&sort=$sort&disabled=$disabled'";

View File

@ -186,11 +186,13 @@ $table->data[2][1] = html_print_select(
echo '<form method="post" id="form_agents" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents">';
html_print_table($table);
if (!is_central_policies_on_node()) {
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
html_print_input_hidden('delete', 1);
html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
}
echo '<div class="action-buttons" style="width: '.$table->width.'" onsubmit="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
html_print_input_hidden('delete', 1);
html_print_submit_button(__('Delete'), 'go', false, 'class="sub delete"');
echo '</div>';
echo '</form>';
echo '<h3 class="error invisible" id="message"> </h3>';

View File

@ -305,6 +305,10 @@ echo '</div>';
</script>
<?php
if (is_central_policies_on_node() && $option == 'delete_agents') {
ui_print_warning_message(__('This node is configured with centralized mode. To delete an agent go to metaconsole.'));
}
echo '<br />';
echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">';
echo '<table border="0"><tr><td>';

View File

@ -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 {

View File

@ -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]);