Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions aquilon/netbox2aquilon.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ def _netbox_copy_vm_disks(self, virtual_machine):
if virtual_disks:
boot = True
for disk in virtual_disks:
# Netbox stores virtual disk size in MB, Aquilon needs it in GB
# For netbox 1000 MB = 1GB
virtual_disk_gb = round(disk.size / 1000) # to nearest GB
cmd = [
'add_disk',
'--machine', f'{virtual_machine.aq_machine_name}',
'--disk', f'{disk.name}',
'--controller', 'sata',
'--size', f'{disk.size}',
'--size', f'{virtual_disk_gb}',
]
if boot:
cmd.append('--boot')
Expand All @@ -154,12 +157,14 @@ def _netbox_copy_vm_disks(self, virtual_machine):
cmd += ['--comments', f'"{disk.description}"']
cmds.append(cmd)
else:
# Netbox stores disk size in MB, Aquilon needs it in GB
disk_gb = round(virtual_machine.disk / 1000) # to nearest GB
cmds.append([
'add_disk',
'--machine', f'{virtual_machine.aq_machine_name}',
'--disk', 'sda',
'--controller', 'sata',
'--size', f'{virtual_machine.disk}',
'--size', f'{disk_gb}',
'--boot',
])

Expand Down
6 changes: 3 additions & 3 deletions aquilon/testdata/disks_virtual.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"name": "sda",
"description": "",
"size": 40,
"size": 40000,
"tags": [],
"custom_fields": {},
"created": "2025-06-02T13:43:40.552134Z",
Expand All @@ -29,7 +29,7 @@
},
"name": "sdb",
"description": "",
"size": 100,
"size": 100000,
"tags": [],
"custom_fields": {},
"created": "2025-06-02T13:43:49.494852Z",
Expand All @@ -47,7 +47,7 @@
},
"name": "sdc",
"description": "/opt",
"size": 100,
"size": 100000,
"tags": [],
"custom_fields": {},
"created": "2025-06-02T13:44:01.016349Z",
Expand Down
Loading