zabbix_hostmacro: Fixed support for LLD type user macros and added missing validate_certs attribute (#48730)

pull/49348/head
Dusan Matejka 6 years ago committed by René Moser
parent b842b1b97e
commit 7190c73d50

@ -77,8 +77,8 @@ try:
# Extend the ZabbixAPI # Extend the ZabbixAPI
# Since the zabbix-api python module too old (version 1.0, no higher version so far). # Since the zabbix-api python module too old (version 1.0, no higher version so far).
class ZabbixAPIExtends(ZabbixAPI): class ZabbixAPIExtends(ZabbixAPI):
def __init__(self, server, timeout, user, passwd, **kwargs): def __init__(self, server, timeout, user, passwd, validate_certs, **kwargs):
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd) ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd, validate_certs=validate_certs)
HAS_ZABBIX_API = True HAS_ZABBIX_API = True
except ImportError: except ImportError:
@ -136,7 +136,7 @@ class HostMacro(object):
self._zapi.usermacro.update({'hostmacroid': host_macro_id, 'value': macro_value}) self._zapi.usermacro.update({'hostmacroid': host_macro_id, 'value': macro_value})
self._module.exit_json(changed=True, result="Successfully updated host macro %s" % macro_name) self._module.exit_json(changed=True, result="Successfully updated host macro %s" % macro_name)
except Exception as e: except Exception as e:
self._module.fail_json(msg="Failed to updated host macro %s: %s" % (macro_name, e)) self._module.fail_json(msg="Failed to update host macro %s: %s" % (macro_name, e))
# delete host macro # delete host macro
def delete_host_macro(self, host_macro_obj, macro_name): def delete_host_macro(self, host_macro_obj, macro_name):
@ -179,12 +179,17 @@ def main():
http_login_password = module.params['http_login_password'] http_login_password = module.params['http_login_password']
validate_certs = module.params['validate_certs'] validate_certs = module.params['validate_certs']
host_name = module.params['host_name'] host_name = module.params['host_name']
macro_name = (module.params['macro_name']).upper() macro_name = (module.params['macro_name'])
macro_value = module.params['macro_value'] macro_value = module.params['macro_value']
state = module.params['state'] state = module.params['state']
timeout = module.params['timeout'] timeout = module.params['timeout']
force = module.params['force'] force = module.params['force']
if ':' in macro_name:
macro_name = ':'.join([macro_name.split(':')[0].upper(), macro_name.split(':')[1]])
else:
macro_name = macro_name.upper()
zbx = None zbx = None
# login to zabbix # login to zabbix
try: try:

Loading…
Cancel
Save