From db996725df0476e1d590e652a6be5b76c963e9ee Mon Sep 17 00:00:00 2001 From: Emerson Felipe Date: Wed, 24 Jul 2024 18:57:45 +0000 Subject: [PATCH] Add 'vcpus', 'memory' and 'disk' properties to Netbox Virtual Machines --- .../backend/routes/proxbox/clusters/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/netbox_proxbox/backend/routes/proxbox/clusters/__init__.py b/netbox_proxbox/backend/routes/proxbox/clusters/__init__.py index 710c673..1aaf429 100644 --- a/netbox_proxbox/backend/routes/proxbox/clusters/__init__.py +++ b/netbox_proxbox/backend/routes/proxbox/clusters/__init__.py @@ -164,7 +164,11 @@ class VirtualMachineStatus(Enum): devices = {} clusters = {} for vm in virtual_machines: - vm_node = vm.get("node") + + print(f"\n[VM] {vm}\n") + + vm_node: str = vm.get("node") + print(f"vm_node: {vm_node} | {type(vm_node)}") """ Get Device from Netbox based on Proxmox Node Name only if it's not already in the devices dict @@ -174,6 +178,9 @@ class VirtualMachineStatus(Enum): devices[vm_node] = await Device(nb = nb).get(name = vm.get("node")) device = devices[vm_node] + print(f"devices[vm_node]: {devices[vm_node]} | {device}") + print(f"DEVICE TEST: {device}") + """ Get Cluster from Netbox based on Cluster Name only if it's not already in the devices dict @@ -188,8 +195,11 @@ class VirtualMachineStatus(Enum): await VirtualMachine(nb = nb).post(data = { "name": vm.get("name"), "cluster": cluster.id, - "device": device.id, + "device": device, "status": VirtualMachineStatus(vm.get("status")).name, + "vcpus": int(vm.get("maxcpu", 0)), + "memory": int(int(vm.get("maxmem", 0)) / 1000000), + "disk": int(int(vm.get("maxdisk", 0)) / 1000000000), }) )