use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.
the class StorageAllocatorTest method testClusterAllocatorMultiplePools.
@Test
public void testClusterAllocatorMultiplePools() {
Long newStorageId = null;
try {
createDb();
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());
StoragePoolVO newStorage = storagePoolDao.persist(storage);
newStorageId = newStorage.getId();
DiskProfile profile = new DiskProfile(volume, diskOffering, 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.size(), 1);
foundAcct++;
}
}
if (foundAcct > 1 || foundAcct == 0) {
Assert.fail();
}
} catch (Exception e) {
cleanDb();
if (newStorageId != null) {
storagePoolDao.remove(newStorageId);
}
Assert.fail();
}
}
use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.
the class StorageAllocatorTest method testZoneWideStorageAllocator.
@Test
public void testZoneWideStorageAllocator() {
try {
createDb();
StoragePoolVO pool = storagePoolDao.findById(storagePoolId);
pool.setHypervisor(HypervisorType.KVM);
pool.setScope(ScopeType.ZONE);
pool.setClusterId(null);
pool.setPodId(null);
storagePoolDao.update(pool.getId(), pool);
DiskProfile profile = new DiskProfile(volume, diskOffering, HypervisorType.KVM);
VirtualMachineProfile vmProfile = Mockito.mock(VirtualMachineProfile.class);
Mockito.when(vmProfile.getHypervisorType()).thenReturn(HypervisorType.KVM);
Mockito.when(storageMgr.storagePoolHasEnoughSpace(Matchers.anyListOf(Volume.class), Matchers.any(StoragePool.class))).thenReturn(true);
Mockito.when(storageMgr.storagePoolHasEnoughIops(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 com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.
the class StorageAllocatorTest method testLocalStorageAllocator.
@Test
public void testLocalStorageAllocator() {
try {
createDb();
StoragePoolVO pool = storagePoolDao.findById(storagePoolId);
pool.setScope(ScopeType.HOST);
storagePoolDao.update(pool.getId(), pool);
DiskOfferingVO diskOff = diskOfferingDao.findById(diskOfferingId);
diskOff.setUseLocalStorage(true);
diskOfferingDao.update(diskOfferingId, 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 com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.
the class GarbageCollectingStoragePoolAllocator method select.
@Override
public List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) {
s_logger.debug("GarbageCollectingStoragePoolAllocator looking for storage pool");
if (!_storagePoolCleanupEnabled) {
s_logger.debug("Storage pool cleanup is not enabled, so GarbageCollectingStoragePoolAllocator is being skipped.");
return null;
}
// Clean up all storage pools
storageMgr.cleanupStorage(false);
// Determine what allocator to use
StoragePoolAllocator allocator;
if (dskCh.useLocalStorage()) {
allocator = _localStoragePoolAllocator;
} else {
allocator = _firstFitStoragePoolAllocator;
}
// Try to find a storage pool after cleanup
ExcludeList myAvoids = new ExcludeList(avoid.getDataCentersToAvoid(), avoid.getPodsToAvoid(), avoid.getClustersToAvoid(), avoid.getHostsToAvoid(), avoid.getPoolsToAvoid());
return allocator.allocateToPool(dskCh, vmProfile, plan, myAvoids, returnUpTo);
}
use of com.cloud.deploy.DeploymentPlanner.ExcludeList in project cloudstack by apache.
the class ImplicitPlannerTest method checkPreferredModeNoHostsAvailable.
@Test
public void checkPreferredModeNoHostsAvailable() throws InsufficientServerCapacityException {
@SuppressWarnings("unchecked") VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
DataCenterDeployment plan = mock(DataCenterDeployment.class);
ExcludeList avoids = new ExcludeList();
initializeForTest(vmProfile, plan);
initializeForImplicitPlannerTest(false);
// Mark the host 5, 6 and 7 to be in avoid list.
avoids.addHost(5L);
avoids.addHost(6L);
avoids.addHost(7L);
List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
// Validations.
// Check cluster list is empty.
assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
}
Aggregations