From cce5cf45f738ed95a96a4526253bec01a15277f0 Mon Sep 17 00:00:00 2001 From: Rongze Zhu Date: Wed, 12 Sep 2012 09:18:53 +0000 Subject: Return 400 if create volume snapshot force parameter is invalid Fixes bug #1014689 * Add is_valid_boolstr function in utils.py * Add force parameter check in SnapshotsController.create() * Add unittest for invalid force parameter. Change-Id: Ie6a07a2ac589da76f52a82b126a6d66e5987edc4 --- nova/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nova/utils.py') diff --git a/nova/utils.py b/nova/utils.py index 31d62a611..41b268c2e 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -941,6 +941,15 @@ def bool_from_str(val): val.lower() == 'y' +def is_valid_boolstr(val): + """Check if the provided string is a valid bool string or not. """ + val = str(val).lower() + return val == 'true' or val == 'false' or \ + val == 'yes' or val == 'no' or \ + val == 'y' or val == 'n' or \ + val == '1' or val == '0' + + def is_valid_ipv4(address): """valid the address strictly as per format xxx.xxx.xxx.xxx. where xxx is a value between 0 and 255. -- cgit