From 1de0b0781bcf71d5ea2edacc59c0a1f329f3770b Mon Sep 17 00:00:00 2001 From: TheNetworkGuy Date: Tue, 24 Jun 2025 20:44:59 +0200 Subject: [PATCH] Removed default for hostgroups and fixed bug for hostgroup attributes which do not exist --- modules/device.py | 3 +++ modules/hostgroups.py | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/device.py b/modules/device.py index 28e78b4..c3baa17 100644 --- a/modules/device.py +++ b/modules/device.py @@ -564,6 +564,9 @@ class PhysicalDevice: final_data = [] # Check if the hostgroup is in a nested format and check each parent 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("/"))): zabbix_hg = hostgroup.rsplit("/", pos)[0] if self.lookupZabbixHostgroup(hostgroups, zabbix_hg): diff --git a/modules/hostgroups.py b/modules/hostgroups.py index f98c09b..d5306a3 100644 --- a/modules/hostgroups.py +++ b/modules/hostgroups.py @@ -108,11 +108,6 @@ class Hostgroup: def generate(self, hg_format=None): """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 hg_output = [] hg_items = hg_format.split("/")