Don't allow success to be reported when we fail to stop vm due to no agent

connection

BUG-ID: CLOUDSTACK-2195
Bugfix-for: 4.2
Reviewed-by: Edison Su
Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1366950954 -0600
This commit is contained in:
Marcus Sorensen 2013-04-25 22:35:54 -06:00
parent efb4471dc9
commit f429c6687b
2 changed files with 9 additions and 4 deletions

View File

@ -2902,10 +2902,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
}
UserVO user = _userDao.findById(userId);
boolean status = false;
try {
VirtualMachineEntity vmEntity = _orchSrvc.getVirtualMachine(vm.getUuid());
vmEntity.stop(new Long(userId).toString());
status = vmEntity.stop(new Long(userId).toString());
if (status) {
return _vmDao.findById(vmId);
} else {
return null;
}
} catch (ResourceUnavailableException e) {
throw new CloudRuntimeException(
"Unable to contact the agent to stop the virtual machine "
@ -2915,8 +2920,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
"Unable to contact the agent to stop the virtual machine "
+ vm, e);
}
return _vmDao.findById(vmId);
}
@Override

View File

@ -1136,7 +1136,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
vmGuru.finalizeStop(profile, answer);
} catch (AgentUnavailableException e) {
s_logger.warn("Unable to stop vm, agent unavailable: " + e.toString());
} catch (OperationTimedoutException e) {
s_logger.warn("Unable to stop vm, operation timed out: " + e.toString());
} finally {
if (!stopped) {
if (!forced) {