diff options
Diffstat (limited to 'roles/openshift_logging/filter_plugins')
-rw-r--r-- | roles/openshift_logging/filter_plugins/__init__.py | 0 | ||||
-rw-r--r-- | roles/openshift_logging/filter_plugins/openshift_logging.py | 29 |
2 files changed, 29 insertions, 0 deletions
diff --git a/roles/openshift_logging/filter_plugins/__init__.py b/roles/openshift_logging/filter_plugins/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/roles/openshift_logging/filter_plugins/__init__.py diff --git a/roles/openshift_logging/filter_plugins/openshift_logging.py b/roles/openshift_logging/filter_plugins/openshift_logging.py new file mode 100644 index 000000000..b42d5da5f --- /dev/null +++ b/roles/openshift_logging/filter_plugins/openshift_logging.py @@ -0,0 +1,29 @@ +import random, string +import shutil +import sys +import StringIO + +def random_word(source_alpha,length): + return ''.join(random.choice(source_alpha) for i in range(length)) + +def entry_from_named_pair(register_pairs, key): + from ansible.utils.display import Display + results = register_pairs.get("results") + if results == None: + raise RuntimeError("The dict argument does not have a 'results' entry. Must not have been created using 'register' in a loop") + for result in results: + item = result.get("item") + if item != None: + name = item.get("name") + if name == key: + return result["content"] + raise RuntimeError("There was no entry found in the dict that had an item with a name that matched {}".format(key)) + +class FilterModule(object): + ''' OpenShift Logging Filters ''' + + def filters(self): + return { + 'random_word': random_word, + 'entry_from_named_pair': entry_from_named_pair, + } |