From e34d5d9e3d416fc40f147a5914f7dceee26f5ba4 Mon Sep 17 00:00:00 2001 From: Rohit Karajgi Date: Fri, 28 Dec 2012 04:43:14 -0800 Subject: Add Compute API validations for block device map This patch adds validations to return 400 BadRequest to Create server(s) with block device mappings where appropriate and related unit tests Fixes bug 1094244 Change-Id: I778d3ed4b0871561774594e950ce98b6a1ecfcb9 --- nova/compute/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index d0a039644..9b51ba13e 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -432,7 +432,11 @@ class API(base.Base): max_count = min_count block_device_mapping = block_device_mapping or [] - + if min_count > 1 or max_count > 1: + if any(map(lambda bdm: 'volume_id' in bdm, block_device_mapping)): + msg = _('Cannot attach one or more volumes to multiple' + ' instances') + raise exception.InvalidRequest(msg) if instance_type['disabled']: raise exception.InstanceTypeNotFound( instance_type_id=instance_type['id']) -- cgit