summaryrefslogtreecommitdiffstats
path: root/roles/lib_zabbix/library
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2016-01-26 16:42:01 -0500
committerKenny Woodson <kwoodson@redhat.com>2016-01-26 16:42:01 -0500
commitdf07308395576f5fcf7089b1bb29acafde6fb122 (patch)
tree28c03be122a317ad0f5b25879ef9152c141488d2 /roles/lib_zabbix/library
parent00e52c75329b3a94313c210e1af165b5fcffa961 (diff)
downloadopenshift-df07308395576f5fcf7089b1bb29acafde6fb122.tar.gz
openshift-df07308395576f5fcf7089b1bb29acafde6fb122.tar.bz2
openshift-df07308395576f5fcf7089b1bb29acafde6fb122.tar.xz
openshift-df07308395576f5fcf7089b1bb29acafde6fb122.zip
Comparing zbx_host interfaces and removing duplicate hostgroup_names
Diffstat (limited to 'roles/lib_zabbix/library')
-rw-r--r--roles/lib_zabbix/library/zbx_host.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/roles/lib_zabbix/library/zbx_host.py b/roles/lib_zabbix/library/zbx_host.py
index e26c9caf3..560749f07 100644
--- a/roles/lib_zabbix/library/zbx_host.py
+++ b/roles/lib_zabbix/library/zbx_host.py
@@ -63,6 +63,19 @@ def get_template_ids(zapi, template_names):
template_ids.append({'templateid': content['result'][0]['templateid']})
return template_ids
+def interfaces_equal(zbx_interfaces, user_interfaces):
+ '''
+ compare interfaces from zabbix and interfaces from user
+ '''
+
+ for u_int in user_interfaces:
+ for z_int in zbx_interfaces:
+ for u_key, u_val in u_int.items():
+ if str(z_int[u_key]) != str(u_val):
+ return False
+
+ return True
+
def main():
'''
Ansible module for zabbix host
@@ -120,8 +133,9 @@ def main():
'dns': '', # dns for host
'port': '10050', # port for interface? 10050
}]
+ hostgroup_names = list(set(module.params['hostgroup_names']))
params = {'host': hname,
- 'groups': get_group_ids(zapi, module.params['hostgroup_names']),
+ 'groups': get_group_ids(zapi, hostgroup_names),
'templates': get_template_ids(zapi, module.params['template_names']),
'interfaces': ifs,
}
@@ -140,6 +154,11 @@ def main():
if zab_results['parentTemplates'] != value:
differences[key] = value
+
+ elif key == "interfaces":
+ if not interfaces_equal(zab_results[key], value):
+ differences[key] = value
+
elif zab_results[key] != value and zab_results[key] != str(value):
differences[key] = value