Add API schema for v2.1 block_device_mapping extension

By defining the API schema, it is possible to separate the validation
code from the API method. The API method can be more simple.
In addition, a response of API validation error can be consistent for
the whole Nova API.

Partially implements blueprint v2-on-v3-api

Change-Id: I6d53ef2e3dad5a4ac9b67a5838f6e07606a8372b
This commit is contained in:
Yuiko Takada
2014-12-09 15:29:55 +09:00
committed by ghanshyam
parent 0fef477e3b
commit 5316aeabfe
5 changed files with 107 additions and 11 deletions

View File

@@ -384,6 +384,9 @@ def validate_and_default_volume_size(bdm):
bdm['volume_size'] = utils.validate_integer(
bdm['volume_size'], 'volume_size', min_value=0)
except exception.InvalidInput:
# NOTE: We can remove this validation code after removing
# Nova v2.0 API code because v2.1 API validates this case
# already at its REST API layer.
raise exception.InvalidBDMFormat(
details=_("Invalid volume_size."))