Search in sources :

Example 31 with DiskOfferingVO

use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.

the class ManagementServerImpl method hasSuitablePoolsForVolume.

private boolean hasSuitablePoolsForVolume(final VolumeVO volume, final Host host, final VirtualMachineProfile vmProfile) {
    final DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
    final DiskProfile diskProfile = new DiskProfile(volume, diskOffering, vmProfile.getHypervisorType());
    final DataCenterDeployment plan = new DataCenterDeployment(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), null, null);
    final ExcludeList avoid = new ExcludeList();
    for (final StoragePoolAllocator allocator : _storagePoolAllocators) {
        final List<StoragePool> poolList = allocator.allocateToPool(diskProfile, vmProfile, plan, avoid, 1);
        if (poolList != null && !poolList.isEmpty()) {
            return true;
        }
    }
    return false;
}
Also used : ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) StoragePool(com.cloud.storage.StoragePool) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) DiskProfile(com.cloud.vm.DiskProfile) StoragePoolAllocator(org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)

Example 32 with DiskOfferingVO

use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.

the class UserVmManagerImplTest method prepareAndRunConfigureCustomRootDiskSizeTest.

private void prepareAndRunConfigureCustomRootDiskSizeTest(Map<String, String> customParameters, long expectedRootDiskSize, int timesVerifyIfHypervisorSupports, Long offeringRootDiskSize) {
    VMTemplateVO template = Mockito.mock(VMTemplateVO.class);
    Mockito.when(template.getId()).thenReturn(1l);
    Mockito.when(template.getSize()).thenReturn(99L * GiB_TO_BYTES);
    Mockito.when(templateDao.findById(Mockito.anyLong())).thenReturn(template);
    DiskOfferingVO diskfferingVo = Mockito.mock(DiskOfferingVO.class);
    Mockito.when(diskfferingVo.getDiskSize()).thenReturn(offeringRootDiskSize);
    Mockito.when(volumeApiService.validateVolumeSizeInBytes(Mockito.anyLong())).thenReturn(true);
    long rootDiskSize = userVmManagerImpl.configureCustomRootDiskSize(customParameters, template, Hypervisor.HypervisorType.KVM, diskfferingVo);
    Assert.assertEquals(expectedRootDiskSize, rootDiskSize);
    Mockito.verify(userVmManagerImpl, Mockito.times(timesVerifyIfHypervisorSupports)).verifyIfHypervisorSupportsRootdiskSizeOverride(Mockito.any());
}
Also used : DiskOfferingVO(com.cloud.storage.DiskOfferingVO) VMTemplateVO(com.cloud.storage.VMTemplateVO)

Example 33 with DiskOfferingVO

use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.

the class UserVmManagerImplTest method prepareResizeVolumeCmdTestNewRootDiskOffering.

@Test(expected = InvalidParameterValueException.class)
public void prepareResizeVolumeCmdTestNewRootDiskOffering() {
    VolumeVO rootVolumeOfVm = Mockito.mock(VolumeVO.class);
    DiskOfferingVO currentRootDiskOffering = Mockito.mock(DiskOfferingVO.class);
    userVmManagerImpl.prepareResizeVolumeCmd(rootVolumeOfVm, currentRootDiskOffering, null);
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 34 with DiskOfferingVO

use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.

the class UserVmManagerImplTest method prepareResizeVolumeCmdTestCurrentRootDiskOffering.

@Test(expected = InvalidParameterValueException.class)
public void prepareResizeVolumeCmdTestCurrentRootDiskOffering() {
    DiskOfferingVO newRootDiskOffering = Mockito.mock(DiskOfferingVO.class);
    VolumeVO rootVolumeOfVm = Mockito.mock(VolumeVO.class);
    userVmManagerImpl.prepareResizeVolumeCmd(rootVolumeOfVm, null, newRootDiskOffering);
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 35 with DiskOfferingVO

use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.

the class ConfigurationServerImpl method createServiceOffering.

private ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, ProvisioningType provisioningType, boolean localStorageRequired, boolean offerHA, String tags) {
    tags = cleanupTags(tags);
    DiskOfferingVO diskOfferingVO = new DiskOfferingVO(name, displayText, provisioningType, false, tags, false, false, true);
    diskOfferingVO.setUniqueName("Cloud.Com-" + name);
    diskOfferingVO = _diskOfferingDao.persistDefaultDiskOffering(diskOfferingVO);
    ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, false, null, false);
    offering.setUniqueName("Cloud.Com-" + name);
    offering.setDiskOfferingId(diskOfferingVO.getId());
    // leaving the above reference to cloud.com in as it is an identifyer and has no real world relevance
    offering = _serviceOfferingDao.persistSystemServiceOffering(offering);
    return offering;
}
Also used : DiskOfferingVO(com.cloud.storage.DiskOfferingVO) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO)

Aggregations

DiskOfferingVO (com.cloud.storage.DiskOfferingVO)86 ArrayList (java.util.ArrayList)34 ServiceOfferingVO (com.cloud.service.ServiceOfferingVO)32 VolumeVO (com.cloud.storage.VolumeVO)25 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)24 Account (com.cloud.user.Account)23 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)22 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)18 List (java.util.List)16 StoragePool (com.cloud.storage.StoragePool)15 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)14 DiskProfile (com.cloud.vm.DiskProfile)14 VMInstanceVO (com.cloud.vm.VMInstanceVO)14 HostVO (com.cloud.host.HostVO)13 NetworkVO (com.cloud.network.dao.NetworkVO)13 Pair (com.cloud.utils.Pair)13 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)12 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)12 User (com.cloud.user.User)12 HashMap (java.util.HashMap)12