Skip to content

Commit

Permalink
enhancement(#4843): Fixing white spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-akim committed Mar 19, 2024
1 parent 33bc706 commit a0ef700
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion deployability/modules/testing/tests/helpers/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def uninstall_agent(inventory_path, wazuh_version=None, wazuh_revision=None) ->
"/usr/bin/dscl . -delete '/Groups/wazuh'",
"/usr/sbin/pkgutil --forget com.wazuh.pkg.wazuh-agent"
])
print(commands)

Executor.execute_commands(inventory_path, commands)


Expand All @@ -165,8 +165,10 @@ def get_agents_information(wazuh_api: WazuhAPI) -> list:
List: Information about agents.
"""
response = requests.get(f"{wazuh_api.api_url}/agents", headers=wazuh_api.headers, verify=False)

return eval(response.text)['data']['affected_items']


def get_agent_status(wazuh_api: WazuhAPI, agent_name) -> str:
"""
Function to get the status of an agent given its name.
Expand All @@ -182,6 +184,7 @@ def get_agent_status(wazuh_api: WazuhAPI, agent_name) -> str:
for agent in eval(response.text)['data']['affected_items']:
if agent.get('name') == agent_name:
return agent.get('status')

return None


Expand All @@ -198,7 +201,9 @@ def get_agent_ip_status_and_name_by_id(wazuh_api: WazuhAPI, identifier):
agents_information = wazuh_api.get_agents_information()
for element in agents_information:
if element['id'] == identifier:

return [element['ip'], element['name'], element['status']]

return [None, None, None]


Expand All @@ -214,6 +219,7 @@ def add_agent_to_manager(wazuh_api: WazuhAPI, name, ip) -> str:
str: Response text.
"""
response = requests.post(f"{wazuh_api.api_url}/agents", json={"name": name ,"ip": ip}, headers=wazuh_api.headers, verify=False)

return response.text


Expand All @@ -225,6 +231,7 @@ def restart_agents(wazuh_api: WazuhAPI) -> str:
str: Response text.
"""
response = requests.put(f"{wazuh_api.api_url}/agents/restart", headers=wazuh_api.headers, verify=False)

return response.text


Expand All @@ -236,4 +243,5 @@ def agent_status_report(wazuh_api: WazuhAPI) -> dict:
Dict: Agent status report.
"""
response = requests.get(f"{wazuh_api.api_url}/agents/summary/status", headers=wazuh_api.headers, verify=False)

return eval(response.text)['data']

0 comments on commit a0ef700

Please sign in to comment.