Search in sources :

Example 6 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class SolidFireSharedPrimaryDataStoreLifeCycle method getVolumeId.

private long getVolumeId(long storagePoolId) {
    StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.VOLUME_ID);
    String volumeId = storagePoolDetail.getValue();
    return Long.parseLong(volumeId);
}
Also used : StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)

Example 7 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class SolidFireSharedPrimaryDataStoreLifeCycle method deleteDataStore.

// invoked to delete primary storage that is based on the SolidFire plug-in
@Override
public boolean deleteDataStore(DataStore dataStore) {
    List<StoragePoolHostVO> hostPoolRecords = _storagePoolHostDao.listByPoolId(dataStore.getId());
    HypervisorType hypervisorType = null;
    if (hostPoolRecords.size() > 0) {
        hypervisorType = getHypervisorType(hostPoolRecords.get(0).getHostId());
    }
    if (!isSupportedHypervisorType(hypervisorType)) {
        throw new CloudRuntimeException(hypervisorType + " is not a supported hypervisor type.");
    }
    StoragePool storagePool = (StoragePool) dataStore;
    StoragePoolVO storagePoolVO = _primaryDataStoreDao.findById(storagePool.getId());
    List<VMTemplateStoragePoolVO> unusedTemplatesInPool = _tmpltMgr.getUnusedTemplatesInPool(storagePoolVO);
    for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
        _tmpltMgr.evictTemplateFromStoragePool(templatePoolVO);
    }
    Long clusterId = null;
    for (StoragePoolHostVO host : hostPoolRecords) {
        DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(storagePool);
        if (HypervisorType.VMware.equals(hypervisorType)) {
            deleteCmd.setRemoveDatastore(true);
            Map<String, String> details = new HashMap<String, String>();
            StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.DATASTORE_NAME);
            details.put(DeleteStoragePoolCommand.DATASTORE_NAME, storagePoolDetail.getValue());
            storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.IQN);
            details.put(DeleteStoragePoolCommand.IQN, storagePoolDetail.getValue());
            storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_VIP);
            details.put(DeleteStoragePoolCommand.STORAGE_HOST, storagePoolDetail.getValue());
            storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_PORT);
            details.put(DeleteStoragePoolCommand.STORAGE_PORT, storagePoolDetail.getValue());
            deleteCmd.setDetails(details);
        }
        final Answer answer = _agentMgr.easySend(host.getHostId(), deleteCmd);
        if (answer != null && answer.getResult()) {
            s_logger.info("Successfully deleted storage pool using Host ID " + host.getHostId());
            HostVO hostVO = _hostDao.findById(host.getHostId());
            if (hostVO != null) {
                clusterId = hostVO.getClusterId();
            }
            break;
        } else {
            s_logger.error("Failed to delete storage pool using Host ID " + host.getHostId() + ": " + answer.getResult());
        }
    }
    if (clusterId != null) {
        ClusterVO cluster = _clusterDao.findById(clusterId);
        GlobalLock lock = GlobalLock.getInternLock(cluster.getUuid());
        if (!lock.lock(SolidFireUtil.s_lockTimeInSeconds)) {
            String errMsg = "Couldn't lock the DB on the following string: " + cluster.getUuid();
            s_logger.debug(errMsg);
            throw new CloudRuntimeException(errMsg);
        }
        try {
            removeVolumeFromVag(storagePool.getId(), clusterId);
        } finally {
            lock.unlock();
            lock.releaseRef();
        }
    }
    deleteSolidFireVolume(storagePool.getId());
    return _primaryDataStoreHelper.deletePrimaryDataStore(dataStore);
}
Also used : StoragePool(com.cloud.storage.StoragePool) ClusterVO(com.cloud.dc.ClusterVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HashMap(java.util.HashMap) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) HostVO(com.cloud.host.HostVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) GlobalLock(com.cloud.utils.db.GlobalLock) Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO)

Example 8 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class SolidFirePrimaryDataStoreDriver method getDefaultBurstIops.

private long getDefaultBurstIops(long storagePoolId, long maxIops) {
    StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS);
    String clusterDefaultBurstIopsPercentOfMaxIops = storagePoolDetail.getValue();
    float fClusterDefaultBurstIopsPercentOfMaxIops = Float.parseFloat(clusterDefaultBurstIopsPercentOfMaxIops);
    return (long) (maxIops * fClusterDefaultBurstIopsPercentOfMaxIops);
}
Also used : StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)

Example 9 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class SolidFireUtil method getSolidFireConnection.

public static SolidFireConnection getSolidFireConnection(long storagePoolId, StoragePoolDetailsDao storagePoolDetailsDao) {
    StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.MANAGEMENT_VIP);
    String mVip = storagePoolDetail.getValue();
    storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.MANAGEMENT_PORT);
    int mPort = Integer.parseInt(storagePoolDetail.getValue());
    storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_ADMIN_USERNAME);
    String clusterAdminUsername = storagePoolDetail.getValue();
    storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_ADMIN_PASSWORD);
    String clusterAdminPassword = storagePoolDetail.getValue();
    return new SolidFireConnection(mVip, mPort, clusterAdminUsername, clusterAdminPassword);
}
Also used : StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)

Example 10 with StoragePoolDetailVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO in project cloudstack by apache.

the class SolidFirePrimaryDataStoreDriver method getDefaultMinIops.

private long getDefaultMinIops(long storagePoolId) {
    StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePoolId, SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS);
    String clusterDefaultMinIops = storagePoolDetail.getValue();
    return Long.parseLong(clusterDefaultMinIops);
}
Also used : StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)

Aggregations

StoragePoolDetailVO (org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO)11 StoragePool (com.cloud.storage.StoragePool)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Answer (com.cloud.agent.api.Answer)2 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)2 DeploymentPlan (com.cloud.deploy.DeploymentPlan)2 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)2 HostVO (com.cloud.host.HostVO)2 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)2 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)2 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)2 Volume (com.cloud.storage.Volume)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 DiskProfile (com.cloud.vm.DiskProfile)2 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)2 StoragePoolAllocator (org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator)2 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)2 Test (org.junit.Test)2 CreateStoragePoolCommand (com.cloud.agent.api.CreateStoragePoolCommand)1