mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-16 12:12:57 -06:00
code cleanup
This commit is contained in:
parent
23bef6b549
commit
2fcd21a723
@ -362,12 +362,11 @@ class NetworkDevice():
|
|||||||
f"not part of a cluster.")
|
f"not part of a cluster.")
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
raise SyncInventoryError(e)
|
raise SyncInventoryError(e)
|
||||||
elif not self.nb.virtual_chassis.master:
|
if not self.nb.virtual_chassis.master:
|
||||||
e = (f"{self.name} is part of a Netbox virtual chassis which does "
|
e = (f"{self.name} is part of a Netbox virtual chassis which does "
|
||||||
"not have a master configured. Skipping for this reason.")
|
"not have a master configured. Skipping for this reason.")
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
raise SyncInventoryError(e)
|
raise SyncInventoryError(e)
|
||||||
else:
|
|
||||||
return self.nb.virtual_chassis.master.id
|
return self.nb.virtual_chassis.master.id
|
||||||
|
|
||||||
def promoteMasterDevice(self):
|
def promoteMasterDevice(self):
|
||||||
@ -419,7 +418,7 @@ class NetworkDevice():
|
|||||||
e = (f"Unable to find template {nb_template} "
|
e = (f"Unable to find template {nb_template} "
|
||||||
f"for host {self.name} in Zabbix. Skipping host...")
|
f"for host {self.name} in Zabbix. Skipping host...")
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
raise SyncInventoryError(e)
|
raise SyncInventoryError(e) from e
|
||||||
|
|
||||||
def getZabbixGroup(self, groups):
|
def getZabbixGroup(self, groups):
|
||||||
"""
|
"""
|
||||||
@ -434,7 +433,6 @@ class NetworkDevice():
|
|||||||
e = f"Found group {group['name']} for host {self.name}."
|
e = f"Found group {group['name']} for host {self.name}."
|
||||||
logger.debug(e)
|
logger.debug(e)
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
e = (f"Unable to find group '{self.hostgroup}' "
|
e = (f"Unable to find group '{self.hostgroup}' "
|
||||||
f"for host {self.name} in Zabbix.")
|
f"for host {self.name} in Zabbix.")
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
@ -456,7 +454,7 @@ class NetworkDevice():
|
|||||||
except ZabbixAPIException as e:
|
except ZabbixAPIException as e:
|
||||||
e = f"Zabbix returned the following error: {str(e)}."
|
e = f"Zabbix returned the following error: {str(e)}."
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
raise SyncExternalError(e)
|
raise SyncExternalError(e) from e
|
||||||
|
|
||||||
def _zabbixHostnameExists(self):
|
def _zabbixHostnameExists(self):
|
||||||
"""
|
"""
|
||||||
@ -485,7 +483,7 @@ class NetworkDevice():
|
|||||||
except InterfaceConfigError as e:
|
except InterfaceConfigError as e:
|
||||||
e = f"{self.name}: {e}"
|
e = f"{self.name}: {e}"
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
raise SyncInventoryError(e)
|
raise SyncInventoryError(e) from e
|
||||||
|
|
||||||
def setProxy(self, proxy_list):
|
def setProxy(self, proxy_list):
|
||||||
""" check if Zabbix Proxy has been defined in config context """
|
""" check if Zabbix Proxy has been defined in config context """
|
||||||
|
Loading…
Reference in New Issue
Block a user