Skip to content

Commit

Permalink
Merge pull request #56 from q1x/inventory-zero-values
Browse files Browse the repository at this point in the history
Allow for source inventory fields to have a value of zero
  • Loading branch information
TheNetworkGuy authored May 22, 2024
2 parents 0b9b8a4 + e9143eb commit 60140b4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion netbox_zabbix_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,10 @@ def set_inventory(self, nbdevice):
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
Expand Down

0 comments on commit 60140b4

Please sign in to comment.