use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.
the class DiskOfferingDaoImpl method remove.
@Override
public boolean remove(Long id) {
DiskOfferingVO diskOffering = createForUpdate();
diskOffering.setRemoved(new Date());
return update(id, diskOffering);
}
use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.
the class ServiceOfferingDaoImpl method createSystemServiceOfferings.
@Override
public List<ServiceOfferingVO> createSystemServiceOfferings(String name, String uniqueName, int cpuCount, int ramSize, int cpuSpeed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, ProvisioningType provisioningType, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vmType, boolean defaultUse) {
DiskOfferingVO diskOfferingVO = new DiskOfferingVO(name, displayText, provisioningType, false, tags, recreatable, false, true);
diskOfferingVO.setUniqueName(uniqueName);
diskOfferingVO = diskOfferingDao.persistDefaultDiskOffering(diskOfferingVO);
List<ServiceOfferingVO> list = new ArrayList<ServiceOfferingVO>();
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpuCount, ramSize, cpuSpeed, rateMbps, multicastRateMbps, offerHA, displayText, systemUse, vmType, defaultUse);
offering.setUniqueName(uniqueName);
offering.setDiskOfferingId(diskOfferingVO.getId());
offering = persistSystemServiceOffering(offering);
if (offering != null) {
list.add(offering);
}
boolean useLocal = true;
if (diskOfferingVO.isUseLocalStorage()) {
// if 1st one is already local then 2nd needs to be shared
useLocal = false;
}
diskOfferingVO = new DiskOfferingVO(name + (useLocal ? " - Local Storage" : ""), displayText, provisioningType, false, tags, recreatable, useLocal, true);
diskOfferingVO.setUniqueName(uniqueName + (useLocal ? "-Local" : ""));
diskOfferingVO = diskOfferingDao.persistDefaultDiskOffering(diskOfferingVO);
offering = new ServiceOfferingVO(name + (useLocal ? " - Local Storage" : ""), cpuCount, ramSize, cpuSpeed, rateMbps, multicastRateMbps, offerHA, displayText, systemUse, vmType, defaultUse);
offering.setUniqueName(uniqueName + (useLocal ? "-Local" : ""));
offering.setDiskOfferingId(diskOfferingVO.getId());
offering = persistSystemServiceOffering(offering);
if (offering != null) {
list.add(offering);
}
return list;
}
use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.
the class ServiceOfferingDaoImpl method persistSystemServiceOffering.
@Override
@DB
public ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO offering) {
assert offering.getUniqueName() != null : "how are you going to find this later if you don't set it?";
ServiceOfferingVO vo = findByName(offering.getUniqueName());
if (vo != null) {
DiskOfferingVO diskOfferingVO = diskOfferingDao.findById(vo.getDiskOfferingId());
// check invalid CPU speed in system service offering, set it to default value of 500 Mhz if 0 CPU speed is found
if (vo.getSpeed() <= 0) {
vo.setSpeed(500);
update(vo.getId(), vo);
}
if (!vo.getUniqueName().endsWith("-Local")) {
if (diskOfferingVO.isUseLocalStorage()) {
vo.setUniqueName(vo.getUniqueName() + "-Local");
vo.setName(vo.getName() + " - Local Storage");
update(vo.getId(), vo);
}
}
return vo;
}
try {
return persist(offering);
} catch (EntityExistsException e) {
// Assume it's conflict on unique name
return findByName(offering.getUniqueName());
}
}
use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.
the class StorageAllocatorTest method createDb.
protected void createDb() {
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
dc = dcDao.persist(dc);
dcId = dc.getId();
HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), "255.255.255.255", "", 8, "test");
pod = podDao.persist(pod);
podId = pod.getId();
ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
cluster.setHypervisorType(HypervisorType.XenServer.toString());
cluster.setClusterType(ClusterType.CloudManaged);
cluster.setManagedState(ManagedState.Managed);
cluster = clusterDao.persist(cluster);
clusterId = cluster.getId();
DataStoreProvider provider = providerMgr.getDataStoreProvider(DataStoreProvider.DEFAULT_PRIMARY);
storage = new StoragePoolVO();
storage.setDataCenterId(dcId);
storage.setPodId(podId);
storage.setPoolType(StoragePoolType.NetworkFilesystem);
storage.setClusterId(clusterId);
storage.setStatus(StoragePoolStatus.Up);
storage.setScope(ScopeType.CLUSTER);
storage.setUsedBytes(1000);
storage.setCapacityBytes(20000);
storage.setHostAddress(UUID.randomUUID().toString());
storage.setPath(UUID.randomUUID().toString());
storage.setStorageProviderName(provider.getName());
storage = storagePoolDao.persist(storage);
storagePoolId = storage.getId();
storageMgr.createCapacityEntry(storage.getId());
diskOffering = new DiskOfferingVO();
diskOffering.setDiskSize(500);
diskOffering.setName("test-disk");
diskOffering.setSystemUse(false);
diskOffering.setUseLocalStorage(false);
diskOffering.setCustomized(false);
diskOffering.setRecreatable(false);
diskOffering = diskOfferingDao.persist(diskOffering);
diskOfferingId = diskOffering.getId();
volume = new VolumeVO(Volume.Type.ROOT, "volume", dcId, 1, 1, diskOffering.getId(), Storage.ProvisioningType.THIN, diskOffering.getDiskSize(), diskOffering.getMinIops(), diskOffering.getMaxIops(), "");
volume = volumeDao.persist(volume);
volumeId = volume.getId();
}
use of com.cloud.storage.DiskOfferingVO in project cloudstack by apache.
the class StorageAllocatorTest method testClusterAllocatorWithTags.
@Test
public void testClusterAllocatorWithTags() {
try {
createDb();
StoragePoolDetailVO detailVO = new StoragePoolDetailVO(this.storagePoolId, "high", "true", true);
poolDetailsDao.persist(detailVO);
DiskOfferingVO diskOff = this.diskOfferingDao.findById(diskOffering.getId());
List<String> tags = new ArrayList<String>();
tags.add("high");
diskOff.setTagsArray(tags);
diskOfferingDao.update(diskOff.getId(), diskOff);
DiskProfile profile = new DiskProfile(volume, diskOff, HypervisorType.XenServer);
VirtualMachineProfile vmProfile = Mockito.mock(VirtualMachineProfile.class);
Mockito.when(storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class), Matchers.any(StoragePool.class))).thenReturn(true);
DeploymentPlan plan = new DataCenterDeployment(dcId, podId, clusterId, null, null, null);
int foundAcct = 0;
for (StoragePoolAllocator allocator : allocators) {
List<StoragePool> pools = allocator.allocateToPool(profile, vmProfile, plan, new ExcludeList(), 1);
if (!pools.isEmpty()) {
Assert.assertEquals(pools.get(0).getId(), storage.getId());
foundAcct++;
}
}
if (foundAcct > 1 || foundAcct == 0) {
Assert.fail();
}
} catch (Exception e) {
cleanDb();
Assert.fail();
}
}
Aggregations