zabbix_proxy fix support for Zabbix 5.0 (#71290)

pull/71527/head
Dusan Matejka 4 years ago committed by GitHub
parent f42bd0ecdd
commit 36fbd2d9fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- zabbix_proxy - fixed support for Zabbix 5.0

@ -139,6 +139,7 @@ RETURN = r''' # '''
import traceback import traceback
import atexit import atexit
from distutils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
try: try:
from zabbix_api import ZabbixAPI from zabbix_api import ZabbixAPI
@ -153,6 +154,7 @@ class Proxy(object):
def __init__(self, module, zbx): def __init__(self, module, zbx):
self._module = module self._module = module
self._zapi = zbx self._zapi = zbx
self._zbx_api_version = zbx.api_version()[:5]
self.existing_data = None self.existing_data = None
def proxy_exists(self, proxy_name): def proxy_exists(self, proxy_name):
@ -204,6 +206,10 @@ class Proxy(object):
len(self.existing_data['interface']) > 0: len(self.existing_data['interface']) > 0:
old_interface = self.existing_data['interface'] old_interface = self.existing_data['interface']
if LooseVersion(self._zbx_api_version) >= LooseVersion('5.0.0'):
if old_interface:
old_interface['details'] = str(old_interface['details'])
final_interface = old_interface.copy() final_interface = old_interface.copy()
final_interface.update(new_interface) final_interface.update(new_interface)
final_interface = dict((k, str(v)) for k, v in final_interface.items()) final_interface = dict((k, str(v)) for k, v in final_interface.items())

Loading…
Cancel
Save