From 7258188491d814791015a663c1396e7353d88417 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 11 Dec 2023 11:01:53 +0100 Subject: [PATCH] remove agents bulk operation pandora_enterprise#12299 --- .../godmode/massive/massive_delete_agents.php | 16 ++++++++++------ pandora_console/include/functions_api.php | 10 +++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index 1dc6397cc6..88d7e54ccb 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -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], diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 8f5fb66f54..7a06156fb4 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -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; }