Adding basic validation of volume size on creation, plus tests for it.

This commit is contained in:
Joshua McKenty
2010年06月24日 04:11:56 +01:00
committed by andy
parent a17abe20d3
commit 0912a1c2d5

View File

@@ -59,6 +59,13 @@ class StorageTestCase(test.TrialTestCase):
self.assertRaises(exception.Error,
storage.get_volume,
volume_id)
def test_too_big_volume(self):
vol_size = '1001'
user_id = 'fake'
self.assertRaises(TypeError,
self.mystorage.create_volume,
vol_size, user_id)
def test_run_attach_detach_volume(self):
# Create one volume and one node to test with

View File

@@ -35,7 +35,7 @@ def rangetest(**argchecks): # validate ranges for both+defaults
# for all args to be checked
if argname in kargs:
# was passed by name
if kargs[argname] < low or kargs[argname] > high:
if float(kargs[argname]) < low or float(kargs[argname]) > high:
errmsg = '{0} argument "{1}" not in {2}..{3}'
errmsg = errmsg.format(funcname, argname, low, high)
raise TypeError(errmsg)
@@ -43,9 +43,9 @@ def rangetest(**argchecks): # validate ranges for both+defaults
elif argname in positionals:
# was passed by position
position = positionals.index(argname)
if pargs[position] < low or pargs[position] > high:
errmsg = '{0} argument "{1}" not in {2}..{3}'
errmsg = errmsg.format(funcname, argname, low, high)
if float(pargs[position]) < low or float(pargs[position]) > high:
errmsg = '{0} argument "{1}" with value of {4} not in {2}..{3}'
errmsg = errmsg.format(funcname, argname, low, high, pargs[position])
raise TypeError(errmsg)
else:
pass

View File

@@ -35,6 +35,7 @@ from nova import exception
from nova import flags
from nova import rpc
from nova import utils
from nova import validate
FLAGS = flags.FLAGS
@@ -84,6 +85,7 @@ class BlockStore(object):
#TODO: aggregate the state of the system
pass
@validate.rangetest(size=(0, 100))
def create_volume(self, size, user_id):
"""
Creates an exported volume (fake or real),
Reference in New Issue
openstack/nova
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.