summaryrefslogtreecommitdiffstats
path: root/roles/openshift_logging/filter_plugins
diff options
context:
space:
mode:
authorJeff Cantrill <jcantril@redhat.com>2017-03-08 09:17:43 -0500
committerJeff Cantrill <jcantril@redhat.com>2017-03-09 16:50:06 -0500
commit5e952859247d28abe6d5efb794ff6a1f8639000d (patch)
tree1e03d97ab6d8842db2713bce3a905c755841feae /roles/openshift_logging/filter_plugins
parentb551ba3afbe6bf2b4888bd62dc0f5a837edadb67 (diff)
downloadopenshift-5e952859247d28abe6d5efb794ff6a1f8639000d.tar.gz
openshift-5e952859247d28abe6d5efb794ff6a1f8639000d.tar.bz2
openshift-5e952859247d28abe6d5efb794ff6a1f8639000d.tar.xz
openshift-5e952859247d28abe6d5efb794ff6a1f8639000d.zip
bug 1428249. Use ES hostmount storage if it exists
Diffstat (limited to 'roles/openshift_logging/filter_plugins')
-rw-r--r--roles/openshift_logging/filter_plugins/openshift_logging.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/roles/openshift_logging/filter_plugins/openshift_logging.py b/roles/openshift_logging/filter_plugins/openshift_logging.py
index 9beffaef7..44b0b2d48 100644
--- a/roles/openshift_logging/filter_plugins/openshift_logging.py
+++ b/roles/openshift_logging/filter_plugins/openshift_logging.py
@@ -5,6 +5,18 @@
import random
+def es_storage(os_logging_facts, dc_name, pvc_claim, root='elasticsearch'):
+ '''Return a hash with the desired storage for the given ES instance'''
+ deploy_config = os_logging_facts[root]['deploymentconfigs'].get(dc_name)
+ if deploy_config:
+ storage = deploy_config['volumes']['elasticsearch-storage']
+ if storage.get('hostPath'):
+ return dict(kind='hostpath', path=storage.get('hostPath').get('path'))
+ if len(pvc_claim.strip()) > 0:
+ return dict(kind='pvc', pvc_claim=pvc_claim)
+ return dict(kind='emptydir')
+
+
def random_word(source_alpha, length):
''' Returns a random word given the source of characters to pick from and resulting length '''
return ''.join(random.choice(source_alpha) for i in range(length))
@@ -44,4 +56,5 @@ class FilterModule(object):
'random_word': random_word,
'entry_from_named_pair': entry_from_named_pair,
'map_from_pairs': map_from_pairs,
+ 'es_storage': es_storage
}