use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO 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();
}
}
use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.
the class SolidFirePrimaryDataStoreDriver method getDefaultMaxIops.
private long getDefaultMaxIops(long storagePoolId) {
StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS);
String clusterDefaultMaxIops = storagePoolDetail.getValue();
return Long.parseLong(clusterDefaultMaxIops);
}
use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.
the class SolidFireSharedPrimaryDataStoreLifeCycle method getIopsValue.
private long getIopsValue(long storagePoolId, String iopsKey) {
StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePoolId, iopsKey);
String iops = storagePoolDetail.getValue();
return Long.parseLong(iops);
}
use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.
the class SolidFireSharedHostListener method handleVMware.
private void handleVMware(long hostId, boolean add) {
HostVO host = hostDao.findById(hostId);
if (HypervisorType.VMware.equals(host.getHypervisorType())) {
List<StoragePoolVO> storagePools = storagePoolDao.findPoolsByProvider(SolidFireUtil.SHARED_PROVIDER_NAME);
if (storagePools != null && storagePools.size() > 0) {
List<Map<String, String>> targets = new ArrayList<>();
for (StoragePoolVO storagePool : storagePools) {
if (storagePool.getClusterId().equals(host.getClusterId())) {
long storagePoolId = storagePool.getId();
StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.IQN);
String iqn = storagePoolDetail.getValue();
storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.STORAGE_VIP);
String sVip = storagePoolDetail.getValue();
storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.STORAGE_PORT);
String sPort = storagePoolDetail.getValue();
Map<String, String> details = new HashMap<>();
details.put(ModifyTargetsCommand.IQN, iqn);
details.put(ModifyTargetsCommand.STORAGE_HOST, sVip);
details.put(ModifyTargetsCommand.STORAGE_PORT, sPort);
targets.add(details);
}
}
if (targets.size() > 0) {
ModifyTargetsCommand cmd = new ModifyTargetsCommand();
cmd.setAdd(add);
cmd.setTargets(targets);
sendModifyTargetsCommand(cmd, hostId);
}
}
}
}
use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.
the class StorageAllocatorTest method testClusterAllocatorWithWrongTag.
@Test
public void testClusterAllocatorWithWrongTag() {
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("low");
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()) {
foundAcct++;
}
}
if (foundAcct != 0) {
Assert.fail();
}
} catch (Exception e) {
cleanDb();
Assert.fail();
}
}
Aggregations