diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2016-01-26 16:45:37 -0500 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2016-01-26 16:45:37 -0500 |
commit | bb8983fcfaecec5b156cee99dfe2feca5f8d3800 (patch) | |
tree | cf93ac204e549f456a7961248df0925647dad6e7 | |
parent | d1e0c0ed6470e63bb2c4b4eb13289ec2540f50d4 (diff) | |
parent | df07308395576f5fcf7089b1bb29acafde6fb122 (diff) | |
download | openshift-bb8983fcfaecec5b156cee99dfe2feca5f8d3800.tar.gz openshift-bb8983fcfaecec5b156cee99dfe2feca5f8d3800.tar.bz2 openshift-bb8983fcfaecec5b156cee99dfe2feca5f8d3800.tar.xz openshift-bb8983fcfaecec5b156cee99dfe2feca5f8d3800.zip |
Merge pull request #1286 from kwoodson/zbx_host_fix
Fixed zbx_host interface comparison and removed duplicate hostgroup names for input.
-rw-r--r-- | roles/lib_zabbix/library/zbx_host.py | 21 |
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 |