diff --git a/modules/device.py b/modules/device.py index d90e505..b8d038d 100644 --- a/modules/device.py +++ b/modules/device.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python3 -# pylint: disable=invalid-name, logging-not-lazy, too-many-locals, logging-fstring-interpolation, too-many-lines, too-many-public-methods +# pylint: disable=invalid-name, logging-not-lazy, too-many-locals, logging-fstring-interpolation, too-many-lines, too-many-public-methods, duplicate-code """ Device specific handeling for NetBox to Zabbix """ @@ -7,7 +6,6 @@ from copy import deepcopy from logging import getLogger from os import sys from re import search -from venv import logger from zabbix_utils import APIRequestError @@ -20,7 +18,6 @@ from modules.exceptions import ( ) from modules.hostgroups import Hostgroup from modules.interface import ZabbixInterface -from modules.logging import get_logger from modules.tags import ZabbixTags from modules.tools import field_mapper, remove_duplicates from modules.usermacros import ZabbixUsermacros @@ -549,9 +546,9 @@ class PhysicalDevice: host = self.zabbix.host.create(**create_data) self.zabbix_id = host["hostids"][0] except APIRequestError as e: - e = f"Host {self.name}: Couldn't create. Zabbix returned {str(e)}." - self.logger.error(e) - raise SyncExternalError(e) from e + msg = f"Host {self.name}: Couldn't create. Zabbix returned {str(e)}." + self.logger.error(msg) + raise SyncExternalError(msg) from e # Set NetBox custom field to hostID value. self.nb.custom_fields[device_cf] = int(self.zabbix_id) self.nb.save() diff --git a/modules/hostgroups.py b/modules/hostgroups.py index c67f5e6..d1350bd 100644 --- a/modules/hostgroups.py +++ b/modules/hostgroups.py @@ -10,12 +10,13 @@ class Hostgroup: """Hostgroup class for devices and VM's Takes type (vm or dev) and NB object""" + # pylint: disable=too-many-arguments, disable=too-many-positional-arguments def __init__( self, obj_type, nb_obj, version, - logger=None, # pylint: disable=too-many-arguments, too-many-positional-arguments + logger=None, nested_sitegroup_flag=False, nested_region_flag=False, nb_regions=None, diff --git a/modules/virtual_machine.py b/modules/virtual_machine.py index 6038811..34e3394 100644 --- a/modules/virtual_machine.py +++ b/modules/virtual_machine.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 # pylint: disable=duplicate-code """Module that hosts all functions for virtual machine processing""" diff --git a/netbox_zabbix_sync.py b/netbox_zabbix_sync.py index 2f30ccd..79d8a20 100755 --- a/netbox_zabbix_sync.py +++ b/netbox_zabbix_sync.py @@ -5,7 +5,7 @@ import argparse import logging import ssl -from os import environ, path, sys +from os import environ, sys from pynetbox import api from pynetbox.core.query import RequestError as NBRequestError