From ecfd486938e1bff9569251efbf08913818969738 Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Mon, 2 Dec 2013 17:49:07 -0800 Subject: [PATCH] CLOUDSTACK-4881: changeServiceForVirtualMachine API should be used to scale up a stopped vm only --- server/src/com/cloud/vm/UserVmManagerImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index ef9f936296e..a16f51cc8b7 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -816,8 +816,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir //UserVmVO vmInstance = _vmDao.findById(vmId); VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId); if (vmInstance == null) { - throw new InvalidParameterValueException( - "unable to find a virtual machine with id " + vmId); + throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId); + }else if (!(vmInstance.getState().equals(State.Stopped))) { + throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " " + " in state " + vmInstance.getState() + + "; make sure the virtual machine is stopped"); } _accountMgr.checkAccess(caller, null, true, vmInstance);