From 334ce0aefdc1aa2bb3f6e757c02c23a9f25c7e51 Mon Sep 17 00:00:00 2001 From: Shailaja Date: Fri, 5 Jul 2024 18:54:14 +0530 Subject: [PATCH] refractor --- agent.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/agent.py b/agent.py index 26751ff..37ded8b 100644 --- a/agent.py +++ b/agent.py @@ -273,8 +273,8 @@ class ServerData: return os_entry['id'] return 1 - if 'NAME' in os_info and 'VERSION' in os_info: - current_os = f"{os_info.get('NAME', 'Unknown')} {os_info.get('VERSION', '').strip()}".strip().lower() + if 'ID' in os_info and 'VERSION_ID' in os_info: + current_os = f"{os_info.get('NAME', 'Unknown')} {os_info.get('VERSION', '').strip()}".strip() else: current_os = f"{os_info.get('os_name', 'Unknown')} {os_info.get('productversion', '').strip()}".strip().lower() @@ -299,9 +299,8 @@ class ServerData: - def create_post_data(self): + def create_post_data(self, os_list): ram, disk = self.get_ram_and_disk() - os_list = self.get_os_list() post_data = { "server_type": 1, "os_id": self.get_os_id(os_list), @@ -468,7 +467,7 @@ class ServerManager: return self.create_note(note_data) def get_os_list(self): - os_list = self.send_request('GET', '/api/v1/os') + os_list = self.send_request('GET', '/api/os') logging.info("OS list fetched successfully") if os_list else logging.error("Failed to fetch OS list") return os_list or []