Merge "Add processor process_string_nofloat"

This commit is contained in:
Jenkins
2015-06-03 23:35:36 +00:00
committed by Gerrit Code Review
2 changed files with 15 additions and 0 deletions

View File

@@ -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]

View File

@@ -57,6 +57,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",