summaryrefslogtreecommitdiffstats
path: root/filter_plugins
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-07-24 10:52:29 -0400
committerKenny Woodson <kwoodson@redhat.com>2015-07-24 11:13:04 -0400
commit2a6fc886cc080ec1344d9ad4767f0fcde7ba3442 (patch)
tree85a5dc0e17c0d0c0a3d231ec808633ae05fdea7e /filter_plugins
parent97f96b71ff8abc2ccf38e745e124c68b91a71146 (diff)
downloadopenshift-2a6fc886cc080ec1344d9ad4767f0fcde7ba3442.tar.gz
openshift-2a6fc886cc080ec1344d9ad4767f0fcde7ba3442.tar.bz2
openshift-2a6fc886cc080ec1344d9ad4767f0fcde7ba3442.tar.xz
openshift-2a6fc886cc080ec1344d9ad4767f0fcde7ba3442.zip
Adding initial zabbix setup
Diffstat (limited to 'filter_plugins')
-rw-r--r--filter_plugins/oo_filters.py10
-rw-r--r--filter_plugins/oo_zabbix_filters.py79
2 files changed, 79 insertions, 10 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index 88e86f67c..47033a88e 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -232,15 +232,6 @@ class FilterModule(object):
return [x for x in data if x[filter_attr]]
@staticmethod
- def oo_build_zabbix_list_dict(values, string):
- ''' Build a list of dicts with string as key for each value
- '''
- rval = []
- for value in values:
- rval.append({string: value})
- return rval
-
- @staticmethod
def oo_parse_heat_stack_outputs(data):
''' Formats the HEAT stack output into a usable form
@@ -320,6 +311,5 @@ class FilterModule(object):
"oo_combine_key_value": self.oo_combine_key_value,
"oo_split": self.oo_split,
"oo_filter_list": self.oo_filter_list,
- "oo_build_zabbix_list_dict": self.oo_build_zabbix_list_dict,
"oo_parse_heat_stack_outputs": self.oo_parse_heat_stack_outputs
}
diff --git a/filter_plugins/oo_zabbix_filters.py b/filter_plugins/oo_zabbix_filters.py
new file mode 100644
index 000000000..a473993a2
--- /dev/null
+++ b/filter_plugins/oo_zabbix_filters.py
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# vim: expandtab:tabstop=4:shiftwidth=4
+'''
+Custom zabbix filters for use in openshift-ansible
+'''
+
+import pdb
+
+class FilterModule(object):
+ ''' Custom zabbix ansible filters '''
+
+ @staticmethod
+ def create_data(data, results, key, new_key):
+ '''Take a dict, filter through results and add results['key'] to dict
+ '''
+ new_list = [app[key] for app in results]
+ data[new_key] = new_list
+ return data
+
+ @staticmethod
+ def oo_set_zbx_trigger_triggerid(item, trigger_results):
+ '''Set zabbix trigger id from trigger results
+ '''
+ if isinstance(trigger_results, list):
+ item['triggerid'] = trigger_results[0]['triggerid']
+ return item
+
+ item['triggerid'] = trigger_results['triggerids'][0]
+ return item
+
+ @staticmethod
+ def oo_set_zbx_item_hostid(item, template_results):
+ ''' Set zabbix host id from template results
+ '''
+ if isinstance(template_results, list):
+ item['hostid'] = template_results[0]['templateid']
+ return item
+
+ item['hostid'] = template_results['templateids'][0]
+ return item
+
+ @staticmethod
+ def oo_pdb(arg):
+ ''' This pops you into a pdb instance where arg is the data passed in
+ from the filter.
+ Ex: "{{ hostvars | oo_pdb }}"
+ '''
+ pdb.set_trace()
+ return arg
+
+ @staticmethod
+ def select_by_name(ans_data, data):
+ ''' test
+ '''
+ for zabbix_item in data:
+ if ans_data['name'] == zabbix_item:
+ data[zabbix_item]['params']['hostid'] = ans_data['templateid']
+ return data[zabbix_item]['params']
+ return None
+
+ @staticmethod
+ def oo_build_zabbix_list_dict(values, string):
+ ''' Build a list of dicts with string as key for each value
+ '''
+ rval = []
+ for value in values:
+ rval.append({string: value})
+ return rval
+
+ def filters(self):
+ ''' returns a mapping of filters to methods '''
+ return {
+ "select_by_name": self.select_by_name,
+ "oo_set_zbx_item_hostid": self.oo_set_zbx_item_hostid,
+ "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,
+ }