From a8ad908666b963bfd152b508fcec7259cf3a545f Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Sat, 27 Jul 2013 19:51:02 +0530 Subject: [PATCH] CLOUDSTACK-3703: change service offering of stopped vm on Conflicts: server/test/com/cloud/vm/UserVmManagerTest.java --- server/src/com/cloud/vm/UserVmManagerImpl.java | 7 ++++--- server/test/com/cloud/vm/UserVmManagerTest.java | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index e4d1c78f85f..34f3de2b95e 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1139,15 +1139,16 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir // Verify input parameters VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId); - if(vmInstance.getHypervisorType() != HypervisorType.XenServer && vmInstance.getHypervisorType() != HypervisorType.VMware){ - throw new InvalidParameterValueException("This operation not permitted for this hypervisor of the vm"); - } if (vmInstance.getState().equals(State.Stopped)) { upgradeStoppedVirtualMachine(vmId, newServiceOfferingId); return true; } + if(vmInstance.getHypervisorType() != HypervisorType.XenServer && vmInstance.getHypervisorType() != HypervisorType.VMware){ + throw new InvalidParameterValueException("This operation not permitted for this hypervisor of the vm"); + } + _accountMgr.checkAccess(caller, null, true, vmInstance); // Check that the specified service offering ID is valid diff --git a/server/test/com/cloud/vm/UserVmManagerTest.java b/server/test/com/cloud/vm/UserVmManagerTest.java index 13563243e7c..a6b8daf92a8 100755 --- a/server/test/com/cloud/vm/UserVmManagerTest.java +++ b/server/test/com/cloud/vm/UserVmManagerTest.java @@ -313,6 +313,8 @@ public class UserVmManagerTest { // UserContext.current().setEventDetails("Vm Id: "+getId()); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid"); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); + //AccountVO(String accountName, long domainId, String networkDomain, short type, int regionId) + doReturn(VirtualMachine.State.Running).when(_vmInstance).getState(); CallContext.register(user, account); try {