From ddbb06a967f8ea792846ec4b44d2d442dd2a60b2 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 17 Sep 2021 11:46:59 +0200 Subject: [PATCH] Merged policies conf fixer tool --- .../tools/merged_policies_conf_fixer.php | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 pandora_console/tools/merged_policies_conf_fixer.php diff --git a/pandora_console/tools/merged_policies_conf_fixer.php b/pandora_console/tools/merged_policies_conf_fixer.php new file mode 100644 index 0000000000..3198b663d7 --- /dev/null +++ b/pandora_console/tools/merged_policies_conf_fixer.php @@ -0,0 +1,62 @@ +hasRemoteCapabilities() === true) { + $agent_policies = $agent->getConfPolicies(); + + $oldIds = []; + $newIds = []; + foreach ($agent_policies as $oldId => $name) { + $oldIds[] = $oldId; + $newIds[] = $policies[io_safe_input($name)]; + } + + $res_update_con_policy = $agent->updatePolicyIds( + $oldIds, + $newIds + ); + if ($res_update_con_policy === false) { + echo 'Failed ['.$agent->name()."]\n"; + } else { + echo 'Agent '.io_safe_output($agent->alias())." updated successfully\n"; + } + } else { + echo 'Agent '.io_safe_output($agent->alias())." skipped\n"; + } + } catch (Exception $e) { + echo $e->getMessage()."\n"; + } +}