mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-16 04:02:56 -06:00
Fixed bug in which some instances a nested hostgroup was not created
This commit is contained in:
parent
70a5c3e384
commit
a0ea21d731
@ -536,24 +536,26 @@ class NetworkDevice():
|
|||||||
"""
|
"""
|
||||||
Checks if Zabbix object is still valid with Netbox parameters.
|
Checks if Zabbix object is still valid with Netbox parameters.
|
||||||
"""
|
"""
|
||||||
# Set Hostgroup ID
|
# If group is found or if the hostgroup is nested
|
||||||
# If not, create the hostgroup and try finding the group again
|
if not self.setZabbixGroupID(groups) or len(self.hostgroup.split('/')) > 1:
|
||||||
if not self.setZabbixGroupID(groups):
|
|
||||||
# No hostgroup was found
|
|
||||||
if create_hostgroups:
|
if create_hostgroups:
|
||||||
# Script is allowed to create a new hostgroup
|
# Script is allowed to create a new hostgroup
|
||||||
new_groups = self.createZabbixHostgroup(groups)
|
new_groups = self.createZabbixHostgroup(groups)
|
||||||
for group in new_groups:
|
for group in new_groups:
|
||||||
# Go through all newly created groups
|
# Add all new groups to the list of groups
|
||||||
groups.append(group)
|
groups.append(group)
|
||||||
self.setZabbixGroupID(groups)
|
# check if the initial group was not already found (and this is a nested folder check)
|
||||||
else:
|
if not self.group_id:
|
||||||
e = (f"Device {self.name}: different hostgroup is required but "
|
# Function returns true / false but also sets GroupID
|
||||||
"unable to create hostgroup without generation permission.")
|
if not self.setZabbixGroupID(groups) and not create_hostgroups:
|
||||||
self.logger.warning(e)
|
e = (f"Device {self.name}: different hostgroup is required but "
|
||||||
raise SyncInventoryError(e)
|
"unable to create hostgroup without generation permission.")
|
||||||
|
self.logger.warning(e)
|
||||||
|
raise SyncInventoryError(e)
|
||||||
|
# Prepare templates and proxy config
|
||||||
self.zbxTemplatePrepper(templates)
|
self.zbxTemplatePrepper(templates)
|
||||||
self.setProxy(proxies)
|
self.setProxy(proxies)
|
||||||
|
# Get host object from Zabbix
|
||||||
host = self.zabbix.host.get(filter={'hostid': self.zabbix_id},
|
host = self.zabbix.host.get(filter={'hostid': self.zabbix_id},
|
||||||
selectInterfaces=['type', 'ip',
|
selectInterfaces=['type', 'ip',
|
||||||
'port', 'details',
|
'port', 'details',
|
||||||
|
Loading…
Reference in New Issue
Block a user