mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-12-26 23:17:43 -06:00
Removed previous patch for Nonetype hostgroups and made a proper fix by refactoring the set_hostgroup() function and removing it from virtual_machines.py
This commit is contained in:
@@ -16,6 +16,7 @@ class VirtualMachine(PhysicalDevice):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.hostgroup = None
|
||||
self.zbx_template_names = None
|
||||
self.hostgroup_type = "vm"
|
||||
|
||||
def _inventory_map(self):
|
||||
"""use VM inventory maps"""
|
||||
@@ -29,25 +30,6 @@ class VirtualMachine(PhysicalDevice):
|
||||
"""use VM tag maps"""
|
||||
return config["vm_tag_map"]
|
||||
|
||||
def set_hostgroup(self, hg_format, nb_site_groups, nb_regions):
|
||||
"""Set the hostgroup for this device"""
|
||||
# Create new Hostgroup instance
|
||||
hg = Hostgroup(
|
||||
"vm",
|
||||
self.nb,
|
||||
self.nb_api_version,
|
||||
logger=self.logger,
|
||||
nested_sitegroup_flag=config["traverse_site_groups"],
|
||||
nested_region_flag=config["traverse_regions"],
|
||||
nb_groups=nb_site_groups,
|
||||
nb_regions=nb_regions,
|
||||
)
|
||||
# Generate hostgroup based on hostgroup format
|
||||
if isinstance(hg_format, list):
|
||||
self.hostgroups = [hg.generate(f) for f in hg_format]
|
||||
else:
|
||||
self.hostgroups.append(hg.generate(hg_format))
|
||||
|
||||
def set_vm_template(self):
|
||||
"""Set Template for VMs. Overwrites default class
|
||||
to skip a lookup of custom fields."""
|
||||
|
||||
Reference in New Issue
Block a user