From 5a8578c038ccae5a19549168b46d4aaa79f55af5 Mon Sep 17 00:00:00 2001 From: Javier Pena Date: Wed, 27 May 2015 12:53:05 +0200 Subject: [PATCH] Add processor process_string_nofloat In some corner cases, the Heat auth_encryption_key value set by the user or randomly can be convertible into a float number. This will make the puppet-heat module to complain, because the size() function from puppetlabs-stdlib will check that before returning the array size. Fixing this by implementing a new processor, that will check for those cases and change the value to a random 16 char hex string if needed. Change-Id: I6d9541692f9f87b100ae1e4651038297c802cbf4 --- packstack/installer/processors.py | 14 ++++++++++++++ packstack/plugins/heat_650.py | 1 + 2 files changed, 15 insertions(+) diff --git a/packstack/installer/processors.py b/packstack/installer/processors.py index 948abbed6..3ef124849 100644 --- a/packstack/installer/processors.py +++ b/packstack/installer/processors.py @@ -121,3 +121,17 @@ def process_password(param, param_name, config=None): else: param = process_password.pw_dict[param_name] return param + + +def process_string_nofloat(param, param_name, config=None): + """ + Process a string, making sure it is *not* convertible into a float + If it is, change it into a random 16 char string, and check again + """ + while True: + try: + float(param) + except ValueError: + return param + else: + param = uuid.uuid4().hex[:16] diff --git a/packstack/plugins/heat_650.py b/packstack/plugins/heat_650.py index f07fe523d..4d453eef5 100644 --- a/packstack/plugins/heat_650.py +++ b/packstack/plugins/heat_650.py @@ -56,6 +56,7 @@ def initConfig(controller): "OPTION_LIST": [], "VALIDATORS": [validators.validate_not_empty], "DEFAULT_VALUE": uuid.uuid4().hex[:16], + "PROCESSORS": [processors.process_string_nofloat], "MASK_INPUT": True, "LOOSE_VALIDATION": False, "CONF_NAME": "CONFIG_HEAT_AUTH_ENC_KEY",