CLOUDSTACK-3703: change service offering of stopped vm on

This commit is contained in:
Harikrishna Patnala 2013-07-27 19:51:02 +05:30 committed by Kishan Kavala
parent b39d302888
commit b21de4006a
2 changed files with 6 additions and 4 deletions

View File

@ -1144,15 +1144,16 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
// 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

View File

@ -272,7 +272,8 @@ public class UserVmManagerTest {
// UserContext.current().setEventDetails("Vm Id: "+getId());
Account account = (Account) new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
//AccountVO(String accountName, long domainId, String networkDomain, short type, int regionId)
UserContext.registerContext(1, account, null, true);
doReturn(VirtualMachine.State.Running).when(_vmInstance).getState();
UserContext.registerContext(1, account, null, true);
when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance);