From b04f4ace822e2f050346a7f2ba588de4cba4f70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=A1gr?= Date: Wed, 10 Sep 2014 10:38:46 +0200 Subject: [PATCH] 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 --- packstack/plugins/swift_600.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packstack/plugins/swift_600.py b/packstack/plugins/swift_600.py index ca497f348..b632f3b69 100644 --- a/packstack/plugins/swift_600.py +++ b/packstack/plugins/swift_600.py @@ -52,7 +52,7 @@ def initConfig(controller): "setup"), "PROMPT": "Enter the Swift Storage devices e.g. /path/to/dev", "OPTION_LIST": [], - "VALIDATORS": [], + "VALIDATORS": [validate_storage], "DEFAULT_VALUE": '', "MASK_INPUT": False, "LOOSE_VALIDATION": True, @@ -162,6 +162,15 @@ def initSequences(controller): #------------------------- 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): match = re.match(r'\d+G|\d+M|\d+K', param, re.IGNORECASE) if not match: