Merge pull request #1554 from vtsingaras/vsphere_guest_reconfig_power_state

Remember power state when starting vm reconfigure
reviewable/pr18780/r1
Benno Joy 10 years ago
commit f92dcc8dca

@ -571,6 +571,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
changes = {} changes = {}
request = VI.ReconfigVM_TaskRequestMsg() request = VI.ReconfigVM_TaskRequestMsg()
shutdown = False shutdown = False
poweron = vm.is_powered_on()
memoryHotAddEnabled = bool(vm.properties.config.memoryHotAddEnabled) memoryHotAddEnabled = bool(vm.properties.config.memoryHotAddEnabled)
cpuHotAddEnabled = bool(vm.properties.config.cpuHotAddEnabled) cpuHotAddEnabled = bool(vm.properties.config.cpuHotAddEnabled)
@ -661,7 +662,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
module.fail_json( module.fail_json(
msg="Error reconfiguring vm: %s" % task.get_error_message()) msg="Error reconfiguring vm: %s" % task.get_error_message())
if vm.is_powered_off(): if vm.is_powered_off() and poweron:
try: try:
vm.power_on(sync_run=True) vm.power_on(sync_run=True)
except Exception, e: except Exception, e:

Loading…
Cancel
Save