summaryrefslogtreecommitdiff
path: root/nova/block_device.py
diff options
context:
space:
mode:
authorzhangbailin <zhangbailin@inspur.com>2018-09-29 08:07:18 -0400
committerzhangbailin <zhangbailin@inspur.com>2018-10-12 02:57:58 -0400
commitc7f4190af26ad106bea29f66770b9569ab3fc4e1 (patch)
treee1cc16784936a91c710bdb83071cb97ab3d5760c /nova/block_device.py
parent686dbc3640f12a85f450ffa75c2a152e355d0b79 (diff)
downloadnova-c7f4190af26ad106bea29f66770b9569ab3fc4e1.tar.gz
Add microversion 2.67 to support volume_type
Add a new microversion 2.67 to support specify ``volume_type`` when boot instances. Part of bp boot-instance-specific-storage-backend Change-Id: I13102243f7ce36a5d44c1790f3a633703373ebf7
Diffstat (limited to 'nova/block_device.py')
-rw-r--r--nova/block_device.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/nova/block_device.py b/nova/block_device.py
index 7ff3cde3b9..c0113a350a 100644
--- a/nova/block_device.py
+++ b/nova/block_device.py
@@ -173,6 +173,7 @@ class BlockDeviceDict(dict):
source_type = api_dict.get('source_type')
device_uuid = api_dict.get('uuid')
destination_type = api_dict.get('destination_type')
+ volume_type = api_dict.get('volume_type')
if source_type == 'blank' and device_uuid:
raise exception.InvalidBDMFormat(
@@ -191,12 +192,24 @@ class BlockDeviceDict(dict):
boot_index = -1
boot_index = int(boot_index)
- # if this bdm is generated from --image ,then
+ # if this bdm is generated from --image, then
# source_type = image and destination_type = local is allowed
if not (image_uuid_specified and boot_index == 0):
raise exception.InvalidBDMFormat(
details=_("Mapping image to local is not supported."))
+ if destination_type == 'local' and volume_type:
+ raise exception.InvalidBDMFormat(
+ details=_("Specifying a volume_type with destination_type="
+ "local is not supported."))
+
+ # Specifying a volume_type with a pre-existing source volume is
+ # not supported.
+ if source_type == 'volume' and volume_type:
+ raise exception.InvalidBDMFormat(
+ details=_("Specifying volume type to existing volume is "
+ "not supported."))
+
api_dict.pop('uuid', None)
return cls(api_dict)