Merge branch '2294-Requisitos-API-cluster-2' into 'develop'
Add cluster and API get functions - #2294 See merge request artica/pandorafms!1495
This commit is contained in:
commit
900f6ba609
|
@ -83,9 +83,6 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
|
|||
if (empty ($id_group) && (int)$id_group != 0)
|
||||
return false;
|
||||
|
||||
if (empty ($ip_address))
|
||||
return false;
|
||||
|
||||
// Check interval greater than zero
|
||||
if ($interval < 0)
|
||||
$interval = false;
|
||||
|
@ -97,16 +94,20 @@ function agents_create_agent ($name, $id_group, $interval, $ip_address, $values
|
|||
$values['nombre'] = $name;
|
||||
$values['id_grupo'] = $id_group;
|
||||
$values['intervalo'] = $interval;
|
||||
$values['direccion'] = $ip_address;
|
||||
|
||||
if (!empty ($ip_address)){
|
||||
$values['direccion'] = $ip_address;
|
||||
}
|
||||
|
||||
$id_agent = db_process_sql_insert ('tagente', $values);
|
||||
if ($id_agent === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create address for this agent in taddress
|
||||
agents_add_address ($id_agent, $ip_address);
|
||||
|
||||
if (!empty ($ip_address)){
|
||||
agents_add_address ($id_agent, $ip_address);
|
||||
}
|
||||
|
||||
db_pandora_audit ("Agent management", "New agent '$name' created");
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ enterprise_include_once ('include/functions_local_components.php');
|
|||
enterprise_include_once ('include/functions_events.php');
|
||||
enterprise_include_once ('include/functions_agents.php');
|
||||
enterprise_include_once ('include/functions_modules.php');
|
||||
enterprise_include_once ('include/functions_clusters.php');
|
||||
|
||||
/**
|
||||
* Parse the "other" parameter.
|
||||
|
@ -10636,4 +10637,94 @@ function api_get_cluster_status($id_cluster, $trash1, $trash2, $returnType) {
|
|||
returnData($returnType, $data);
|
||||
}
|
||||
|
||||
function api_get_cluster_id_by_name($cluster_name, $trash1, $trash2, $returnType) {
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cluster_name = io_safe_output($cluster_name);
|
||||
|
||||
$value = cluster_get_id_by_name($cluster_name);
|
||||
|
||||
if ($value === false) {
|
||||
returnError('id_not_found', $returnType);
|
||||
}
|
||||
|
||||
$data = array('type' => 'string', 'data' => $value);
|
||||
|
||||
returnData($returnType, $data);
|
||||
}
|
||||
|
||||
function api_get_agents_id_name_by_cluster_id($cluster_id, $trash1, $trash2, $returnType) {
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$all_agents = cluster_get_agents_id_name_by_cluster_id($cluster_id);
|
||||
|
||||
if (count($all_agents) > 0 and $all_agents !== false) {
|
||||
$data = array('type' => 'array', 'data' => $all_agents);
|
||||
|
||||
returnData('json', $data);
|
||||
}
|
||||
else {
|
||||
returnError('error_agents', 'No agents retrieved.');
|
||||
}
|
||||
}
|
||||
|
||||
function api_get_agents_id_name_by_cluster_name($cluster_name, $trash1, $trash2, $returnType) {
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$all_agents = cluster_get_agents_id_name_by_cluster_name($cluster_name);
|
||||
|
||||
if (count($all_agents) > 0 and $all_agents !== false) {
|
||||
$data = array('type' => 'array', 'data' => $all_agents);
|
||||
|
||||
returnData('json', $data);
|
||||
}
|
||||
else {
|
||||
returnError('error_agents', 'No agents retrieved.');
|
||||
}
|
||||
}
|
||||
|
||||
function api_get_modules_id_name_by_cluster_id ($cluster_id){
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$all_modules = cluster_get_modules_id_name_by_cluster_id($cluster_id);
|
||||
|
||||
if (count($all_modules) > 0 and $all_modules !== false) {
|
||||
$data = array('type' => 'array', 'data' => $all_modules);
|
||||
|
||||
returnData('json', $data);
|
||||
}
|
||||
else {
|
||||
returnError('error_agent_modules', 'No modules retrieved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function api_get_modules_id_name_by_cluster_name ($cluster_name){
|
||||
if (defined ('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$all_modules = cluster_get_modules_id_name_by_cluster_name($cluster_name);
|
||||
|
||||
if (count($all_modules) > 0 and $all_modules !== false) {
|
||||
$data = array('type' => 'array', 'data' => $all_modules);
|
||||
|
||||
returnData('json', $data);
|
||||
}
|
||||
else {
|
||||
returnError('error_agent_modules', 'No modules retrieved.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue