From 7c9761b3bb52788021b5bf0eb9726af833db4074 Mon Sep 17 00:00:00 2001 From: Unmesh Gurjar Date: Thu, 11 Oct 2012 23:48:08 -0700 Subject: Fix error on invalid delete_on_termination value 1. Fixed 500 error when an invalid value is passed to 'delete_on_termination' parameter in 'block_device_mapping' of create server API (json request). Converted the value to 'bool' (similar to XML request workflow) to fix issue. 2. Also added unit test coverage. Fixes LP: #1060955 Change-Id: Ib35040f17a3712dac45ec1e3c2f32fee17db7c03 --- nova/api/openstack/compute/servers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 89eac8bfd..cdc95db0b 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -792,7 +792,11 @@ class Controller(wsgi.Controller): block_device_mapping = None if self.ext_mgr.is_loaded('os-volumes'): - block_device_mapping = server_dict.get('block_device_mapping') + block_device_mapping = server_dict.get('block_device_mapping', []) + for bdm in block_device_mapping: + if 'delete_on_termination' in bdm: + bdm['delete_on_termination'] = utils.bool_from_str( + bdm['delete_on_termination']) ret_resv_id = False # min_count and max_count are optional. If they exist, they may come -- cgit