VMware: pass vm_ref to _set_machine_id

Save a method call to get the vm_ref. In spawn this value exists so
we can pass it to the method if necessary.

Change-Id: Ied43fb09fb2eec2d2c22fce17b4f98ae3f58860e
This commit is contained in:
Gary Kotton
2014-11-03 02:28:15 -08:00
parent b501773e35
commit f6c879aeb7
2 changed files with 8 additions and 4 deletions

View File

@@ -871,7 +871,8 @@ class VMwareVMOpsTestCase(test.NoDBTestCase):
mock_set_machine_id.assert_called_once_with(
self._session.vim.client.factory,
self._instance,
network_info)
network_info,
vm_ref='fake_vm_ref')
if power_on:
mock_power_on_instance.assert_called_once_with(
self._session, self._instance, vm_ref='fake_vm_ref')

View File

@@ -449,7 +449,8 @@ class VMwareVMOps(object):
# Set the machine.id parameter of the instance to inject
# the NIC configuration inside the VM
if CONF.flat_injected:
self._set_machine_id(client_factory, instance, network_info)
self._set_machine_id(client_factory, instance, network_info,
vm_ref=vm_ref)
# Set the vnc configuration of the instance, vnc port starts from 5900
if CONF.vnc_enabled:
@@ -1244,11 +1245,13 @@ class VMwareVMOps(object):
machine_id_str = machine_id_str + interface_str + '#'
return machine_id_str
def _set_machine_id(self, client_factory, instance, network_info):
def _set_machine_id(self, client_factory, instance, network_info,
vm_ref=None):
"""Set the machine id of the VM for guest tools to pick up
and reconfigure the network interfaces.
"""
vm_ref = vm_util.get_vm_ref(self._session, instance)
if vm_ref is None:
vm_ref = vm_util.get_vm_ref(self._session, instance)
machine_id_change_spec = vm_util.get_machine_id_change_spec(
client_factory,