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
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user