From b15ad7e4c9f43573259ca0d1f9a0b806acd118a2 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 9 Jun 2023 12:40:05 +0200 Subject: [PATCH] feat(#46): More changes after linter --- src/wazuh_qa_framework/system/wazuh_handler.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/wazuh_qa_framework/system/wazuh_handler.py b/src/wazuh_qa_framework/system/wazuh_handler.py index 8325c82..773f7d9 100644 --- a/src/wazuh_qa_framework/system/wazuh_handler.py +++ b/src/wazuh_qa_framework/system/wazuh_handler.py @@ -596,7 +596,6 @@ def clean_logs(self, hosts): if 'master' == host_type or 'worker' == host_type: self.truncate_file(host, f'{logs_path}/cluster.log', recreate=True, become=True, ignore_errors=False) - def clean_agents(self, agents=None): """Stop agents, remove them from manager and clean their client keys Args: @@ -604,7 +603,6 @@ def clean_agents(self, agents=None): """ pass - def restart_agents(self, agent_list): """Restart agents Args: @@ -618,8 +616,7 @@ def restart_agents(self, agent_list): else: self.run_command(agent, f"service wazuh-agent restart", become=True, ignore_errors=False) - - def remove_agents_from_manager(self, agent_list, manager=None, method='cmd', parallel=True , logs=False, + def remove_agents_from_manager(self, agent_list, manager=None, method='cmd', parallel=True, logs=False, restart=False): """Remove agents from manager @@ -631,8 +628,8 @@ def remove_agents_from_manager(self, agent_list, manager=None, method='cmd', par logs (str): Remove logs from agents. Defaults to False. restart (str): Restart agents. Defaults to False. """ - if manager is None: manager = 'manager1' - if method == 'api': parallel = False + manager = 'manager1' if manager is None else manager + parallel = False if method == 'api' else parallel # Getting agent_ids list agent_ids = self.get_agents_id(agent_list) @@ -650,8 +647,8 @@ def remove_agent_cmd(id): remove_agent_cmd(id) else: agent_string = ','.join(agent_ids) - self.make_api_call('manager1', port=55000, method='DELETE', - endpoint=f'/agents?pretty=true&older_than=0s&agents_list={agent_string}&status=all', + self.make_api_call('manager1', port=55000, method='DELETE', + endpoint=f'/agents?pretty=true&older_than=0s&agents_list={agent_string}&status=all', request_body=None, token=None, check=False) # Remove logs