bug 8898: allow service offering upgrade for Running vm

This commit is contained in:
alena 2011-03-09 10:03:26 -08:00
parent e2de70f363
commit 7668e1878a
1 changed files with 6 additions and 4 deletions

View File

@ -838,10 +838,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
throw new InvalidParameterValueException("Unable to find a service offering with id " + serviceOfferingId);
}
// Check that the VM is stopped
if (!vmInstance.getState().equals(State.Stopped)) {
// Check that the VM is stopped or running
if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running))) {
s_logger.warn("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState());
throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState() + "; make sure the virtual machine is stopped and not in an error state before upgrading.");
throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState() + "; make sure the virtual machine is in Stopped or Running state before upgrading.");
}
// Check if the service offering being upgraded to is what the VM is already running with
@ -2418,7 +2418,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
UserVO user = _userDao.findById(userId);
try {
_itMgr.advanceStop(vm, forced, user, caller);
if (!_itMgr.advanceStop(vm, forced, user, caller)) {
throw new CloudRuntimeException("Unable to stop vm " + vm);
}
} catch (ResourceUnavailableException e) {
throw new CloudRuntimeException("Unable to contact the agent to stop the virtual machine " + vm, e);
} catch (OperationTimedoutException e) {