Missing validator
This patch adds validator to CONFIG_SWIFT_STORAGES to make clear that values have to be paths only (without IP addresses). Change-Id: Ia5327ac2df0e8123f75934fdb3ae21dcf839f69c Fixes: rhbz#1128303
This commit is contained in:
@@ -52,7 +52,7 @@ def initConfig(controller):
|
|||||||
"setup"),
|
"setup"),
|
||||||
"PROMPT": "Enter the Swift Storage devices e.g. /path/to/dev",
|
"PROMPT": "Enter the Swift Storage devices e.g. /path/to/dev",
|
||||||
"OPTION_LIST": [],
|
"OPTION_LIST": [],
|
||||||
"VALIDATORS": [],
|
"VALIDATORS": [validate_storage],
|
||||||
"DEFAULT_VALUE": '',
|
"DEFAULT_VALUE": '',
|
||||||
"MASK_INPUT": False,
|
"MASK_INPUT": False,
|
||||||
"LOOSE_VALIDATION": True,
|
"LOOSE_VALIDATION": True,
|
||||||
@@ -162,6 +162,15 @@ def initSequences(controller):
|
|||||||
|
|
||||||
#------------------------- helper functions -------------------------
|
#------------------------- helper functions -------------------------
|
||||||
|
|
||||||
|
def validate_storage(param, options=None):
|
||||||
|
if not param:
|
||||||
|
return
|
||||||
|
if not param.startswith('/'):
|
||||||
|
raise ParamValidationError(
|
||||||
|
'Storage value has to be in format "/path/to/device".'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def validate_storage_size(param, options=None):
|
def validate_storage_size(param, options=None):
|
||||||
match = re.match(r'\d+G|\d+M|\d+K', param, re.IGNORECASE)
|
match = re.match(r'\d+G|\d+M|\d+K', param, re.IGNORECASE)
|
||||||
if not match:
|
if not match:
|
||||||
|
|||||||
Reference in New Issue
Block a user