🎨 Formatting improvements

This commit is contained in:
Wouter de Bruijn 2025-06-17 10:03:10 +02:00
parent de438777d2
commit 767f974ad8
No known key found for this signature in database
GPG Key ID: AC71F96733B92BFA
7 changed files with 12 additions and 11 deletions

View File

@ -97,7 +97,7 @@ class PhysicalDevice:
if config["device_cf"] in self.nb.custom_fields: if config["device_cf"] in self.nb.custom_fields:
self.zabbix_id = self.nb.custom_fields[config["device_cf"]] self.zabbix_id = self.nb.custom_fields[config["device_cf"]]
else: else:
e = f'Host {self.name}: Custom field {config["device_cf"]} not present' e = f"Host {self.name}: Custom field {config['device_cf']} not present"
self.logger.warning(e) self.logger.warning(e)
raise SyncInventoryError(e) raise SyncInventoryError(e)
@ -323,7 +323,7 @@ class PhysicalDevice:
self.group_ids.append({"groupid": group["groupid"]}) self.group_ids.append({"groupid": group["groupid"]})
e = ( e = (
f"Host {self.name}: matched group " f"Host {self.name}: matched group "
f"\"{group['name']}\" (ID:{group['groupid']})" f'"{group["name"]}" (ID:{group["groupid"]})'
) )
self.logger.debug(e) self.logger.debug(e)
if len(self.group_ids) == len(self.hostgroups): if len(self.group_ids) == len(self.hostgroups):
@ -469,7 +469,7 @@ class PhysicalDevice:
# If the proxy name matches # If the proxy name matches
if proxy["name"] == proxy_name: if proxy["name"] == proxy_name:
self.logger.debug( self.logger.debug(
f"Host {self.name}: using {proxy['type']}" f" {proxy_name}" f"Host {self.name}: using {proxy['type']} {proxy_name}"
) )
self.zbxproxy = proxy self.zbxproxy = proxy
return True return True
@ -924,8 +924,7 @@ class PhysicalDevice:
return True return True
except NetboxRequestError as e: except NetboxRequestError as e:
self.logger.warning( self.logger.warning(
"Unable to create journal entry for " f"Unable to create journal entry for {self.name}: NB returned {e}"
f"{self.name}: NB returned {e}"
) )
return False return False
return False return False

View File

@ -2,6 +2,7 @@
""" """
All of the Zabbix interface related configuration All of the Zabbix interface related configuration
""" """
from modules.exceptions import InterfaceConfigError from modules.exceptions import InterfaceConfigError

View File

@ -3,6 +3,7 @@
""" """
All of the Zabbix Usermacro related configuration All of the Zabbix Usermacro related configuration
""" """
from logging import getLogger from logging import getLogger
from modules.tools import field_mapper, remove_duplicates from modules.tools import field_mapper, remove_duplicates

View File

@ -74,8 +74,7 @@ def field_mapper(host, mapper, nbdevice, logger):
elif not value: elif not value:
# empty value should just be an empty string for API compatibility # empty value should just be an empty string for API compatibility
logger.debug( logger.debug(
f"Host {host}: NetBox lookup for " f"Host {host}: NetBox lookup for '{nb_field}' returned an empty value"
f"'{nb_field}' returned an empty value"
) )
data[zbx_field] = "" data[zbx_field] = ""
else: else:

View File

@ -3,6 +3,7 @@
""" """
All of the Zabbix Usermacro related configuration All of the Zabbix Usermacro related configuration
""" """
from logging import getLogger from logging import getLogger
from re import match from re import match
@ -86,8 +87,7 @@ class ZabbixUsermacros:
else: else:
self.logger.warning( self.logger.warning(
f"Host {self.name}: Usermacro {macro_name} " f"Host {self.name}: Usermacro {macro_name} has no value, skipping."
"has no value, skipping."
) )
return False return False
else: else:

View File

@ -1,5 +1,6 @@
# pylint: disable=duplicate-code # pylint: disable=duplicate-code
"""Module that hosts all functions for virtual machine processing""" """Module that hosts all functions for virtual machine processing"""
from modules.config import load_config from modules.config import load_config
from modules.device import PhysicalDevice from modules.device import PhysicalDevice
from modules.exceptions import InterfaceConfigError, SyncInventoryError, TemplateError from modules.exceptions import InterfaceConfigError, SyncInventoryError, TemplateError

View File

@ -2,6 +2,7 @@
# pylint: disable=invalid-name, logging-not-lazy, too-many-locals, logging-fstring-interpolation # pylint: disable=invalid-name, logging-not-lazy, too-many-locals, logging-fstring-interpolation
"""NetBox to Zabbix sync script.""" """NetBox to Zabbix sync script."""
import argparse import argparse
import logging import logging
import ssl import ssl
@ -181,8 +182,7 @@ def main(arguments):
# Device has been added to NetBox # Device has been added to NetBox
# but is not in Activate state # but is not in Activate state
logger.info( logger.info(
f"VM {vm.name}: skipping since this VM is " f"VM {vm.name}: skipping since this VM is not in the active state."
f"not in the active state."
) )
continue continue
# Check if the VM is in the disabled state # Check if the VM is in the disabled state