Search in sources :

Example 66 with StoragePoolVO

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;
}
Also used : StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO)

Example 67 with StoragePoolVO

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;
}
Also used : StoragePool(com.cloud.storage.StoragePool) ArrayList(java.util.ArrayList) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO)

Example 68 with StoragePoolVO

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;
}
Also used : StoragePool(com.cloud.storage.StoragePool) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) ArrayList(java.util.ArrayList)

Example 69 with StoragePoolVO

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());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) Answer(com.cloud.agent.api.Answer) AttachAnswer(com.cloud.storage.command.AttachAnswer) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) CreateStoragePoolCommand(com.cloud.agent.api.CreateStoragePoolCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 70 with StoragePoolVO

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());
}
Also used : RebootAnswer(com.cloud.agent.api.RebootAnswer) CreateAnswer(com.cloud.agent.api.storage.CreateAnswer) Answer(com.cloud.agent.api.Answer) AttachAnswer(com.cloud.storage.command.AttachAnswer) CreateCommand(com.cloud.agent.api.storage.CreateCommand) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) DiskProfile(com.cloud.vm.DiskProfile) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

StoragePoolVO (com.cloud.storage.datastore.db.StoragePoolVO)86 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)29 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)22 Test (org.junit.Test)18 HostVO (com.cloud.host.HostVO)15 VolumeVO (com.cloud.storage.VolumeVO)15 ArrayList (java.util.ArrayList)15 Answer (com.cloud.agent.api.Answer)14 Account (com.cloud.user.Account)13 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)12 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)11 StoragePool (com.cloud.storage.StoragePool)10 AttachAnswer (com.cloud.storage.command.AttachAnswer)10 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)9 VMInstanceVO (com.cloud.vm.VMInstanceVO)9 RebootAnswer (com.cloud.agent.api.RebootAnswer)8 PrimaryDataStore (com.cloud.engine.subsystem.api.storage.PrimaryDataStore)8 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)8 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)8 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)8