mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-14 01:41:25 -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
|
# Add default formatting options
|
||||||
# Check if a site is configured. A site is optional for VMs
|
# Check if a site is configured. A site is optional for VMs
|
||||||
format_options["region"] = None
|
format_options["region"] = None
|
||||||
format_options["location"] = None
|
|
||||||
format_options["site_group"] = None
|
format_options["site_group"] = None
|
||||||
if self.nb.site:
|
if self.nb.site:
|
||||||
if self.nb.site.region:
|
if self.nb.site.region:
|
||||||
format_options["region"] = self.generate_parents("region",
|
format_options["region"] = self.generate_parents("region",
|
||||||
str(self.nb.site.region))
|
str(self.nb.site.region))
|
||||||
if self.nb.location:
|
|
||||||
format_options["location"] = str(self.nb.location)
|
|
||||||
if self.nb.site.group:
|
if self.nb.site.group:
|
||||||
format_options["site_group"] = self.generate_parents("site_group",
|
format_options["site_group"] = self.generate_parents("site_group",
|
||||||
str(self.nb.site.group))
|
str(self.nb.site.group))
|
||||||
@ -61,8 +58,11 @@ class Hostgroup():
|
|||||||
# Variables only applicable for devices
|
# Variables only applicable for devices
|
||||||
if self.type == "dev":
|
if self.type == "dev":
|
||||||
format_options["manufacturer"] = self.nb.device_type.manufacturer.name
|
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
|
# Variables only applicable for VM's
|
||||||
if self.type == "vm":
|
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"] = self.nb.cluster.name
|
||||||
format_options["cluster_type"] = self.nb.cluster.type.name
|
format_options["cluster_type"] = self.nb.cluster.type.name
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""Module that hosts all functions for virtual machine processing"""
|
"""Module that hosts all functions for virtual machine processing"""
|
||||||
|
|
||||||
|
from os import sys
|
||||||
from modules.device import PhysicalDevice
|
from modules.device import PhysicalDevice
|
||||||
from modules.hostgroups import Hostgroup
|
from modules.hostgroups import Hostgroup
|
||||||
from modules.exceptions import TemplateError
|
from modules.exceptions import TemplateError
|
||||||
try:
|
try:
|
||||||
from config import (
|
from config import (
|
||||||
traverse_site_groups,
|
traverse_site_groups,
|
||||||
traverse_regions,
|
traverse_regions
|
||||||
template_cf
|
|
||||||
)
|
)
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
print("Configuration file config.py not found in main directory."
|
print("Configuration file config.py not found in main directory."
|
||||||
@ -36,6 +36,11 @@ class VirtualMachine(PhysicalDevice):
|
|||||||
self.logger.warning(e)
|
self.logger.warning(e)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def set_template(self, **kwargs):
|
def set_template(self, prefer_config_context=None, overrule_custom=None):
|
||||||
"""Simple wrapper fur underlying functions"""
|
"""
|
||||||
|
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()
|
self.set_vm_template()
|
@ -8,7 +8,7 @@ from os import environ, path, sys
|
|||||||
from pynetbox import api
|
from pynetbox import api
|
||||||
from zabbix_utils import ZabbixAPI, APIRequestError, ProcessingError
|
from zabbix_utils import ZabbixAPI, APIRequestError, ProcessingError
|
||||||
from modules.device import PhysicalDevice
|
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.tools import convert_recordset, proxy_prepper
|
||||||
from modules.exceptions import EnvironmentVarError, HostgroupError, SyncError
|
from modules.exceptions import EnvironmentVarError, HostgroupError, SyncError
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user