diff options
author | Brenton Leanhardt <bleanhar@redhat.com> | 2016-01-06 14:30:09 -0500 |
---|---|---|
committer | Brenton Leanhardt <bleanhar@redhat.com> | 2016-01-06 14:30:09 -0500 |
commit | 31a18b4e6096451bd81603b92a2d4cf7d21cecef (patch) | |
tree | 26137b20f9df24d47958948baffd3b56880c9b03 /filter_plugins | |
parent | af803894ad2e214948264d105f539bb7514e92ce (diff) | |
parent | 82db6897085a1278e6b982a403875ed8671190bb (diff) | |
download | openshift-31a18b4e6096451bd81603b92a2d4cf7d21cecef.tar.gz openshift-31a18b4e6096451bd81603b92a2d4cf7d21cecef.tar.bz2 openshift-31a18b4e6096451bd81603b92a2d4cf7d21cecef.tar.xz openshift-31a18b4e6096451bd81603b92a2d4cf7d21cecef.zip |
Merge pull request #1018 from abutcher/secrets
Clean up idempotency issues with session secrets.
Diffstat (limited to 'filter_plugins')
-rw-r--r-- | filter_plugins/oo_filters.py | 19 | ||||
-rw-r--r-- | filter_plugins/openshift_master.py | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 48e27a24a..326c36f6c 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -8,12 +8,11 @@ Custom filters for use in openshift-ansible from ansible import errors from operator import itemgetter import OpenSSL.crypto -import os.path +import os import pdb import re import json - class FilterModule(object): ''' Custom ansible filters ''' @@ -366,9 +365,6 @@ class FilterModule(object): "keyfile": "/etc/origin/master/named_certificates/custom2.key", "names": [ "some-hostname.com" ] }] ''' - if not issubclass(type(certificates), list): - raise errors.AnsibleFilterError("|failed expects certificates is a list") - if not issubclass(type(named_certs_dir), unicode): raise errors.AnsibleFilterError("|failed expects named_certs_dir is unicode") @@ -468,6 +464,16 @@ class FilterModule(object): pass return clusters + @staticmethod + def oo_generate_secret(num_bytes): + ''' generate a session secret ''' + + if not issubclass(type(num_bytes), int): + raise errors.AnsibleFilterError("|failed expects num_bytes is int") + + secret = os.urandom(num_bytes) + return secret.encode('base-64').strip() + def filters(self): ''' returns a mapping of filters to methods ''' return { @@ -486,5 +492,6 @@ class FilterModule(object): "oo_parse_heat_stack_outputs": self.oo_parse_heat_stack_outputs, "oo_parse_named_certificates": self.oo_parse_named_certificates, "oo_haproxy_backend_masters": self.oo_haproxy_backend_masters, - "oo_pretty_print_cluster": self.oo_pretty_print_cluster + "oo_pretty_print_cluster": self.oo_pretty_print_cluster, + "oo_generate_secret": self.oo_generate_secret } diff --git a/filter_plugins/openshift_master.py b/filter_plugins/openshift_master.py index f12017967..8d7c62ad1 100644 --- a/filter_plugins/openshift_master.py +++ b/filter_plugins/openshift_master.py @@ -463,7 +463,6 @@ class FilterModule(object): IdentityProviderBase.validate_idp_list(idp_list) return yaml.safe_dump([idp.to_dict() for idp in idp_list], default_flow_style=False) - def filters(self): ''' returns a mapping of filters to methods ''' return {"translate_idps": self.translate_idps} |