Merge pull request #56 from q1x/inventory-zero-values

Allow for source inventory fields to have a value of zero
This commit is contained in:
Twan K 2024-05-22 10:36:11 +02:00 committed by GitHub
commit 60140b4b74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -416,7 +416,10 @@ class NetworkDevice():
for item in field_list: for item in field_list:
value = value[item] if value else None value = value[item] if value else None
# Check if the result is usable and expected # 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) self.inventory[zbx_inv_field] = str(value)
elif not value: elif not value:
# empty value should just be an empty string for API compatibility # empty value should just be an empty string for API compatibility