From 767f974ad8deaaf492bdef5e73dadab1814d0d8b Mon Sep 17 00:00:00 2001 From: Wouter de Bruijn Date: Tue, 17 Jun 2025 10:03:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Formatting=20improvements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/device.py | 9 ++++----- modules/interface.py | 1 + modules/tags.py | 1 + modules/tools.py | 3 +-- modules/usermacros.py | 4 ++-- modules/virtual_machine.py | 1 + netbox_zabbix_sync.py | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/device.py b/modules/device.py index 5d2a216..f78faa6 100644 --- a/modules/device.py +++ b/modules/device.py @@ -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 diff --git a/modules/interface.py b/modules/interface.py index 1bd1e37..58c2b6b 100644 --- a/modules/interface.py +++ b/modules/interface.py @@ -2,6 +2,7 @@ """ All of the Zabbix interface related configuration """ + from modules.exceptions import InterfaceConfigError diff --git a/modules/tags.py b/modules/tags.py index 441ebe2..769d36a 100644 --- a/modules/tags.py +++ b/modules/tags.py @@ -3,6 +3,7 @@ """ All of the Zabbix Usermacro related configuration """ + from logging import getLogger from modules.tools import field_mapper, remove_duplicates diff --git a/modules/tools.py b/modules/tools.py index 13ba05d..f612993 100644 --- a/modules/tools.py +++ b/modules/tools.py @@ -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: diff --git a/modules/usermacros.py b/modules/usermacros.py index 0719106..c1ef92f 100644 --- a/modules/usermacros.py +++ b/modules/usermacros.py @@ -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: diff --git a/modules/virtual_machine.py b/modules/virtual_machine.py index 59a4325..9126cc7 100644 --- a/modules/virtual_machine.py +++ b/modules/virtual_machine.py @@ -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 diff --git a/netbox_zabbix_sync.py b/netbox_zabbix_sync.py index 76507c4..a16e08b 100755 --- a/netbox_zabbix_sync.py +++ b/netbox_zabbix_sync.py @@ -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