diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2015-11-11 10:25:37 -0500 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2015-11-12 10:33:47 -0500 |
commit | d1d0bb94e2d2b12b857c51076b6b429d02f411c5 (patch) | |
tree | fbcf3780a8b120fd3e9a27c3abbe9d671568bbe2 /filter_plugins | |
parent | 64d45538066480b8d0ab01e4359e482cc05cec6a (diff) | |
download | openshift-d1d0bb94e2d2b12b857c51076b6b429d02f411c5.tar.gz openshift-d1d0bb94e2d2b12b857c51076b6b429d02f411c5.tar.bz2 openshift-d1d0bb94e2d2b12b857c51076b6b429d02f411c5.tar.xz openshift-d1d0bb94e2d2b12b857c51076b6b429d02f411c5.zip |
adding itservice
Diffstat (limited to 'filter_plugins')
-rw-r--r-- | filter_plugins/oo_zabbix_filters.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/filter_plugins/oo_zabbix_filters.py b/filter_plugins/oo_zabbix_filters.py index c44b874e8..fcfe43777 100644 --- a/filter_plugins/oo_zabbix_filters.py +++ b/filter_plugins/oo_zabbix_filters.py @@ -95,6 +95,54 @@ class FilterModule(object): return data + @staticmethod + def itservice_results_builder(data, clusters, keys): + '''Take a list of dict results, + loop through each results and create a hash + of: + [{clusterid: cluster1, key: 111 }] + ''' + r_list = [] + for cluster in clusters: + for results in data: + if cluster == results['item'][0]: + results = results['results'] + if results and len(results) > 0 and all([results[0].has_key(_key) for _key in keys]): + tmp = {} + tmp['clusterid'] = cluster + for key in keys: + tmp[key] = results[0][key] + r_list.append(tmp) + + return r_list + + @staticmethod + def itservice_dependency_builder(data, cluster): + '''Take a list of dict results, + loop through each results and create a hash + of: + [{clusterid: cluster1, key: 111 }] + ''' + r_list = [] + for dep in data: + if cluster == dep['clusterid']: + r_list.append({'name': '%s - %s' % (dep['clusterid'], dep['description']), 'dep_type': 'hard'}) + + return r_list + + @staticmethod + def itservice_dep_builder_list(data): + '''Take a list of dict results, + loop through each results and create a hash + of: + [{clusterid: cluster1, key: 111 }] + ''' + r_list = [] + for dep in data: + r_list.append({'name': '%s' % dep, 'dep_type': 'hard'}) + + return r_list + def filters(self): ''' returns a mapping of filters to methods ''' return { @@ -105,4 +153,7 @@ class FilterModule(object): "create_data": self.create_data, "oo_build_zabbix_collect": self.oo_build_zabbix_collect, "oo_remove_attr_from_list_dict": self.oo_remove_attr_from_list_dict, + "itservice_results_builder": self.itservice_results_builder, + "itservice_dependency_builder": self.itservice_dependency_builder, + "itservice_dep_builder_list": self.itservice_dep_builder_list, } |