2009-03-17 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/manage_config.php: Select dependant modules when an alert is selected. * include/functions_agents.php: Copy selected alerts on process_manage_config(). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1540 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
14b9664803
commit
a040a2a621
|
@ -1,3 +1,11 @@
|
||||||
|
2009-03-17 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
|
* godmode/agentes/manage_config.php: Select dependant modules when an
|
||||||
|
alert is selected.
|
||||||
|
|
||||||
|
* include/functions_agents.php: Copy selected alerts on
|
||||||
|
process_manage_config().
|
||||||
|
|
||||||
2009-03-16 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
2009-03-16 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||||
|
|
||||||
* general/logoff.php: Cleaned up invalid html
|
* general/logoff.php: Cleaned up invalid html
|
||||||
|
@ -16,7 +24,7 @@
|
||||||
|
|
||||||
* include/help/en/help_planned_downtime.php,
|
* include/help/en/help_planned_downtime.php,
|
||||||
include/help/es/help_planned_downtime.php: Added more information
|
include/help/es/help_planned_downtime.php: Added more information
|
||||||
about the scheduled downtime.
|
about the scheduled downtime.
|
||||||
|
|
||||||
2009-03-16 Esteban Sanchez <estebans@artica.es>
|
2009-03-16 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ require_once ('include/functions_agents.php');
|
||||||
require_once ('include/functions_alerts.php');
|
require_once ('include/functions_alerts.php');
|
||||||
require_once ('include/functions_modules.php');
|
require_once ('include/functions_modules.php');
|
||||||
|
|
||||||
echo '<h2>'.__('Agent configuration'). ' » '. __('Configuration Management').'</h2>';
|
echo '<h3>'.__('Configuration Management').'</h3>';
|
||||||
|
|
||||||
$source_id_group = (int) get_parameter ('source_id_group');
|
$source_id_group = (int) get_parameter ('source_id_group');
|
||||||
$source_id_agent = (int) get_parameter ('source_id_agent');
|
$source_id_agent = (int) get_parameter ('source_id_agent');
|
||||||
|
@ -69,7 +69,7 @@ $table->data[0][2] .= '</span>';
|
||||||
$table->data[0][3] = print_select (get_group_agents ($source_id_group, false, "none"),
|
$table->data[0][3] = print_select (get_group_agents ($source_id_group, false, "none"),
|
||||||
'source_id_agent', $source_id_agent, false, __('Select'), 0, true);
|
'source_id_agent', $source_id_agent, false, __('Select'), 0, true);
|
||||||
|
|
||||||
echo '<form id="manage_config_form" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/manage_config">';
|
echo '<form id="manage_config_form" method="post">';
|
||||||
|
|
||||||
echo '<fieldset id="fieldset_source">';
|
echo '<fieldset id="fieldset_source">';
|
||||||
echo '<legend><span>'.__('Source');
|
echo '<legend><span>'.__('Source');
|
||||||
|
@ -167,6 +167,7 @@ require_jquery_file ('pandora.controls');
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/* <![CDATA[ */
|
/* <![CDATA[ */
|
||||||
|
var module_alerts;
|
||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
$("#source_id_group").pandoraSelectGroup ({
|
$("#source_id_group").pandoraSelectGroup ({
|
||||||
agentSelect: "select#source_id_agent",
|
agentSelect: "select#source_id_agent",
|
||||||
|
@ -224,6 +225,7 @@ $(document).ready (function () {
|
||||||
"id_agent" : id_agent
|
"id_agent" : id_agent
|
||||||
},
|
},
|
||||||
function (data, status) {
|
function (data, status) {
|
||||||
|
module_alerts = Array ();
|
||||||
if (! data) {
|
if (! data) {
|
||||||
no_alerts = true;
|
no_alerts = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -236,6 +238,7 @@ $(document).ready (function () {
|
||||||
.append (module_name)
|
.append (module_name)
|
||||||
.append (")");
|
.append (")");
|
||||||
$("#target_alerts").append (option);
|
$("#target_alerts").append (option);
|
||||||
|
module_alerts[val["id"]] = val["id_agent_module"];
|
||||||
});
|
});
|
||||||
no_alerts = false;
|
no_alerts = false;
|
||||||
}
|
}
|
||||||
|
@ -279,6 +282,14 @@ $(document).ready (function () {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#target_alerts").change (function () {
|
||||||
|
jQuery.each ($(this).fieldValue (), function () {
|
||||||
|
if (module_alerts[this] != undefined)
|
||||||
|
$("#target_modules option[value="+module_alerts[this]+"]")
|
||||||
|
.attr ("selected", "selected");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$("#manage_config_form").submit (function () {
|
$("#manage_config_form").submit (function () {
|
||||||
$("h3:not([id=message])").remove ();
|
$("h3:not([id=message])").remove ();
|
||||||
if ($("#source_id_agent").attr ("value") == 0) {
|
if ($("#source_id_agent").attr ("value") == 0) {
|
||||||
|
|
|
@ -127,15 +127,16 @@ function get_agent_alerts ($id_agent, $filter = false, $options = false) {
|
||||||
/**
|
/**
|
||||||
* Copy the agents config from one agent to the other
|
* Copy the agents config from one agent to the other
|
||||||
*
|
*
|
||||||
* @param int $source_id_agent Agent id
|
* @param int Agent id
|
||||||
* @param mixed $destiny_id_agents Agent id or id's (array) to copy to
|
* @param mixed Agent id or id's (array) to copy to
|
||||||
* @param bool $modules Whether to copy modules as well (defaults to get_parameter ('copy_modules'))
|
* @param bool Whether to copy modules as well (defaults to $_REQUEST['copy_modules'])
|
||||||
* @param bool $alerts Whether to copy alerts as well
|
* @param bool Whether to copy alerts as well
|
||||||
* @param array $target_modules Which modules to copy
|
* @param array Which modules to copy.
|
||||||
|
* @param array Which alerts to copy. Only will be used if target_modules is empty.
|
||||||
*
|
*
|
||||||
* @return bool True in case of good, false in case of bad
|
* @return bool True in case of good, false in case of bad
|
||||||
*/
|
*/
|
||||||
function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modules = false, $copy_alerts = false, $target_modules = false) {
|
function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modules = false, $copy_alerts = false, $target_modules = false, $target_alerts = false) {
|
||||||
if (empty ($source_id_agent)) {
|
if (empty ($source_id_agent)) {
|
||||||
echo '<h3 class="error">'.__('No source agent to copy').'</h3>';
|
echo '<h3 class="error">'.__('No source agent to copy').'</h3>';
|
||||||
return false;
|
return false;
|
||||||
|
@ -149,46 +150,68 @@ function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modu
|
||||||
if ($copy_modules == false) {
|
if ($copy_modules == false) {
|
||||||
$copy_modules = (bool) get_parameter ('copy_modules', $copy_modules);
|
$copy_modules = (bool) get_parameter ('copy_modules', $copy_modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($copy_alerts == false) {
|
if ($copy_alerts == false) {
|
||||||
$copy_alerts = (bool) get_parameter ('copy_alerts', $copy_alerts);
|
$copy_alerts = (bool) get_parameter ('copy_alerts', $copy_alerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($copy_modules) {
|
if (! $copy_modules && ! $copy_alerts)
|
||||||
if (empty ($target_modules)) {
|
return;
|
||||||
$target_modules = (array) get_parameter ('target_modules', $target_modules);
|
|
||||||
}
|
if (empty ($target_modules)) {
|
||||||
|
$target_modules = (array) get_parameter ('target_modules', array ());
|
||||||
if (empty ($target_modules)) {
|
}
|
||||||
|
|
||||||
|
if (empty ($target_alerts)) {
|
||||||
|
$target_alerts = (array) get_parameter ('target_alerts', array ());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty ($target_modules)) {
|
||||||
|
if (! $copy_alerts) {
|
||||||
echo '<h3 class="error">'.__('No modules have been selected').'</h3>';
|
echo '<h3 class="error">'.__('No modules have been selected').'</h3>';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$target_modules = array ();
|
||||||
|
|
||||||
process_sql ('SET AUTOCOMMIT = 0');
|
foreach ($target_alerts as $id_alert) {
|
||||||
process_sql ('START TRANSACTION');
|
$alert = get_alert_agent_module ($id_alert);
|
||||||
$error = false;
|
if ($alert === false)
|
||||||
$alerts = array ();
|
continue;
|
||||||
foreach ($destiny_id_agents as $id_destiny_agent) {
|
/* Check if some alerts which doesn't belong to the agent was given */
|
||||||
foreach ($target_modules as $id_agent_module) {
|
if (get_agentmodule_agent ($alert['id_agent_module']) != $source_id_agent)
|
||||||
$result = copy_agent_module_to_agent ($id_agent_module,
|
continue;
|
||||||
$id_destiny_agent);
|
array_push ($target_modules, $alert['id_agent_module']);
|
||||||
|
}
|
||||||
if ($result === false) {
|
}
|
||||||
$error = true;
|
|
||||||
break;
|
process_sql ('SET AUTOCOMMIT = 0');
|
||||||
}
|
process_sql ('START TRANSACTION');
|
||||||
|
$error = false;
|
||||||
$id_destiny_module = $result;
|
|
||||||
if (! isset ($alerts[$id_agent_module]))
|
foreach ($destiny_id_agents as $id_destiny_agent) {
|
||||||
$alerts[$id_agent_module] = get_alerts_agent_module ($id_agent_module,
|
foreach ($target_modules as $id_agent_module) {
|
||||||
true);
|
$result = copy_agent_module_to_agent ($id_agent_module,
|
||||||
|
$id_destiny_agent);
|
||||||
if ($alerts[$id_agent_module] === false)
|
|
||||||
continue;
|
if ($result === false) {
|
||||||
|
$error = true;
|
||||||
if (! $copy_alerts)
|
break;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
foreach ($alerts[$id_agent_module] as $alert) {
|
$id_destiny_module = $result;
|
||||||
|
|
||||||
|
if (! $copy_alerts)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* If the alerts were given, copy afterwards. Otherwise, all the
|
||||||
|
alerts for the module will be copied */
|
||||||
|
if (! empty ($target_alerts)) {
|
||||||
|
foreach ($target_alerts as $id_alert) {
|
||||||
|
$alert = get_alert_agent_module ($id_alert);
|
||||||
|
if ($alert === false)
|
||||||
|
continue;
|
||||||
|
if ($alert['id_agent_module'] != $id_agent_module)
|
||||||
|
continue;
|
||||||
$result = copy_alert_agent_module_to_agent_module ($alert['id'],
|
$result = copy_alert_agent_module_to_agent_module ($alert['id'],
|
||||||
$id_destiny_module);
|
$id_destiny_module);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
@ -196,20 +219,34 @@ function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modu
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$alerts = get_alerts_agent_module ($id_agent_module, true);
|
||||||
|
|
||||||
|
if ($alerts === false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach ($alerts as $alert) {
|
||||||
|
$result = copy_alert_agent_module_to_agent_module ($alert['id'],
|
||||||
|
$id_destiny_module);
|
||||||
|
if ($result === false) {
|
||||||
|
$error = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($error)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if ($error)
|
||||||
if ($error) {
|
break;
|
||||||
echo '<h3 class="error">'.__('There was an error copying the agent configuration, the copy has been cancelled').'</h3>';
|
|
||||||
process_sql ('ROLLBACK');
|
|
||||||
} else {
|
|
||||||
echo '<h3 class="suc">'.__('Successfully copied').'</h3>';
|
|
||||||
process_sql ('COMMIT');
|
|
||||||
}
|
|
||||||
process_sql ('SET AUTOCOMMIT = 1');
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
|
echo '<h3 class="error">'.__('There was an error copying the agent configuration, the copy has been cancelled').'</h3>';
|
||||||
|
process_sql ('ROLLBACK');
|
||||||
|
} else {
|
||||||
|
echo '<h3 class="suc">'.__('Successfully copied').'</h3>';
|
||||||
|
process_sql ('COMMIT');
|
||||||
|
}
|
||||||
|
process_sql ('SET AUTOCOMMIT = 1');
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue