VMware: fix bug for config drive when inventory folder is used

Config drive attachment fails if the datacenter is in an
inventory folder.

Change-Id: I5f0123f6af3af9c06e27f7c2d133f3cd1bb07fd6
Closes-bug: #1505318
This commit is contained in:
Gary Kotton 2015-10-12 10:50:50 -07:00
parent 02b7e64b29
commit 71b8d31233
2 changed files with 8 additions and 4 deletions

View File

@ -853,11 +853,13 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
for i in range(4)]
fake_progress.assert_has_calls(calls)
@mock.patch.object(vutil, 'get_inventory_path', return_value='fake_path')
@mock.patch.object(vmops.VMwareVMOps, '_attach_cdrom_to_vm')
@mock.patch.object(vmops.VMwareVMOps, '_create_config_drive')
def test_configure_config_drive(self,
mock_create_config_drive,
mock_attach_cdrom_to_vm):
mock_attach_cdrom_to_vm,
mock_get_inventory_path):
injected_files = mock.Mock()
admin_password = mock.Mock()
network_info = mock.Mock()
@ -868,9 +870,11 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
injected_files, admin_password, network_info)
upload_iso_path = self._ds.build_path("fake_iso_path")
mock_get_inventory_path.assert_called_once_with(self._session.vim,
self._dc_info.ref)
mock_create_config_drive.assert_called_once_with(self._instance,
injected_files, admin_password, network_info, self._ds.name,
self._dc_info.name, self._instance.uuid, "Fake-CookieJar")
'fake_path', self._instance.uuid, "Fake-CookieJar")
mock_attach_cdrom_to_vm.assert_called_once_with(
vm_ref, self._instance, self._ds.ref, str(upload_iso_path))

View File

@ -231,13 +231,13 @@ class VMwareVMOps(object):
injected_files, admin_password, network_info):
session_vim = self._session.vim
cookies = session_vim.client.options.transport.cookiejar
dc_path = vutil.get_inventory_path(session_vim, dc_info.ref)
uploaded_iso_path = self._create_config_drive(instance,
injected_files,
admin_password,
network_info,
datastore.name,
dc_info.name,
dc_path,
instance.uuid,
cookies)
uploaded_iso_path = datastore.build_path(uploaded_iso_path)