summaryrefslogtreecommitdiffstats
path: root/filter_plugins/oo_zabbix_filters.py
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-08-27 14:46:47 -0400
committerKenny Woodson <kwoodson@redhat.com>2015-08-27 14:46:47 -0400
commit2483b7767d4e56e41e9890adfffe4bdc1480a11b (patch)
tree172b9391942022f73c1884219a5813269119f701 /filter_plugins/oo_zabbix_filters.py
parent96d9a943628578979b9cd0cb602bb04947c85466 (diff)
parent693be4802c2b3886b82681c5c1666b9f13d9ca36 (diff)
downloadopenshift-2483b7767d4e56e41e9890adfffe4bdc1480a11b.tar.gz
openshift-2483b7767d4e56e41e9890adfffe4bdc1480a11b.tar.bz2
openshift-2483b7767d4e56e41e9890adfffe4bdc1480a11b.tar.xz
openshift-2483b7767d4e56e41e9890adfffe4bdc1480a11b.zip
Merge pull request #520 from kwoodson/zbxupdates
Updating zabbix ansible module.
Diffstat (limited to 'filter_plugins/oo_zabbix_filters.py')
-rw-r--r--filter_plugins/oo_zabbix_filters.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/filter_plugins/oo_zabbix_filters.py b/filter_plugins/oo_zabbix_filters.py
index a473993a2..c44b874e8 100644
--- a/filter_plugins/oo_zabbix_filters.py
+++ b/filter_plugins/oo_zabbix_filters.py
@@ -60,6 +60,17 @@ class FilterModule(object):
return None
@staticmethod
+ def oo_build_zabbix_collect(data, string, value):
+ ''' Build a list of dicts from a list of data matched on string attribute
+ '''
+ rval = []
+ for item in data:
+ if item[string] == value:
+ rval.append(item)
+
+ return rval
+
+ @staticmethod
def oo_build_zabbix_list_dict(values, string):
''' Build a list of dicts with string as key for each value
'''
@@ -68,6 +79,22 @@ class FilterModule(object):
rval.append({string: value})
return rval
+ @staticmethod
+ def oo_remove_attr_from_list_dict(data, attr):
+ ''' Remove a specific attribute from a dict
+ '''
+ attrs = []
+ if isinstance(attr, str):
+ attrs.append(attr)
+ else:
+ attrs = attr
+
+ for attribute in attrs:
+ for _entry in data:
+ _entry.pop(attribute, None)
+
+ return data
+
def filters(self):
''' returns a mapping of filters to methods '''
return {
@@ -76,4 +103,6 @@ class FilterModule(object):
"oo_set_zbx_trigger_triggerid": self.oo_set_zbx_trigger_triggerid,
"oo_build_zabbix_list_dict": self.oo_build_zabbix_list_dict,
"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,
}