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;
}
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());
}
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);
}
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);
}
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;
}
Aggregations