🎨 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:
self.zabbix_id = self.nb.custom_fields[config["device_cf"]]
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)
raise SyncInventoryError(e)
@ -323,7 +323,7 @@ class PhysicalDevice:
self.group_ids.append({"groupid": group["groupid"]})
e = (
f"Host {self.name}: matched group "
f"\"{group['name']}\" (ID:{group['groupid']})"
f'"{group["name"]}" (ID:{group["groupid"]})'
)
self.logger.debug(e)
if len(self.group_ids) == len(self.hostgroups):
@ -469,7 +469,7 @@ class PhysicalDevice:
# If the proxy name matches
if proxy["name"] == proxy_name:
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
return True
@ -924,8 +924,7 @@ class PhysicalDevice:
return True
except NetboxRequestError as e:
self.logger.warning(
"Unable to create journal entry for "
f"{self.name}: NB returned {e}"
f"Unable to create journal entry for {self.name}: NB returned {e}"
)
return False
return False

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
# pylint: disable=duplicate-code
"""Module that hosts all functions for virtual machine processing"""
from modules.config import load_config
from modules.device import PhysicalDevice
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
"""NetBox to Zabbix sync script."""
import argparse
import logging
import ssl
@ -181,8 +182,7 @@ def main(arguments):
# Device has been added to NetBox
# but is not in Activate state
logger.info(
f"VM {vm.name}: skipping since this VM is "
f"not in the active state."
f"VM {vm.name}: skipping since this VM is not in the active state."
)
continue
# Check if the VM is in the disabled state