mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-16 04:02:56 -06:00
🚨 Improvement for variable assignment in logging
This commit is contained in:
parent
66d59f2575
commit
132bcc1344
@ -890,16 +890,15 @@ class PhysicalDevice:
|
|||||||
raise SyncExternalError(msg) from e
|
raise SyncExternalError(msg) from e
|
||||||
else:
|
else:
|
||||||
# If no updates are found, Zabbix interface is in-sync
|
# If no updates are found, Zabbix interface is in-sync
|
||||||
e = f"Host {self.name}: interface in-sync."
|
self.logger.debug("Host %s: interface in-sync.", self.name)
|
||||||
self.logger.debug(e)
|
|
||||||
else:
|
else:
|
||||||
e = (
|
error_message = (
|
||||||
f"Host {self.name} has unsupported interface configuration."
|
f"Host {self.name} has unsupported interface configuration."
|
||||||
f" Host has total of {len(host['interfaces'])} interfaces. "
|
f" Host has total of {len(host['interfaces'])} interfaces. "
|
||||||
"Manual intervention required."
|
"Manual intervention required."
|
||||||
)
|
)
|
||||||
self.logger.error(e)
|
self.logger.error(error_message)
|
||||||
raise SyncInventoryError(e)
|
raise SyncInventoryError(error_message)
|
||||||
|
|
||||||
def create_journal_entry(self, severity, message):
|
def create_journal_entry(self, severity, message):
|
||||||
"""
|
"""
|
||||||
|
@ -244,16 +244,16 @@ def main(arguments):
|
|||||||
if device.isCluster() and config["clustering"]:
|
if device.isCluster() and config["clustering"]:
|
||||||
# Check if device is primary or secondary
|
# Check if device is primary or secondary
|
||||||
if device.promoteMasterDevice():
|
if device.promoteMasterDevice():
|
||||||
e = f"Device {device.name}: is " f"part of cluster and primary."
|
logger.info(
|
||||||
logger.info(e)
|
"Device %s: is part of cluster and primary.", device.name
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# Device is secondary in cluster.
|
# Device is secondary in cluster.
|
||||||
# Don't continue with this device.
|
# Don't continue with this device.
|
||||||
e = (
|
logger.info(
|
||||||
f"Device {device.name}: is part of cluster "
|
"Device %s: is part of cluster but not primary. Skipping this host...",
|
||||||
f"but not primary. Skipping this host..."
|
device.name,
|
||||||
)
|
)
|
||||||
logger.info(e)
|
|
||||||
continue
|
continue
|
||||||
# Checks if device is in cleanup state
|
# Checks if device is in cleanup state
|
||||||
if device.status in config["zabbix_device_removal"]:
|
if device.status in config["zabbix_device_removal"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user