From 8679eedb8352630012202c12a9c9acf8757802a5 Mon Sep 17 00:00:00 2001 From: jichenjc Date: Thu, 19 Mar 2015 22:58:17 +0800 Subject: [PATCH] Revert 'Remove image to local block device mapping' https://review.openstack.org/#/c/153203/3 added check for novaclient, removed the logic for both --image and --block-device are added. But actually the following valid boot command failed due to the change here, so this patch reverted original one and add some descriptions to avoid further removal. nova boot test-vm --flavor m1.medium --image centos-vm-32 --nic net-id=c3f40e33-d535-4217-916b-1450b8cd3987 --block-device id=26b7b917-2794-452a-95e5-2efb2ca6e32d,bus=sata, source=volume,bootindex=1 Change-Id: Ia29e63c72b34d3038aa591c466425e65edf5755b Partial-Bug: #1433609 --- novaclient/tests/unit/v2/test_shell.py | 7 +++++++ novaclient/v2/servers.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py index b7e8b9e9d..b1b9b8085 100644 --- a/novaclient/tests/unit/v2/test_shell.py +++ b/novaclient/tests/unit/v2/test_shell.py @@ -292,6 +292,13 @@ def test_boot_image_bdms_v2(self): 'flavorRef': '1', 'name': 'some-server', 'block_device_mapping_v2': [ + { + 'uuid': 1, + 'source_type': 'image', + 'destination_type': 'local', + 'boot_index': 0, + 'delete_on_termination': True, + }, { 'uuid': 'fake-id', 'source_type': 'volume', diff --git a/novaclient/v2/servers.py b/novaclient/v2/servers.py index 397a12ac1..582c4d840 100644 --- a/novaclient/v2/servers.py +++ b/novaclient/v2/servers.py @@ -492,6 +492,14 @@ def _boot(self, resource_url, response_key, name, image, flavor, body['server']['block_device_mapping'] = \ self._parse_block_device_mapping(block_device_mapping) elif block_device_mapping_v2: + # Following logic can't be removed because it will leaves + # a valid boot with both --image and --block-device + # failed , see bug 1433609 for more info + if image: + bdm_dict = {'uuid': image.id, 'source_type': 'image', + 'destination_type': 'local', 'boot_index': 0, + 'delete_on_termination': True} + block_device_mapping_v2.insert(0, bdm_dict) body['server']['block_device_mapping_v2'] = block_device_mapping_v2 if nics is not None: