Search in sources :

Example 16 with StoragePoolHostVO

use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.

the class ElastistorPrimaryDataStoreLifeCycle method deleteDataStore.

@SuppressWarnings("finally")
@Override
public boolean deleteDataStore(DataStore store) {
    List<StoragePoolHostVO> hostPoolRecords = _storagePoolHostDao.listByPoolId(store.getId());
    StoragePool pool = (StoragePool) store;
    // find the hypervisor where the storage is attached to.
    HypervisorType hType = null;
    if (hostPoolRecords.size() > 0) {
        hType = getHypervisorType(hostPoolRecords.get(0).getHostId());
    }
    StoragePoolVO storagePoolVO = _storagePoolDao.findById(store.getId());
    if (!(storagePoolVO.isManaged())) {
        // Remove the SR associated with the Xenserver
        for (StoragePoolHostVO host : hostPoolRecords) {
            DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(pool);
            final Answer answer = agentMgr.easySend(host.getHostId(), deleteCmd);
            if (answer != null && answer.getResult()) {
                // to all the kvm hosts.
                if (HypervisorType.KVM != hType) {
                    break;
                }
            } else {
                if (answer != null) {
                    s_logger.error("Failed to delete storage pool: " + answer.getResult());
                }
            }
        }
    }
    // delete the Elastistor volume at backend
    deleteElastistorVolume(pool, storagePoolVO.isManaged());
    return _dataStoreHelper.deletePrimaryDataStore(store);
}
Also used : HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Answer(com.cloud.agent.api.Answer) StoragePool(com.cloud.storage.StoragePool) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand)

Example 17 with StoragePoolHostVO

use of com.cloud.storage.StoragePoolHostVO in project cloudstack by apache.

the class DeploymentPlanningManagerImpl method hostCanAccessSPool.

protected boolean hostCanAccessSPool(Host host, StoragePool pool) {
    boolean hostCanAccessSPool = false;
    StoragePoolHostVO hostPoolLinkage = _poolHostDao.findByPoolHost(pool.getId(), host.getId());
    if (hostPoolLinkage != null) {
        hostCanAccessSPool = true;
    }
    s_logger.debug("Host: " + host.getId() + (hostCanAccessSPool ? " can" : " cannot") + " access pool: " + pool.getId());
    return hostCanAccessSPool;
}
Also used : StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO)

Aggregations

StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)17 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)9 StoragePool (com.cloud.storage.StoragePool)6 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)6 Answer (com.cloud.agent.api.Answer)5 HostVO (com.cloud.host.HostVO)4 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)4 DeleteStoragePoolCommand (com.cloud.agent.api.DeleteStoragePoolCommand)3 ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)3 ModifyStoragePoolCommand (com.cloud.agent.api.ModifyStoragePoolCommand)3 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)3 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)3 DB (com.cloud.utils.db.DB)3 ClusterVO (com.cloud.dc.ClusterVO)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 ArrayList (java.util.ArrayList)2 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)1 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 StorageConflictException (com.cloud.exception.StorageConflictException)1