Bug:6510 add VM state check

This commit is contained in:
Kelven Yang 2011-01-21 11:57:04 -08:00
parent 4a3954690a
commit 4503222409
1 changed files with 10 additions and 0 deletions

View File

@ -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 = "";