2012-07-30 Sergio Martin <sergio.martin@artica.es>

* include/functions_api.php: Added to API the actions:
	add, update and delete module in agent config file



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6831 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-07-31 10:24:01 +00:00
parent 27c81e2ba1
commit 3665207a0a
2 changed files with 109 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2012-07-30 Sergio Martin <sergio.martin@artica.es>
* include/functions_api.php: Added to API the actions:
add, update and delete module in agent config file
2012-07-30 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/module_manager_editor_plugin.php,
@ -79,6 +84,7 @@
* operation/search_modules.php: fixed the search when the modules
haven't inicialiced.
>>>>>>> .r6830
2012-07-26 Sergio Martin <sergio.martin@artica.es>
* include/functions_html.php: Change the sort function

View File

@ -3194,6 +3194,109 @@ function api_set_update_plugin_module_policy($id, $thrash1, $other, $thrash3) {
returnData('string', array('type' => 'string', 'data' => __('Plugin policy module updated.')));
}
/**
* Add module data configuration into agent configuration file
*
* @param string $id_agent Id of the agent
* @param string $module_name
* @param array $configuration_data is an array. The data in it is the new configuration data of the module
* @param $thrash3 Don't use
*
* Call example:
*
* api.php?op=set&op2=add_module_in_conf&user=admin&pass=pandora&id=9043&id2=example_name&other=bW9kdWxlX2JlZ2luCm1vZHVsZV9uYW1lIGV4YW1wbGVfbmFtZQptb2R1bGVfdHlwZSBnZW5lcmljX2RhdGEKbW9kdWxlX2V4ZWMgZWNobyAxOwptb2R1bGVfZW5k
*
* @return string success or error message
*/
function api_set_add_module_in_conf($id_agent, $module_name, $configuration_data, $thrash3) {
$new_configuration_data = base64_decode($configuration_data['data']);
// Check if exist a current module with the same name in the conf file
$old_configuration_data = config_agents_get_module_from_conf($id_agent, io_safe_output($module_name));
// If exists a module with same name, abort
if(!empty($old_configuration_data)) {
echo "Already exist";
exit;
}
$result = config_agents_add_module_in_conf($id_agent, $new_configuration_data);
if($result) {
returnData('string', array('type' => 'string', 'data' => 'Successfully added module to conf.'));
}
else {
returnError('error_adding_module_conf', 'Error adding module to conf file.');
}
}
/**
* Delete module data configuration from agent configuration file
*
* @param string $id_agent Id of the agent
* @param string $module_name
* @param $thrash2 Don't use
* @param $thrash3 Don't use
*
* Call example:
*
* api.php?op=set&op2=delete_module_in_conf&user=admin&pass=pandora&id=9043&id2=example_name
*
* @return string success or error message
*/
function api_set_delete_module_in_conf($id_agent, $module_name, $thrash2, $thrash3) {
$result = config_agents_delete_module_in_conf($id_agent, $module_name);
if($result) {
returnData('string', array('type' => 'string', 'data' => 'Successfully deleted module from conf.'));
}
else {
returnError('error_deleting_module_conf', 'Error deleting module from conf file.');
}
}
/**
* Update module data configuration from agent configuration file
*
* @param string $id_agent Id of the agent
* @param string $module_name
* @param array $configuration_data is an array. The data in it is the new configuration data of the module
* @param $thrash3 Don't use
*
* Call example:
*
* api.php?op=set&op2=update_module_in_conf&user=admin&pass=pandora&id=9043&id2=example_name&other=bW9kdWxlX2JlZ2luCm1vZHVsZV9uYW1lIGV4YW1wbGVfbmFtZQptb2R1bGVfdHlwZSBnZW5lcmljX2RhdGEKbW9kdWxlX2V4ZWMgZWNobyAxOwptb2R1bGVfZW5k
*
* @return string success or error message
*/
function api_set_update_module_in_conf($id_agent, $module_name, $configuration_data_serialized, $thrash3) {
$new_configuration_data = base64_decode($configuration_data_serialized['data']);
// Get current configuration
$old_configuration_data = config_agents_get_module_from_conf($id_agent, io_safe_output($module_name));
// If not exists
if(empty($old_configuration_data)) {
echo "Module doesnt exist";
exit;
}
// If current configuration and new configuration are equal, abort
if($new_configuration_data == $old_configuration_data) {
echo "No change";
exit;
}
$result = config_agents_update_module_in_conf($id_agent, $old_configuration_data, $new_configuration_data);
if($result) {
returnData('string', array('type' => 'string', 'data' => 'Successfully updated module in conf.'));
}
else {
returnError('error_editing_module_conf', 'Error editing module in conf file.');
}
/**
* Add SNMP module to policy. And return id from new module.
*