File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -2261,15 +2261,19 @@ def add_virtual_machine(self, obj):
2261
2261
if grab (vm_device_backing , "fileName" ) is not None :
2262
2262
vm_device_description .append (grab (vm_device_backing , "fileName" ))
2263
2263
2264
- disk_size = grab (vm_device , "capacityInKB" , fallback = 0 )
2265
- disk_size_in_gb = int (disk_size / 1024 / 1024 )
2266
- if disk_size_in_gb < 1 :
2267
- vm_device_description .append (f"Size: { int (disk_size / 1024 )} MB" )
2268
- disk_size_in_gb = 1
2264
+ disk_size_in_kb = grab (vm_device , "capacityInKB" , fallback = 0 )
2265
+ if version .parse (self .inventory .netbox_api_version ) < version .parse ("4.1.0" ):
2266
+ disk_size = int (disk_size_in_kb / 1024 / 1024 )
2267
+ if disk_size < 1 :
2268
+ vm_device_description .append (f"Size: { int (disk_size_in_kb / 1024 )} MB" )
2269
+ disk_size = 1
2270
+ # since NetBox 4.1.0 disk size is represented in MB
2271
+ else :
2272
+ disk_size = int (disk_size_in_kb / 1024 )
2269
2273
2270
2274
disk_data .append ({
2271
2275
"name" : grab (vm_device , "deviceInfo.label" ),
2272
- "size" : disk_size_in_gb ,
2276
+ "size" : disk_size ,
2273
2277
"description" : " / " .join (vm_device_description )
2274
2278
})
2275
2279
You can’t perform that action at this time.
0 commit comments