use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.
the class PrimaryDataStoreHelper method disable.
public boolean disable(final DataStore store) {
final StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
pool.setStatus(StoragePoolStatus.Disabled);
this.dataStoreDao.update(pool.getId(), pool);
return true;
}
use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.
the class ClusterScopeStoragePoolAllocator method select.
@Override
protected List<StoragePool> select(final DiskProfile dskCh, final VirtualMachineProfile vmProfile, final DeploymentPlan plan, final ExcludeList avoid, final int returnUpTo) {
s_logger.debug("ClusterScopeStoragePoolAllocator looking for storage pool");
if (dskCh.useLocalStorage()) {
// cluster wide allocator should bail out in case of local disk
return null;
}
final List<StoragePool> suitablePools = new ArrayList<>();
final long dcId = plan.getDataCenterId();
final Long podId = plan.getPodId();
final Long clusterId = plan.getClusterId();
if (podId == null) {
// only podId is passed into this call.
return null;
}
if (dskCh.getTags() != null && dskCh.getTags().length != 0) {
s_logger.debug("Looking for pools in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having tags:" + Arrays.toString(dskCh.getTags()) + ". Disabled pools will be ignored.");
} else {
s_logger.debug("Looking for pools in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + ". Disabled pools will be ignored.");
}
if (s_logger.isTraceEnabled()) {
// Log the pools details that are ignored because they are in disabled state
final List<StoragePoolVO> disabledPools = _storagePoolDao.findDisabledPoolsByScope(dcId, podId, clusterId, ScopeType.CLUSTER);
if (disabledPools != null && !disabledPools.isEmpty()) {
for (final StoragePoolVO pool : disabledPools) {
s_logger.trace("Ignoring pool " + pool + " as it is in disabled state.");
}
}
}
final List<StoragePoolVO> pools = _storagePoolDao.findPoolsByTags(dcId, podId, clusterId, dskCh.getTags());
s_logger.debug("Found pools matching tags: " + pools);
// add remaining pools in cluster, that did not match tags, to avoid set
final List<StoragePoolVO> allPools = _storagePoolDao.findPoolsByTags(dcId, podId, clusterId, null);
allPools.removeAll(pools);
for (final StoragePoolVO pool : allPools) {
s_logger.debug("Adding pool " + pool + " to avoid set since it did not match tags");
avoid.addPool(pool.getId());
}
if (pools.size() == 0) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("No storage pools available for " + ServiceOffering.StorageType.shared.toString() + " volume allocation, returning");
}
return suitablePools;
}
for (final StoragePoolVO pool : pools) {
if (suitablePools.size() == returnUpTo) {
break;
}
final StoragePool storagePool = (StoragePool) dataStoreMgr.getPrimaryDataStore(pool.getId());
if (filter(avoid, storagePool, dskCh, plan)) {
suitablePools.add(storagePool);
} else {
avoid.addPool(pool.getId());
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("ClusterScopeStoragePoolAllocator returning " + suitablePools.size() + " suitable storage pools");
}
return suitablePools;
}
use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.
the class LocalStoragePoolAllocator method select.
@Override
protected List<StoragePool> select(final DiskProfile dskCh, final VirtualMachineProfile vmProfile, final DeploymentPlan plan, final ExcludeList avoid, final int returnUpTo) {
s_logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the vm");
if (!dskCh.useLocalStorage()) {
return null;
}
if (s_logger.isTraceEnabled()) {
// Log the pools details that are ignored because they are in disabled state
final List<StoragePoolVO> disabledPools = _storagePoolDao.findDisabledPoolsByScope(plan.getDataCenterId(), plan.getPodId(), plan.getClusterId(), ScopeType.HOST);
if (disabledPools != null && !disabledPools.isEmpty()) {
for (final StoragePoolVO pool : disabledPools) {
s_logger.trace("Ignoring pool " + pool + " as it is in disabled state.");
}
}
}
final List<StoragePool> suitablePools = new ArrayList<>();
// data disk and host identified from deploying vm (attach volume case)
if (plan.getHostId() != null) {
final List<StoragePoolVO> hostTagsPools = _storagePoolDao.findLocalStoragePoolsByHostAndTags(plan.getHostId(), dskCh.getTags());
for (final StoragePoolVO pool : hostTagsPools) {
if (pool != null && pool.isLocal()) {
final StoragePool storagePool = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(pool.getId());
if (filter(avoid, storagePool, dskCh, plan)) {
s_logger.debug("Found suitable local storage pool " + pool.getId() + ", adding to list");
suitablePools.add(storagePool);
} else {
avoid.addPool(pool.getId());
}
}
if (suitablePools.size() == returnUpTo) {
break;
}
}
} else {
if (plan.getPodId() == null) {
// zone wide primary storage deployment
return null;
}
final List<StoragePoolVO> availablePools = _storagePoolDao.findLocalStoragePoolsByTags(plan.getDataCenterId(), plan.getPodId(), plan.getClusterId(), dskCh.getTags());
detectSuitableOrToAvoidPools(dskCh, plan, avoid, returnUpTo, suitablePools, availablePools);
// add remaining pools in cluster, that did not match tags, to avoid
// set
final List<StoragePoolVO> allPools = _storagePoolDao.findLocalStoragePoolsByTags(plan.getDataCenterId(), plan.getPodId(), plan.getClusterId(), null);
allPools.removeAll(availablePools);
for (final StoragePoolVO pool : allPools) {
avoid.addPool(pool.getId());
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("LocalStoragePoolAllocator returning " + suitablePools.size() + " suitable storage pools");
}
return suitablePools;
}
use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.
the class NotAValidCommand method testCreateStoragePoolCommand.
@Test
public void testCreateStoragePoolCommand() {
final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
final XsHost xsHost = Mockito.mock(XsHost.class);
final CreateStoragePoolCommand createStorageCommand = new CreateStoragePoolCommand(false, poolVO);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getHost()).thenReturn(xsHost);
final Answer answer = wrapper.execute(createStorageCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
use of com.cloud.storage.datastore.db.StoragePoolVO in project cosmic by MissionCriticalCloud.
the class NotAValidCommand method testExecuteCreateCommand.
@Test
public void testExecuteCreateCommand() {
final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
final DiskProfile diskProfile = Mockito.mock(DiskProfile.class);
final CreateCommand createCommand = new CreateCommand(diskProfile, "", poolVO, false);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(createCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
Aggregations