Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added version check so login works with previous versions
  • Loading branch information
jschoewe committed Jun 6, 2023
commit 55f40f4bcc0fcd45fe1ec909abc92c80c30cc2f0
9 changes: 8 additions & 1 deletion pyzabbix/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import ssl
import sys
import base64
from packaging.version import Version

# For Python 2 and 3 compatibility
try:
Expand Down Expand Up @@ -196,7 +197,13 @@ def _login(self, user='', password=''):

logger.debug("ZabbixAPI.login({0},{1})".format(user, HideSensitiveService.HIDEMASK))

self.auth = self.user.login(username=user, password=password)
api_version = Version(self.apiinfo.version())

# 5.4.0 was the first version of Zabbix to change the user param in the login method
if api_version and api_version < Version("5.4.0"):
self.auth = self.user.login(user=user, password=password)
else:
self.auth = self.user.login(username=user, password=password)

def _logout(self):
"""Do logout from zabbix server."""
Expand Down