diff options
| author | Rongze Zhu <zrzhit@gmail.com> | 2012-09-12 09:18:53 +0000 |
|---|---|---|
| committer | Rongze Zhu <zrzhit@gmail.com> | 2012-09-13 05:19:55 +0000 |
| commit | cce5cf45f738ed95a96a4526253bec01a15277f0 (patch) | |
| tree | 5aab122f9f70071a4f9857bc16a713b884643671 /nova/utils.py | |
| parent | e72db9fe9345c48f4ea287643306d884c82f04f4 (diff) | |
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
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 9 |
1 files changed, 9 insertions, 0 deletions
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. |
