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
# Since the zabbix-api python module too old (version 1.0, no higher version so far).
class ZabbixAPIExtends(ZabbixAPI):
def __init__(self, server, timeout, user, passwd, **kwargs):
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd)
def __init__(self, server, timeout, user, passwd, validate_certs, **kwargs):
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd, validate_certs=validate_certs)
HAS_ZABBIX_API = True
except ImportError:
@ -136,7 +136,7 @@ class HostMacro(object):
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)
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
def delete_host_macro(self, host_macro_obj, macro_name):
@ -179,12 +179,17 @@ def main():
http_login_password = module.params['http_login_password']
validate_certs = module.params['validate_certs']
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']
state = module.params['state']
timeout = module.params['timeout']
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
# login to zabbix
try:

Loading…
Cancel
Save