refractor

This commit is contained in:
Shailaja Kumari 2024-07-05 18:54:14 +05:30
parent 777d742d40
commit 334ce0aefd
Signed by: shailaja
GPG Key ID: 2B9455CAFBC4D75A

View File

@ -273,8 +273,8 @@ class ServerData:
return os_entry['id'] return os_entry['id']
return 1 return 1
if 'NAME' in os_info and 'VERSION' in os_info: 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().lower() current_os = f"{os_info.get('NAME', 'Unknown')} {os_info.get('VERSION', '').strip()}".strip()
else: else:
current_os = f"{os_info.get('os_name', 'Unknown')} {os_info.get('productversion', '').strip()}".strip().lower() 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() ram, disk = self.get_ram_and_disk()
os_list = self.get_os_list()
post_data = { post_data = {
"server_type": 1, "server_type": 1,
"os_id": self.get_os_id(os_list), "os_id": self.get_os_id(os_list),
@ -468,7 +467,7 @@ class ServerManager:
return self.create_note(note_data) return self.create_note(note_data)
def get_os_list(self): 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") logging.info("OS list fetched successfully") if os_list else logging.error("Failed to fetch OS list")
return os_list or [] return os_list or []