From 4358f37e07797deeb02c8ec27658b53bff098ed8 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Wed, 24 Jan 2018 16:15:53 +0100 Subject: [PATCH] Delete clusters, agents and modules - #1748 --- .../general/firts_task/cluster_builder.php | 2 +- .../reporting/cluster_builder.main.php | 40 ++++++---- .../godmode/reporting/cluster_builder.php | 35 ++++++--- .../godmode/reporting/cluster_list.php | 73 ++++++++++++------- .../godmode/reporting/cluster_view.php | 2 +- pandora_console/pandoradb_data.sql | 2 - 6 files changed, 100 insertions(+), 54 deletions(-) diff --git a/pandora_console/general/firts_task/cluster_builder.php b/pandora_console/general/firts_task/cluster_builder.php index 8edec602be..a9c4cf2083 100644 --- a/pandora_console/general/firts_task/cluster_builder.php +++ b/pandora_console/general/firts_task/cluster_builder.php @@ -40,7 +40,7 @@ ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no cl echo __('Clusters to guarantee service: these are active - passive (A/P) mode clusters. It means that one of the nodes (or machines that make up the cluster) will be running (primary) and another won\'t (secondary). When the primary goes down, the secondary must take over and give the service instead. Although many of the elements of this cluster are active-passive, it will also have active elements in both of them that indicate that the passive node is "online", so that in the case of a service failure in the master, the active node collects this information.'); ?>

-
+
diff --git a/pandora_console/godmode/reporting/cluster_builder.main.php b/pandora_console/godmode/reporting/cluster_builder.main.php index ea7a8210e6..fa894c9786 100644 --- a/pandora_console/godmode/reporting/cluster_builder.main.php +++ b/pandora_console/godmode/reporting/cluster_builder.main.php @@ -157,10 +157,7 @@ echo '
'; if($step == 1){ - if ($edit_cluster) - echo "
"; - else - echo ""; + echo ""; echo ""; echo ""; @@ -222,7 +219,7 @@ elseif($step == 2){ echo ""; echo ""; @@ -230,7 +227,7 @@ elseif($step == 2){ echo ""; echo ""; echo ""; @@ -293,7 +290,7 @@ elseif ($step == 3) { echo ""; echo ""; @@ -301,7 +298,7 @@ elseif ($step == 3) { echo ""; echo ""; echo ""; @@ -408,7 +405,7 @@ elseif ($step == 5) { echo ""; echo ""; @@ -416,7 +413,7 @@ elseif ($step == 5) { echo ""; echo ""; echo ""; @@ -713,20 +710,35 @@ elseif ($step == 6) { refresh_agents($(this).val(), agents_out_keys, agents_out, $("#id_agents"), ); }); - $("input[name='select_all_left']").click(function () { + $("#select_all_left_agents").click(function () { $('#id_agents option').map(function() { $(this).prop('selected', true); }); return false; }); - $("input[name='select_all_right']").click(function () { + $("#select_all_right_agents").click(function () { $('#id_agents2 option').map(function() { $(this).prop('selected', true); }); return false; }); + + $("#select_all_left_modules").click(function () { + $('#name_modules option').map(function() { + $(this).prop('selected', true); + }); + + return false; + }); + $("#select_all_right_modules").click(function () { + $('#name_modules2 option').map(function() { + $(this).prop('selected', true); + }); + + return false; + }); $("#agent_right").click (function () { jQuery.each($("select[name='id_agents[]'] option:selected"), function (key, value) { @@ -902,9 +914,9 @@ elseif ($step == 6) { }); } - - }); + + }); diff --git a/pandora_console/godmode/reporting/cluster_builder.php b/pandora_console/godmode/reporting/cluster_builder.php index dc674e3561..9044a0be37 100644 --- a/pandora_console/godmode/reporting/cluster_builder.php +++ b/pandora_console/godmode/reporting/cluster_builder.php @@ -26,11 +26,12 @@ if (! check_acl ($config['id_user'], 0, "RW") && ! check_acl ($config['id_user'] require_once ('include/functions_agents.php'); require_once('include/functions_clusters.php'); -$step = get_parameter('step',1); +$step = get_parameter('step',0); $id_cluster = get_parameter('id_cluster',0); +$delete_cluster = get_parameter('delete_cluster',0); if($step == 1){ - + $add_cluster = (bool) get_parameter('add_cluster', false); $update_cluster = (bool) get_parameter('update_cluster', false); @@ -70,7 +71,8 @@ if ($add_cluster) { 'nombre' => 'Cluster status', 'id_modulo' => 5, 'prediction_module' => 5, - 'id_agente' =>$id_agent + 'id_agente' =>$id_agent, + 'custom_integer_1' =>$id_cluster ); $id_module = db_process_sql_insert('tagente_modulo', $values_module); @@ -168,7 +170,8 @@ elseif ($step == 3) { 'id_modulo' => 5, 'prediction_module' => 6, 'id_agente' => $id_agent[0]['id_agent'], - 'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'] + 'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'], + 'custom_integer_1' =>$id_cluster ); $id_module = db_process_sql_insert('tagente_modulo', $values_module); @@ -239,7 +242,7 @@ elseif ($step == 3) { header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_builder&step=5&id_cluster=".$id_cluster); } elseif ($cluster_type[$id_cluster] == 'AA') { - header ("Location: index.php?sec=estado&sec2=enterprise/operation/cluster/cluster"); + header ("Location: index.php?sec=reporting&sec2=godmode/reporting/cluster_view&id=".$id_cluster); } } @@ -273,7 +276,8 @@ elseif ($step == 3) { 'id_modulo' => 5, 'prediction_module' => 7, 'id_agente' => $id_agent[0]['id_agent'], - 'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'] + 'parent_module_id' => $id_parent_modulo[0]['id_agente_modulo'], + 'custom_integer_1' =>$id_cluster ); $id_module = db_process_sql_insert('tagente_modulo', $values_module); @@ -335,9 +339,22 @@ elseif ($step == 3) { ui_print_page_header (__('Cluster')." » ".__('New'), "images/chart.png", false, "", false, $buttons); } - - - + elseif ($delete_cluster){ + + $temp_id_cluster = db_process_sql('select id_agent from tcluster where id ='.$delete_cluster); + + $tcluster_modules_delete = db_process_sql('delete from tagente_modulo where custom_integer_1 = '.$delete_cluster); + + $tcluster_items_delete = db_process_sql('delete from tcluster_item where id_cluster = '.$delete_cluster); + + $tcluster_agents_delete = db_process_sql('delete from tcluster_agent where id_cluster = '.$delete_cluster); + + $tcluster_delete = db_process_sql('delete from tcluster where id = '.$delete_cluster); + + $tcluster_agent_delete = db_process_sql('delete from tagente where id_agente = '.$temp_id_cluster[0]['id_agent']); + + header ("Location: index.php?sec=reporting&sec2=enterprise/operation/cluster/cluster"); + } $active_tab = get_parameter('tab', 'main'); diff --git a/pandora_console/godmode/reporting/cluster_list.php b/pandora_console/godmode/reporting/cluster_list.php index a227fe233e..1b53548168 100644 --- a/pandora_console/godmode/reporting/cluster_list.php +++ b/pandora_console/godmode/reporting/cluster_list.php @@ -34,20 +34,41 @@ ui_pagination (count($clusters)); $table->class = 'databox data'; $table->align = array (); $table->head = array (); - $table->head[0] = __('Cluster name'); - $table->head[1] = __('Description'); - $table->head[2] = __('Cluster type'); - $table->head[3] = __('Number of A/A modules'); - $table->head[4] = __('Number of A/P modules'); - $table->head[5] = __('Group'); - $table->head[6] = __('Actions'); - $table->size[0] = '25%'; + $table->head[0] = __('Cluster name') . ' ' . + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; + $table->head[1] = __('Description') . ' ' . + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; + + $table->head[2] = __('Group') . ' ' . + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; + + $table->head[3] = __('Type') . ' ' . + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; + + + $table->head[4] = __('Nodes') . ' ' . + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; + + $table->head[5] = __('Status') . ' ' . + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; + + $table->head[6] = __('Actions') . ' ' . + '' . html_print_image("images/sort_up.png", true, array("style" => $selectNameUp, "alt" => "up")) . '' . + '' . html_print_image("images/sort_down.png", true, array("style" => $selectNameDown, "alt" => "down")) . ''; + + $table->size[0] = '25%'; $table->size[1] = '25%'; $table->size[2] = '10%'; $table->size[3] = '10%'; $table->size[4] = '15%'; $table->size[5] = '10%'; - $table->size[5] = '5%'; + $table->size[6] = '5%'; $table->align[2] = 'left'; $table->align[3] = 'left'; @@ -58,32 +79,30 @@ ui_pagination (count($clusters)); $data[0] = ''.$cluster["name"].''; $data[1] = ui_print_truncate_text($cluster["description"], 70); - $data[2] = $cluster["cluster_type"]; + + $data[2] = ui_print_group_icon($cluster['group'],true); + + $data[3] = $cluster["cluster_type"]; - $aa_modules_cluster = db_process_sql('select count(*) as number from tcluster_item where id_cluster = '.$cluster['id'].' and item_type = "AA"'); - - $data[3] = $aa_modules_cluster[0]['number']; + $nodes_cluster = db_process_sql('select count(*) as number from tcluster_agent where id_cluster = '.$cluster['id']); + + $data[4] = $nodes_cluster[0]['number']; + + $cluster_agent = db_process_sql('select id_agente from tagente where id_agente = (select id_agent from tcluster where id = '.$cluster['id'].')'); + + $cluster_agent_status = agents_get_status($cluster_agent[0]['id_agente']); + + $data[5] = $cluster_agent_status; - if($cluster['cluster_type'] == 'AP'){ - $ap_modules_cluster = db_process_sql('select count(*) as number from tcluster_item where id_cluster = '.$cluster['id'].' and item_type = "AP"'); - - $data[4] = $ap_modules_cluster[0]['number']; - } - else{ - $data[4] = 'AA clusters do not have AP modules'; - } - - $data[5] = ui_print_group_icon($cluster['group'],true); - - $data[6] = " - "; + $data[6] = " + "; array_push ($table->data, $data); } html_print_table($table); - echo ''; + echo ''; html_print_submit_button (__('Create cluster'), 'create', false, 'class="sub next" style="margin-right:5px;"'); echo ""; diff --git a/pandora_console/godmode/reporting/cluster_view.php b/pandora_console/godmode/reporting/cluster_view.php index b0c2b9b70a..363a5a0c9f 100644 --- a/pandora_console/godmode/reporting/cluster_view.php +++ b/pandora_console/godmode/reporting/cluster_view.php @@ -71,6 +71,6 @@ echo "
"; - // $attr = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); + $attr = array('id' => 'select_all_left_agents', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); echo "" . __('Agents')."  " . html_print_image ('images/tick.png', true, $attr, false, true); echo ""; - // $attr = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); + $attr = array('id' => 'select_all_right_agents', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); echo "" . __('Agents in Cluster')."  " . html_print_image ('images/tick.png', true, $attr, false, true); echo "
"; - // $attr = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); + $attr = array('id' => 'select_all_left_modules', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); echo "" . __('Common in agents')."  " . html_print_image ('images/tick.png', true, $attr, false, true); echo ""; - // $attr = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); + $attr = array('id' => 'select_all_right_modules', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); echo "" . __('Added common modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); echo "
"; - // $attr = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); + $attr = array('id' => 'select_all_left_modules', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); echo "" . __('Modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); echo ""; - // $attr = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); + $attr = array('id' => 'select_all_right_modules', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); echo "" . __('Added balanced modules')."  " . html_print_image ('images/tick.png', true, $attr, false, true); echo "
"; echo "
"; -echo 'El estado del modulo del cluster '.clusters_get_name($id_cluster).' es '.modules_get_agentmodule_last_status(40); +echo 'El estado del modulo del cluster '.clusters_get_name($id_cluster).' es '.agents_get_status(40); ?> \ No newline at end of file diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 554f576192..27dbfea739 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -269,8 +269,6 @@ INSERT INTO `ttipo_modulo` VALUES (31,'web_proc',9,'Remote HTTP module to check server response','mod_web_proc.png'), (32,'web_content_data',9,'Remote HTTP module to retrieve numeric data','mod_web_data.png'), (33,'web_content_string',9,'Remote HTTP module to retrieve string data','mod_web_data.png'), -(34,'cluster_proc',69,'Boolean cluster module','mod_cluster_proc.png'), -(35,'cluster_data',69,'Numeric cluster module','mod_cluster_data.png'), (100,'keep_alive',-1,'KeepAlive','mod_keepalive.png'); --