Fix resolving image.id in servers.boot
Most places resolve id of input parameter as 'base.getid' and in the beginning of _boot function it resolves image id with such method. But in fixed place it tries to get id directly from object. But code that uses novaclient directly(without shell) falls in this place because it passes string with id to image parameter. Change-Id: Ib90e4ffa3b7835f6648a62eddf7f7b87b5ab0f7e
This commit is contained in:
parent
916993a1f6
commit
0a8fffffba
novaclient
@ -136,6 +136,31 @@ class ServersTest(utils.FixturedTestCase):
|
||||
|
||||
test_create_server_from_volume()
|
||||
|
||||
def test_create_server_boot_from_volume_bdm_v2(self):
|
||||
old_boot = self.cs.servers._boot
|
||||
|
||||
bdm = [{"volume_size": "1",
|
||||
"volume_id": "11111111-1111-1111-1111-111111111111",
|
||||
"delete_on_termination": "0",
|
||||
"device_name": "vda"}]
|
||||
|
||||
def wrapped_boot(url, key, *boot_args, **boot_kwargs):
|
||||
self.assertEqual(boot_kwargs['block_device_mapping_v2'], bdm)
|
||||
return old_boot(url, key, *boot_args, **boot_kwargs)
|
||||
|
||||
with mock.patch.object(self.cs.servers, '_boot', wrapped_boot):
|
||||
s = self.cs.servers.create(
|
||||
name="My server",
|
||||
image=1,
|
||||
flavor=1,
|
||||
meta={'foo': 'bar'},
|
||||
userdata="hello moto",
|
||||
key_name="fakekey",
|
||||
block_device_mapping_v2=bdm
|
||||
)
|
||||
self.assert_called('POST', '/os-volumes_boot')
|
||||
self.assertIsInstance(s, servers.Server)
|
||||
|
||||
def test_create_server_boot_with_nics_ipv6(self):
|
||||
old_boot = self.cs.servers._boot
|
||||
nics = [{'net-id': '11111111-1111-1111-1111-111111111111',
|
||||
|
@ -505,7 +505,7 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
# 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',
|
||||
bdm_dict = {'uuid': base.getid(image), 'source_type': 'image',
|
||||
'destination_type': 'local', 'boot_index': 0,
|
||||
'delete_on_termination': True}
|
||||
block_device_mapping_v2.insert(0, bdm_dict)
|
||||
|
Loading…
x
Reference in New Issue
Block a user