From 868e800a1325a726c24afc752033434a80d13b2d Mon Sep 17 00:00:00 2001 From: Jeff Cantrill Date: Thu, 12 Jan 2017 16:52:23 -0500 Subject: additional cr fixes --- filter_plugins/oo_filters.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'filter_plugins/oo_filters.py') diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 707662cbf..ca2615b29 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -11,6 +11,7 @@ import pkg_resources import re import json import yaml +import random from ansible import errors from collections import Mapping @@ -921,6 +922,14 @@ Ex: # '+', .split() returns an array of the original string. return str(version).split('+')[0] +def oo_random_word(length,source='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'): + """Generates a random string of given length from a set of alphanumeric characters. + The default source uses [a-z][A-Z][0-9] + Ex: + - oo_random_word(3) => aB9 + - oo_random_word(4, source='012') => 0123 + """ + return ''.join(random.choice(source) for i in range(length)) class FilterModule(object): """ Custom ansible filter mapping """ @@ -961,4 +970,5 @@ class FilterModule(object): "oo_openshift_loadbalancer_frontends": oo_openshift_loadbalancer_frontends, "oo_openshift_loadbalancer_backends": oo_openshift_loadbalancer_backends, "to_padded_yaml": to_padded_yaml, + "oo_random_word": oo_random_word } -- cgit v1.2.3 From 65eb7e43faf38698b22b90ad3c743d1fecdc0961 Mon Sep 17 00:00:00 2001 From: Jeff Cantrill Date: Tue, 17 Jan 2017 11:42:23 -0500 Subject: use pod to generate keystores (#14) --- filter_plugins/oo_filters.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'filter_plugins/oo_filters.py') diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index ca2615b29..c9390efe6 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -922,7 +922,8 @@ Ex: # '+', .split() returns an array of the original string. return str(version).split('+')[0] -def oo_random_word(length,source='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'): + +def oo_random_word(length, source='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'): """Generates a random string of given length from a set of alphanumeric characters. The default source uses [a-z][A-Z][0-9] Ex: @@ -931,6 +932,7 @@ def oo_random_word(length,source='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST """ return ''.join(random.choice(source) for i in range(length)) + class FilterModule(object): """ Custom ansible filter mapping """ -- cgit v1.2.3