remove agents bulk operation pandora_enterprise#12299

This commit is contained in:
daniel 2023-12-11 11:01:53 +01:00
parent 071427e60b
commit 7258188491
2 changed files with 19 additions and 7 deletions

View File

@ -46,6 +46,7 @@ require_once $config['homedir'].'/include/functions_alerts.php';
require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_users.php';
require_once $config['homedir'].'/include/functions_massive_operations.php';
enterprise_include_once('include/functions_agents.php');
/**
@ -71,12 +72,15 @@ function process_manage_delete($id_agents)
$array_id = explode('|', $id_agent);
try {
$node = new Node((int) $array_id[0]);
$node->connect();
$agent = new Agent((int) $array_id[1]);
$success = $agent->delete();
$node->disconnect();
$api_call_delete = $node->callApi(
'delete_agent',
'set',
(int) $array_id[1],
null,
['2'],
null,
true
);
$success = agent_delete_from_metaconsole(
$array_id[1],

View File

@ -2266,9 +2266,12 @@ function api_set_delete_agent($id, $thrash1, $other, $returnType)
}
$agent_by_alias = false;
$agent_by_id = false;
if ($other['data'][0] === '1') {
$agent_by_alias = true;
} else if ($other['data'][0] === '2') {
$agent_by_id = true;
}
if (is_metaconsole()) {
@ -2331,7 +2334,12 @@ function api_set_delete_agent($id, $thrash1, $other, $returnType)
}
}
} else {
$idAgent = agents_get_agent_id($id, false);
if ($agent_by_id === true) {
$idAgent = $id;
} else {
$idAgent = agents_get_agent_id($id, false);
}
if (!util_api_check_agent_and_print_error($idAgent, 'string', 'AD')) {
return;
}