Update netbox_zabbix_sync.py

Minor bug fix for float or int zero values in inventory fields
This commit is contained in:
Raymond Kuiper 2024-04-12 10:38:43 +02:00 committed by GitHub
parent 3e638c6f78
commit e9143eb24c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -410,7 +410,10 @@ class NetworkDevice():
for item in field_list:
value = value[item] if value else None
# Check if the result is usable and expected
if value and isinstance(value, int | float | str ):
# We want to apply any int or float 0 values,
# even if python thinks those are empty.
if ((value and isinstance(value, int | float | str )) or
(isinstance(value, int | float) and int(value) ==0)):
self.inventory[zbx_inv_field] = str(value)
elif not value:
# empty value should just be an empty string for API compatibility