summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Butcher <abutcher@redhat.com>2017-04-28 10:33:36 -0400
committerAndrew Butcher <abutcher@redhat.com>2017-05-02 11:01:44 -0400
commitb3180189b9b79aecf319d95e270a4917acf50efc (patch)
tree63ef7788c0d56a5f8160bb3f7a33d0b5231f1924
parentf029779f50fe1fa9b56060ede2fcaeea29f5b198 (diff)
downloadopenshift-b3180189b9b79aecf319d95e270a4917acf50efc.tar.gz
openshift-b3180189b9b79aecf319d95e270a4917acf50efc.tar.bz2
openshift-b3180189b9b79aecf319d95e270a4917acf50efc.tar.xz
openshift-b3180189b9b79aecf319d95e270a4917acf50efc.zip
Refactor secret generation for python3.
-rw-r--r--filter_plugins/oo_filters.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index 10c8600ba..d61184c48 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -11,6 +11,7 @@ import pdb
import random
import re
+from base64 import b64encode
from collections import Mapping
# pylint no-name-in-module and import-error disabled here because pylint
# fails to properly detect the packages when installed in a virtualenv
@@ -672,8 +673,7 @@ def oo_generate_secret(num_bytes):
if not isinstance(num_bytes, int):
raise errors.AnsibleFilterError("|failed expects num_bytes is int")
- secret = os.urandom(num_bytes)
- return secret.encode('base-64').strip()
+ return b64encode(os.urandom(num_bytes)).decode('utf-8')
def to_padded_yaml(data, level=0, indent=2, **kw):