File tree 3 files changed +23
-1
lines changed
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -374,6 +374,14 @@ def __init__(self):
374
374
""" ,
375
375
config_example = "VB_LAST_BACKUP, VB_LAST_BACKUP2"
376
376
),
377
+ ConfigOption ("vm_disk_and_ram_in_decimal" ,
378
+ bool ,
379
+ description = """In NetBox version 4.1.0 and newer the VM disk and RAM values are displayed
380
+ in power of 10 instead of power of 2. If this values is set to true 4GB of RAM will be
381
+ set to a value of 4000 megabyte. If set to false 4GB of RAM will be reported as 4096MB.
382
+ The same behavior also applies for VM disk sizes.""" ,
383
+ default_value = True
384
+ ),
377
385
378
386
# removed settings
379
387
ConfigOption ("netbox_host_device_role" ,
Original file line number Diff line number Diff line change @@ -2168,11 +2168,17 @@ def add_virtual_machine(self, obj):
2168
2168
# get vCenter tags
2169
2169
vm_tags .extend (self .collect_object_tags (obj ))
2170
2170
2171
+ # vm memory depending on setting
2172
+ vm_memory = grab (obj , "config.hardware.memoryMB" , fallback = 0 )
2173
+
2174
+ if self .settings .vm_disk_and_ram_in_decimal is True :
2175
+ vm_memory = int (vm_memory / 1024 * 1000 )
2176
+
2171
2177
vm_data = {
2172
2178
"name" : name ,
2173
2179
"cluster" : nb_cluster_object ,
2174
2180
"status" : status ,
2175
- "memory" : grab ( obj , "config.hardware.memoryMB" ) ,
2181
+ "memory" : vm_memory ,
2176
2182
"vcpus" : grab (obj , "config.hardware.numCPU" )
2177
2183
}
2178
2184
@@ -2270,6 +2276,8 @@ def add_virtual_machine(self, obj):
2270
2276
# since NetBox 4.1.0 disk size is represented in MB
2271
2277
else :
2272
2278
disk_size = int (disk_size_in_kb / 1024 )
2279
+ if self .settings .vm_disk_and_ram_in_decimal :
2280
+ disk_size = int (disk_size / 1024 * 1000 )
2273
2281
2274
2282
disk_data .append ({
2275
2283
"name" : grab (vm_device , "deviceInfo.label" ),
Original file line number Diff line number Diff line change @@ -378,6 +378,12 @@ password = super-secret
378
378
; Any custom attribute with a matching attribute key will be excluded from sync.
379
379
; custom_attribute_exclude = VB_LAST_BACKUP, VB_LAST_BACKUP2
380
380
381
+ ; In NetBox version 4.1.0 and newer the VM disk and RAM values are displayed in power of
382
+ ; 10 instead of power of 2. If this values is set to true 4GB of RAM will be set to a
383
+ ; value of 4000 megabyte. If set to false 4GB of RAM will be reported as 4096MB. The same
384
+ ; behavior also applies for VM disk sizes.
385
+ ; vm_disk_and_ram_in_decimal = True
386
+
381
387
[source/my-redfish-example]
382
388
383
389
; Defines if this source is enabled or not
You can’t perform that action at this time.
0 commit comments