Pragrammatically Answer HA question posted in vCenter since it will block CloudStack from continuously operating on the VM

This commit is contained in:
Kelven Yang 2014-01-28 17:16:04 -08:00
parent 85adaf83c7
commit 4a414d3990

View File

@ -190,10 +190,10 @@ public class VirtualMachineMO extends BaseMO {
}
public boolean powerOn() throws Exception {
if(getResetSafePowerState() == VirtualMachinePowerState.POWERED_ON)
return true;
if (getResetSafePowerState() == VirtualMachinePowerState.POWERED_ON)
return true;
ManagedObjectReference morTask = _context.getService().powerOnVMTask(_mor, null);
ManagedObjectReference morTask = _context.getService().powerOnVMTask(_mor, null);
// Monitor VM questions
final Boolean[] flags = {false};
final VirtualMachineMO vmMo = this;
@ -248,17 +248,12 @@ public class VirtualMachineMO extends BaseMO {
}
});
try {
boolean result = _context.getVimClient().waitForTask(morTask);
if (result) {
_context.waitForTaskProgressDone(morTask);
return true;
} else {
s_logger.error("VMware powerOnVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}
} finally {
// make sure to let VM question monitor exit
flags[0] = true;
boolean result = _context.getVimClient().waitForTask(morTask);
if (result) {
_context.waitForTaskProgressDone(morTask);
return true;
} else {
s_logger.error("VMware powerOnVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}
return false;