mirror of https://github.com/apache/cloudstack.git
Merge release branch 4.17 to main
This commit is contained in:
commit
2149e82856
|
|
@ -3771,6 +3771,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
throw new InvalidParameterValueException("Invalid parameter, newServiceOffering can't be null");
|
||||
}
|
||||
|
||||
if (ServiceOffering.State.Inactive.equals(newServiceOffering.getState())) {
|
||||
throw new InvalidParameterValueException(String.format("New service offering is inactive: [%s].", newServiceOffering.getUuid()));
|
||||
}
|
||||
|
||||
if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running))) {
|
||||
s_logger.warn("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState());
|
||||
throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " " + " in state " + vmInstance.getState() +
|
||||
|
|
|
|||
|
|
@ -318,6 +318,13 @@ public class VirtualMachineManagerImplTest {
|
|||
virtualMachineManagerImpl.checkIfCanUpgrade(vmInstanceMock, serviceOfferingMock);
|
||||
}
|
||||
|
||||
@Test(expected = InvalidParameterValueException.class)
|
||||
public void testCheckIfCanUpgradeFail() {
|
||||
when(serviceOfferingMock.getState()).thenReturn(ServiceOffering.State.Inactive);
|
||||
|
||||
virtualMachineManagerImpl.checkIfCanUpgrade(vmInstanceMock, serviceOfferingMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isStorageCrossClusterMigrationTestStorageTypeEqualsCluster() {
|
||||
Mockito.doReturn(2L).when(storagePoolVoMock).getClusterId();
|
||||
|
|
|
|||
|
|
@ -5781,6 +5781,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
|
||||
}
|
||||
|
||||
if (ServiceOffering.State.Inactive.equals(serviceOffering.getState())) {
|
||||
throw new InvalidParameterValueException(String.format("Service offering is inactive: [%s].", serviceOffering.getUuid()));
|
||||
}
|
||||
|
||||
if (serviceOffering.getDiskOfferingStrictness() && overrideDiskOfferingId != null) {
|
||||
throw new InvalidParameterValueException(String.format("Cannot override disk offering id %d since provided service offering is strictly mapped to its disk offering", overrideDiskOfferingId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ public class RouterDeploymentDefinition {
|
|||
private void verifyServiceOfferingByUuid(String offeringUuid) {
|
||||
logger.debug("Verifying router service offering with uuid : " + offeringUuid);
|
||||
ServiceOfferingVO serviceOffering = serviceOfferingDao.findByUuid(offeringUuid);
|
||||
if (serviceOffering != null && serviceOffering.isSystemUse()) {
|
||||
if (serviceOffering != null && serviceOffering.isSystemUse() && ServiceOffering.State.Active.equals(serviceOffering.getState())) {
|
||||
DiskOfferingVO diskOffering = diskOfferingDao.findById(serviceOffering.getDiskOfferingId());
|
||||
boolean isLocalStorage = ConfigurationManagerImpl.SystemVMUseLocalStorage.valueIn(dest.getDataCenter().getId());
|
||||
if (isLocalStorage == diskOffering.isUseLocalStorage()) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import static org.mockito.ArgumentMatchers.any;
|
|||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyMap;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
|
@ -44,6 +45,7 @@ import com.cloud.user.dao.UserDataDao;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.cloudstack.api.BaseCmd.HTTPMethod;
|
||||
import org.apache.cloudstack.api.command.user.vm.ResetVMUserDataCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
|
@ -59,13 +61,16 @@ import org.mockito.Mockito;
|
|||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.cloud.configuration.Resource;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.network.NetworkModel;
|
||||
|
|
@ -84,11 +89,13 @@ import com.cloud.storage.dao.GuestOSDao;
|
|||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountService;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.UserVmDetailsDao;
|
||||
|
|
@ -135,6 +142,12 @@ public class UserVmManagerImplTest {
|
|||
@Mock
|
||||
private AccountManager accountManager;
|
||||
|
||||
@Mock
|
||||
private AccountService accountService;
|
||||
|
||||
@Mock
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Mock
|
||||
private UserVmDetailsDao userVmDetailVO;
|
||||
|
||||
|
|
@ -174,7 +187,16 @@ public class UserVmManagerImplTest {
|
|||
@Mock
|
||||
private VolumeDao volumeDaoMock;
|
||||
|
||||
private long vmId = 1l;
|
||||
@Mock
|
||||
AccountVO account;
|
||||
|
||||
@Mock
|
||||
private ServiceOfferingVO serviceOffering;
|
||||
|
||||
private static final long vmId = 1l;
|
||||
private static final long zoneId = 2L;
|
||||
private static final long accountId = 3L;
|
||||
private static final long serviceOfferingId = 10L;
|
||||
|
||||
private static final long GiB_TO_BYTES = 1024 * 1024 * 1024;
|
||||
|
||||
|
|
@ -190,7 +212,7 @@ public class UserVmManagerImplTest {
|
|||
|
||||
when(_dcDao.findById(anyLong())).thenReturn(_dcMock);
|
||||
|
||||
Mockito.when(userVmDao.findById(Mockito.eq(vmId))).thenReturn(userVmVoMock);
|
||||
Mockito.when(userVmDao.findById(vmId)).thenReturn(userVmVoMock);
|
||||
|
||||
Mockito.when(callerAccount.getType()).thenReturn(Account.Type.ADMIN);
|
||||
CallContext.register(callerUser, callerAccount);
|
||||
|
|
@ -221,14 +243,14 @@ public class UserVmManagerImplTest {
|
|||
@Test
|
||||
public void validateGuestOsIdForUpdateVirtualMachineCommandTestOsTypeFound() {
|
||||
Mockito.when(updateVmCommand.getOsTypeId()).thenReturn(1l);
|
||||
Mockito.when(guestOSDao.findById(Mockito.eq(1l))).thenReturn(Mockito.mock(GuestOSVO.class));
|
||||
Mockito.when(guestOSDao.findById(1l)).thenReturn(Mockito.mock(GuestOSVO.class));
|
||||
|
||||
userVmManagerImpl.validateGuestOsIdForUpdateVirtualMachineCommand(updateVmCommand);
|
||||
}
|
||||
|
||||
@Test(expected = InvalidParameterValueException.class)
|
||||
public void validateInputsAndPermissionForUpdateVirtualMachineCommandTestVmNotFound() {
|
||||
Mockito.when(userVmDao.findById(Mockito.eq(vmId))).thenReturn(null);
|
||||
Mockito.when(userVmDao.findById(vmId)).thenReturn(null);
|
||||
|
||||
userVmManagerImpl.validateInputsAndPermissionForUpdateVirtualMachineCommand(updateVmCommand);
|
||||
}
|
||||
|
|
@ -624,6 +646,7 @@ public class UserVmManagerImplTest {
|
|||
return newRootDiskOffering;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
private ServiceOfferingVO prepareOfferingsForEncryptionValidation(long diskOfferingId, boolean encryption) {
|
||||
ServiceOfferingVO svcOffering = Mockito.mock(ServiceOfferingVO.class);
|
||||
DiskOfferingVO diskOffering = Mockito.mock(DiskOfferingVO.class);
|
||||
|
|
@ -874,4 +897,20 @@ public class UserVmManagerImplTest {
|
|||
Mockito.verify(volumeApiService).recoverVolume(volumeVOMock.getId());
|
||||
Mockito.verify(volumeDaoMock).attachVolume(volumeVOMock.getId(), vmId, UserVmManagerImpl.ROOT_DEVICE_ID);
|
||||
}
|
||||
|
||||
@Test(expected = InvalidParameterValueException.class)
|
||||
public void createVirtualMachineWithInactiveServiceOffering() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException {
|
||||
DeployVMCmd deployVMCmd = new DeployVMCmd();
|
||||
ReflectionTestUtils.setField(deployVMCmd, "zoneId", zoneId);
|
||||
ReflectionTestUtils.setField(deployVMCmd, "serviceOfferingId", serviceOfferingId);
|
||||
deployVMCmd._accountService = accountService;
|
||||
|
||||
when(accountService.finalyzeAccountId(nullable(String.class), nullable(Long.class), nullable(Long.class), eq(true))).thenReturn(accountId);
|
||||
when(accountService.getActiveAccountById(accountId)).thenReturn(account);
|
||||
when(entityManager.findById(DataCenter.class, zoneId)).thenReturn(_dcMock);
|
||||
when(entityManager.findById(ServiceOffering.class, serviceOfferingId)).thenReturn(serviceOffering);
|
||||
when(serviceOffering.getState()).thenReturn(ServiceOffering.State.Inactive);
|
||||
|
||||
userVmManagerImpl.createVirtualMachine(deployVMCmd);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,8 +140,9 @@ export default {
|
|||
methods: {
|
||||
fetchData () {
|
||||
const params = {
|
||||
domainid: this.$store.getters.userInfo.domainid,
|
||||
account: this.$store.getters.userInfo.account,
|
||||
projectid: this.$store.getters.project ? this.$store.getters.project.id : null,
|
||||
domainid: this.$store.getters.project && this.$store.getters.project.id ? null : this.$store.getters.userInfo.domainid,
|
||||
account: this.$store.getters.project && this.$store.getters.project.id ? null : this.$store.getters.userInfo.account,
|
||||
page: this.page,
|
||||
pageSize: this.pageSize
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue