From f50ff361e27a8ca688c0f1ba448bbc8bfb284905 Mon Sep 17 00:00:00 2001 From: Dirk Mueller <dirk@dmllr.de> Date: Thu, 27 Jun 2013 19:13:01 +0200 Subject: [PATCH] Skip setting volume_size if not given When the block-device parameters skip volume_size, don't set it. Setting to an empty volume_size would be invalid as it has to be an integer, and Nova API will reject the request if api validation is implemented. (proposed e.g. at https://review.openstack.org/#/c/34749/) Fixes bug LP #1199539 Change-Id: I7ab518886abf8d449caf1c70563a79a990d7765e --- novaclient/tests/v1_1/test_shell.py | 1 - novaclient/v1_1/base.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index 0107b0284..66ffca8a0 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -275,7 +275,6 @@ class ShellTest(utils.TestCase): 'name': 'some-server', 'block_device_mapping': [ { - 'volume_size': '', 'volume_id': 'blah', 'delete_on_termination': '0', 'device_name': 'vda' diff --git a/novaclient/v1_1/base.py b/novaclient/v1_1/base.py index af6e689ce..e8d611aee 100644 --- a/novaclient/v1_1/base.py +++ b/novaclient/v1_1/base.py @@ -139,7 +139,8 @@ class BootingManagerWithFind(base.ManagerWithFind): else: bdm_dict['volume_id'] = id if len(mapping_parts) > 2: - bdm_dict['volume_size'] = mapping_parts[2] + if mapping_parts[2]: + bdm_dict['volume_size'] = str(int(mapping_parts[2])) if len(mapping_parts) > 3: bdm_dict['delete_on_termination'] = mapping_parts[3] bdm.append(bdm_dict)