mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-13 23:27:32 -06:00
Renamed VM module for python naming convention. Fixed 2 VM hostgroup bugs. Fixed some whitespace in the VM module.
This commit is contained in:
parent
886ef2a172
commit
bff34a8e38
@ -42,14 +42,11 @@ class Hostgroup():
|
||||
# Add default formatting options
|
||||
# Check if a site is configured. A site is optional for VMs
|
||||
format_options["region"] = None
|
||||
format_options["location"] = None
|
||||
format_options["site_group"] = None
|
||||
if self.nb.site:
|
||||
if self.nb.site.region:
|
||||
format_options["region"] = self.generate_parents("region",
|
||||
str(self.nb.site.region))
|
||||
if self.nb.location:
|
||||
format_options["location"] = str(self.nb.location)
|
||||
if self.nb.site.group:
|
||||
format_options["site_group"] = self.generate_parents("site_group",
|
||||
str(self.nb.site.group))
|
||||
@ -61,8 +58,11 @@ class Hostgroup():
|
||||
# Variables only applicable for devices
|
||||
if self.type == "dev":
|
||||
format_options["manufacturer"] = self.nb.device_type.manufacturer.name
|
||||
format_options["location"] = str(self.nb.location) if self.nb.location else None
|
||||
# Variables only applicable for VM's
|
||||
if self.type == "vm":
|
||||
# Check if a cluster is configured. Could also be configured in a site.
|
||||
if self.nb.cluster:
|
||||
format_options["cluster"] = self.nb.cluster.name
|
||||
format_options["cluster_type"] = self.nb.cluster.type.name
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
"""Module that hosts all functions for virtual machine processing"""
|
||||
|
||||
from os import sys
|
||||
from modules.device import PhysicalDevice
|
||||
from modules.hostgroups import Hostgroup
|
||||
from modules.exceptions import TemplateError
|
||||
try:
|
||||
from config import (
|
||||
traverse_site_groups,
|
||||
traverse_regions,
|
||||
template_cf
|
||||
traverse_regions
|
||||
)
|
||||
except ModuleNotFoundError:
|
||||
print("Configuration file config.py not found in main directory."
|
||||
@ -36,6 +36,11 @@ class VirtualMachine(PhysicalDevice):
|
||||
self.logger.warning(e)
|
||||
return True
|
||||
|
||||
def set_template(self, **kwargs):
|
||||
"""Simple wrapper fur underlying functions"""
|
||||
def set_template(self, prefer_config_context=None, overrule_custom=None):
|
||||
"""
|
||||
This wrapper takes the original function and
|
||||
overwrites it with the set_vm_template function.
|
||||
This function (set_template) is used by several
|
||||
other functions such as the consistency check in the parent class.
|
||||
"""
|
||||
self.set_vm_template()
|
@ -8,7 +8,7 @@ from os import environ, path, sys
|
||||
from pynetbox import api
|
||||
from zabbix_utils import ZabbixAPI, APIRequestError, ProcessingError
|
||||
from modules.device import PhysicalDevice
|
||||
from modules.virtualMachine import VirtualMachine
|
||||
from modules.virtual_machine import VirtualMachine
|
||||
from modules.tools import convert_recordset, proxy_prepper
|
||||
from modules.exceptions import EnvironmentVarError, HostgroupError, SyncError
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user