Add proxmox hostname to vps name

This commit is contained in:
Mario
2024-08-04 23:05:56 +02:00
parent 1da7870720
commit 00724077e1
2 changed files with 3 additions and 1 deletions

View File

@@ -75,7 +75,9 @@ class VPSServer(models.Model):
config_data = config_response.json()['data'] config_data = config_response.json()['data']
# Update fields # Update fields
self.name = config_data.get('name', f"{vm_type}-{vm_id}") hostname = config_data.get('hostname', '')
vm_name = f"{vm_type}-{vm_id}"
self.name = f"{vm_name} ({hostname})" if hostname else vm_name
self.cpu = status_data.get('cpus', 0) self.cpu = status_data.get('cpus', 0)
self.ram = status_data.get('maxmem', 0) / (1024 * 1024 * 1024) # Convert to GB self.ram = status_data.get('maxmem', 0) / (1024 * 1024 * 1024) # Convert to GB
self.storage = status_data.get('maxdisk', 0) / (1024 * 1024 * 1024) # Convert to GB self.storage = status_data.get('maxdisk', 0) / (1024 * 1024 * 1024) # Convert to GB