diff --git a/netbox_zabbix_sync.py b/netbox_zabbix_sync.py index b6c2b80..4a58dfa 100755 --- a/netbox_zabbix_sync.py +++ b/netbox_zabbix_sync.py @@ -137,8 +137,15 @@ def main(arguments): create_journal, logger) logger.debug(f"Host {vm.name}: started operations on VM.") vm.set_hostgroup(vm_hostgroup_format,netbox_site_groups,netbox_regions) + # Check if a valid hostgroup has been found for this VM. + if not vm.hostgroup: + continue vm.set_vm_template() - vm.set_inventory(nb_vm) + # Check if a valid template has been found for this VM. + if not vm.zbx_template_names: + continue + # Temporary disable inventory sync for VM's + # vm.set_inventory(nb_vm) # Checks if device is in cleanup state if vm.status in zabbix_device_removal: @@ -183,7 +190,13 @@ def main(arguments): create_journal, logger) logger.debug(f"Host {device.name}: started operations on device.") device.set_hostgroup(hostgroup_format,netbox_site_groups,netbox_regions) + # Check if a valid hostgroup has been found for this VM. + if not device.hostgroup: + continue device.set_template(templates_config_context, templates_config_context_overrule) + # Check if a valid template has been found for this VM. + if not device.zbx_template_names: + continue device.set_inventory(nb_device) # Checks if device is part of cluster. # Requires clustering variable