Skip to content

Commit

Permalink
Add 'vcpus', 'memory' and 'disk' properties to Netbox Virtual Machines
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonfelipesp committed Jul 24, 2024
1 parent b3c52af commit db99672
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions netbox_proxbox/backend/routes/proxbox/clusters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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),
})
)

Expand Down

0 comments on commit db99672

Please sign in to comment.