mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-14 01:41:25 -06:00
Swapped hostgroup and template calculation since template lookup is a read-only operation and hostgroup lookup could be a read-write operation.
This commit is contained in:
parent
06f97b132a
commit
9417908994
@ -136,14 +136,14 @@ def main(arguments):
|
|||||||
vm = VirtualMachine(nb_vm, zabbix, netbox_journals, nb_version,
|
vm = VirtualMachine(nb_vm, zabbix, netbox_journals, nb_version,
|
||||||
create_journal, logger)
|
create_journal, logger)
|
||||||
logger.debug(f"Host {vm.name}: started operations on VM.")
|
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_vm_template()
|
||||||
# Check if a valid template has been found for this VM.
|
# Check if a valid template has been found for this VM.
|
||||||
if not vm.zbx_template_names:
|
if not vm.zbx_template_names:
|
||||||
continue
|
continue
|
||||||
|
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
|
||||||
# Temporary disable inventory sync for VM's
|
# Temporary disable inventory sync for VM's
|
||||||
# vm.set_inventory(nb_vm)
|
# vm.set_inventory(nb_vm)
|
||||||
|
|
||||||
@ -189,14 +189,14 @@ def main(arguments):
|
|||||||
device = PhysicalDevice(nb_device, zabbix, netbox_journals, nb_version,
|
device = PhysicalDevice(nb_device, zabbix, netbox_journals, nb_version,
|
||||||
create_journal, logger)
|
create_journal, logger)
|
||||||
logger.debug(f"Host {device.name}: started operations on device.")
|
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)
|
device.set_template(templates_config_context, templates_config_context_overrule)
|
||||||
# Check if a valid template has been found for this VM.
|
# Check if a valid template has been found for this VM.
|
||||||
if not device.zbx_template_names:
|
if not device.zbx_template_names:
|
||||||
continue
|
continue
|
||||||
|
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_inventory(nb_device)
|
device.set_inventory(nb_device)
|
||||||
# Checks if device is part of cluster.
|
# Checks if device is part of cluster.
|
||||||
# Requires clustering variable
|
# Requires clustering variable
|
||||||
|
Loading…
Reference in New Issue
Block a user