summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorjiataotj <jiataotj@cn.ibm.com>2013-05-28 18:20:15 +0800
committerjiataotj <jiataotj@cn.ibm.com>2013-06-24 11:30:21 +0800
commit8ee10c55b045ab6d85b41dddbbb95384d009fb9b (patch)
tree907165bb294f0c76bd8c2492540f522458036dcf /nova/compute
parentcefb0510b8f12dab17126907661d82094c31741d (diff)
downloadnova-8ee10c55b045ab6d85b41dddbbb95384d009fb9b.tar.gz
nova-8ee10c55b045ab6d85b41dddbbb95384d009fb9b.tar.xz
nova-8ee10c55b045ab6d85b41dddbbb95384d009fb9b.zip
Add invalid number checking in flavor creation api
Flavor creation api doesn't check whether 'memory_mb' argument number is integer,add invalid number checking into the flavor creation function to remind the user to input right value Fixes bug #1171278 Change-Id: I8308f66c485d8c872864661148e9eac7b685e406
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/flavors.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/nova/compute/flavors.py b/nova/compute/flavors.py
index 59d5d5715..a18b375d8 100644
--- a/nova/compute/flavors.py
+++ b/nova/compute/flavors.py
@@ -95,20 +95,20 @@ def create(name, memory, vcpus, root_gb, ephemeral_gb=0, flavorid=None,
# Some attributes are positive ( > 0) integers
for option in ['memory_mb', 'vcpus']:
try:
+ assert int(str(kwargs[option])) > 0
kwargs[option] = int(kwargs[option])
- assert kwargs[option] > 0
- except (ValueError, AssertionError):
- msg = _("'%s' argument must be greater than 0") % option
+ except (ValueError, AssertionError, TypeError):
+ msg = _("'%s' argument must be a positive integer") % option
raise exception.InvalidInput(reason=msg)
# Some attributes are non-negative ( >= 0) integers
for option in ['root_gb', 'ephemeral_gb', 'swap']:
try:
+ assert int(str(kwargs[option])) >= 0
kwargs[option] = int(kwargs[option])
- assert kwargs[option] >= 0
- except (ValueError, AssertionError):
- msg = _("'%s' argument must be greater than or equal"
- " to 0") % option
+ except (ValueError, AssertionError, TypeError):
+ msg = _("'%s' argument must be an integer greater than or"
+ " equal to 0") % option
raise exception.InvalidInput(reason=msg)
# rxtx_factor should be a positive float