mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-14 01:41:25 -06:00
🚨 "Fixed" linter warnings
This commit is contained in:
parent
9ab5e09dd5
commit
7781bc6732
@ -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, duplicate-code
|
||||||
# pylint: disable=invalid-name, logging-not-lazy, too-many-locals, logging-fstring-interpolation, too-many-lines, too-many-public-methods
|
|
||||||
"""
|
"""
|
||||||
Device specific handeling for NetBox to Zabbix
|
Device specific handeling for NetBox to Zabbix
|
||||||
"""
|
"""
|
||||||
@ -7,7 +6,6 @@ from copy import deepcopy
|
|||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from os import sys
|
from os import sys
|
||||||
from re import search
|
from re import search
|
||||||
from venv import logger
|
|
||||||
|
|
||||||
from zabbix_utils import APIRequestError
|
from zabbix_utils import APIRequestError
|
||||||
|
|
||||||
@ -20,7 +18,6 @@ from modules.exceptions import (
|
|||||||
)
|
)
|
||||||
from modules.hostgroups import Hostgroup
|
from modules.hostgroups import Hostgroup
|
||||||
from modules.interface import ZabbixInterface
|
from modules.interface import ZabbixInterface
|
||||||
from modules.logging import get_logger
|
|
||||||
from modules.tags import ZabbixTags
|
from modules.tags import ZabbixTags
|
||||||
from modules.tools import field_mapper, remove_duplicates
|
from modules.tools import field_mapper, remove_duplicates
|
||||||
from modules.usermacros import ZabbixUsermacros
|
from modules.usermacros import ZabbixUsermacros
|
||||||
@ -549,9 +546,9 @@ class PhysicalDevice:
|
|||||||
host = self.zabbix.host.create(**create_data)
|
host = self.zabbix.host.create(**create_data)
|
||||||
self.zabbix_id = host["hostids"][0]
|
self.zabbix_id = host["hostids"][0]
|
||||||
except APIRequestError as e:
|
except APIRequestError as e:
|
||||||
e = f"Host {self.name}: Couldn't create. Zabbix returned {str(e)}."
|
msg = f"Host {self.name}: Couldn't create. Zabbix returned {str(e)}."
|
||||||
self.logger.error(e)
|
self.logger.error(msg)
|
||||||
raise SyncExternalError(e) from e
|
raise SyncExternalError(msg) from e
|
||||||
# Set NetBox custom field to hostID value.
|
# Set NetBox custom field to hostID value.
|
||||||
self.nb.custom_fields[device_cf] = int(self.zabbix_id)
|
self.nb.custom_fields[device_cf] = int(self.zabbix_id)
|
||||||
self.nb.save()
|
self.nb.save()
|
||||||
|
@ -10,12 +10,13 @@ class Hostgroup:
|
|||||||
"""Hostgroup class for devices and VM's
|
"""Hostgroup class for devices and VM's
|
||||||
Takes type (vm or dev) and NB object"""
|
Takes type (vm or dev) and NB object"""
|
||||||
|
|
||||||
|
# pylint: disable=too-many-arguments, disable=too-many-positional-arguments
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
obj_type,
|
obj_type,
|
||||||
nb_obj,
|
nb_obj,
|
||||||
version,
|
version,
|
||||||
logger=None, # pylint: disable=too-many-arguments, too-many-positional-arguments
|
logger=None,
|
||||||
nested_sitegroup_flag=False,
|
nested_sitegroup_flag=False,
|
||||||
nested_region_flag=False,
|
nested_region_flag=False,
|
||||||
nb_regions=None,
|
nb_regions=None,
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# 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"""
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import ssl
|
import ssl
|
||||||
from os import environ, path, sys
|
from os import environ, sys
|
||||||
|
|
||||||
from pynetbox import api
|
from pynetbox import api
|
||||||
from pynetbox.core.query import RequestError as NBRequestError
|
from pynetbox.core.query import RequestError as NBRequestError
|
||||||
|
Loading…
Reference in New Issue
Block a user