mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-16 04:02:56 -06:00
Removed default for hostgroups and fixed bug for hostgroup attributes which do not exist
This commit is contained in:
parent
1cf24fbcb5
commit
1de0b0781b
@ -564,6 +564,9 @@ class PhysicalDevice:
|
|||||||
final_data = []
|
final_data = []
|
||||||
# Check if the hostgroup is in a nested format and check each parent
|
# Check if the hostgroup is in a nested format and check each parent
|
||||||
for hostgroup in self.hostgroups:
|
for hostgroup in self.hostgroups:
|
||||||
|
# Check if hostgroup is string. If Nonetype skip hostgroup
|
||||||
|
if not isinstance(hostgroup, str):
|
||||||
|
continue
|
||||||
for pos in range(len(hostgroup.split("/"))):
|
for pos in range(len(hostgroup.split("/"))):
|
||||||
zabbix_hg = hostgroup.rsplit("/", pos)[0]
|
zabbix_hg = hostgroup.rsplit("/", pos)[0]
|
||||||
if self.lookupZabbixHostgroup(hostgroups, zabbix_hg):
|
if self.lookupZabbixHostgroup(hostgroups, zabbix_hg):
|
||||||
|
@ -108,11 +108,6 @@ class Hostgroup:
|
|||||||
|
|
||||||
def generate(self, hg_format=None):
|
def generate(self, hg_format=None):
|
||||||
"""Generate hostgroup based on a provided format"""
|
"""Generate hostgroup based on a provided format"""
|
||||||
# Set format to default in case its not specified
|
|
||||||
if not hg_format:
|
|
||||||
hg_format = (
|
|
||||||
"site/manufacturer/role" if self.type == "dev" else "cluster/role"
|
|
||||||
)
|
|
||||||
# Split all given names
|
# Split all given names
|
||||||
hg_output = []
|
hg_output = []
|
||||||
hg_items = hg_format.split("/")
|
hg_items = hg_format.split("/")
|
||||||
|
Loading…
Reference in New Issue
Block a user