diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 9a26502492f..03283a189a7 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -299,6 +299,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager throw new InvalidParameterValueException("Fail to reset password for the virtual machine, the template is not password enabled"); } + if (userVm.getState() == State.Error || userVm.getState() == State.Expunging) { + s_logger.error("vm is not in the right state: " + vmId); + throw new InvalidParameterValueException("Vm with id " + vmId + " is not in the right state"); + } + userId = accountAndUserValidation(vmId, account, userId, userVm); boolean result = resetVMPasswordInternal(cmd, password); @@ -1571,6 +1576,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (vm == null) { throw new CloudRuntimeException("Unable to find virual machine with id " + id); } + + if (vm.getState() == State.Error || vm.getState() == State.Expunging) { + s_logger.error("vm is not in the right state: " + id); + throw new InvalidParameterValueException("Vm with id " + id + " is not in the right state"); + } String description = "";