Search in sources :

Example 1 with VolumeDetailVO

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

the class SolidFireIntegrationTestManagerImpl method getSolidFireVolumeSize.

@Override
public long getSolidFireVolumeSize(String volumeUuid) {
    VolumeVO volume = volumeDao.findByUuid(volumeUuid);
    VolumeDetailVO volumeDetail = volumeDetailsDao.findDetail(volume.getId(), SolidFireUtil.VOLUME_SIZE);
    if (volumeDetail != null && volumeDetail.getValue() != null) {
        return Long.parseLong(volumeDetail.getValue());
    }
    throw new CloudRuntimeException("Unable to determine the size of the SolidFire volume");
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VolumeDetailVO(com.cloud.storage.VolumeDetailVO)

Example 2 with VolumeDetailVO

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

the class XenServerStorageMotionStrategy method handleManagedVolumePreMigration.

/**
     * Tell the underlying storage plug-in to create a new volume, put it in the VAG of the destination cluster, and
     * send a command to the destination cluster to create an SR and to attach to the SR from all hosts in the cluster.
     */
private String handleManagedVolumePreMigration(VolumeInfo volumeInfo, StoragePool storagePool, Host destHost) {
    final PrimaryDataStoreDriver pdsd = (PrimaryDataStoreDriver) volumeInfo.getDataStore().getDriver();
    VolumeDetailVO volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_CREATE, Boolean.TRUE.toString(), false);
    volumeDetailsDao.persist(volumeDetailVo);
    pdsd.createAsync(volumeInfo.getDataStore(), volumeInfo, null);
    volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_GRANT_ACCESS, Boolean.TRUE.toString(), false);
    volumeDetailsDao.persist(volumeDetailVo);
    pdsd.grantAccess(volumeInfo, destHost, volumeInfo.getDataStore());
    final Map<String, String> details = new HashMap<>();
    final String iqn = getBasicIqn(volumeInfo.getId());
    details.put(CreateStoragePoolCommand.DATASTORE_NAME, iqn);
    details.put(CreateStoragePoolCommand.IQN, iqn);
    details.put(CreateStoragePoolCommand.STORAGE_HOST, storagePool.getHostAddress());
    details.put(CreateStoragePoolCommand.STORAGE_PORT, String.valueOf(storagePool.getPort()));
    final CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, storagePool);
    cmd.setDetails(details);
    cmd.setCreateDatastore(true);
    final Answer answer = agentMgr.easySend(destHost.getId(), cmd);
    if (answer == null || !answer.getResult()) {
        String errMsg = "Error interacting with host (related to CreateStoragePoolCommand)" + (StringUtils.isNotBlank(answer.getDetails()) ? ": " + answer.getDetails() : "");
        s_logger.error(errMsg);
        throw new CloudRuntimeException(errMsg);
    }
    return iqn;
}
Also used : MigrateWithStorageCompleteAnswer(com.cloud.agent.api.MigrateWithStorageCompleteAnswer) MigrateWithStorageSendAnswer(com.cloud.agent.api.MigrateWithStorageSendAnswer) Answer(com.cloud.agent.api.Answer) MigrateWithStorageReceiveAnswer(com.cloud.agent.api.MigrateWithStorageReceiveAnswer) MigrateWithStorageAnswer(com.cloud.agent.api.MigrateWithStorageAnswer) PrimaryDataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver) HashMap(java.util.HashMap) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VolumeDetailVO(com.cloud.storage.VolumeDetailVO) CreateStoragePoolCommand(com.cloud.agent.api.CreateStoragePoolCommand)

Example 3 with VolumeDetailVO

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

the class XenServerStorageMotionStrategy method handleManagedVolumePostMigration.

private void handleManagedVolumePostMigration(VolumeInfo volumeInfo, Host srcHost, VolumeObjectTO volumeTO) {
    final Map<String, String> details = new HashMap<>();
    details.put(DeleteStoragePoolCommand.DATASTORE_NAME, volumeInfo.get_iScsiName());
    final DeleteStoragePoolCommand cmd = new DeleteStoragePoolCommand();
    cmd.setDetails(details);
    cmd.setRemoveDatastore(true);
    final Answer answer = agentMgr.easySend(srcHost.getId(), cmd);
    if (answer == null || !answer.getResult()) {
        String errMsg = "Error interacting with host (related to DeleteStoragePoolCommand)" + (StringUtils.isNotBlank(answer.getDetails()) ? ": " + answer.getDetails() : "");
        s_logger.error(errMsg);
        throw new CloudRuntimeException(errMsg);
    }
    final PrimaryDataStoreDriver pdsd = (PrimaryDataStoreDriver) volumeInfo.getDataStore().getDriver();
    pdsd.revokeAccess(volumeInfo, srcHost, volumeInfo.getDataStore());
    VolumeDetailVO volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_DELETE, Boolean.TRUE.toString(), false);
    volumeDetailsDao.persist(volumeDetailVo);
    pdsd.deleteAsync(volumeInfo.getDataStore(), volumeInfo, null);
    VolumeVO volumeVO = volDao.findById(volumeInfo.getId());
    volumeVO.setPath(volumeTO.getPath());
    volDao.update(volumeVO.getId(), volumeVO);
}
Also used : MigrateWithStorageCompleteAnswer(com.cloud.agent.api.MigrateWithStorageCompleteAnswer) MigrateWithStorageSendAnswer(com.cloud.agent.api.MigrateWithStorageSendAnswer) Answer(com.cloud.agent.api.Answer) MigrateWithStorageReceiveAnswer(com.cloud.agent.api.MigrateWithStorageReceiveAnswer) MigrateWithStorageAnswer(com.cloud.agent.api.MigrateWithStorageAnswer) VolumeVO(com.cloud.storage.VolumeVO) HashMap(java.util.HashMap) PrimaryDataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand) VolumeDetailVO(com.cloud.storage.VolumeDetailVO)

Example 4 with VolumeDetailVO

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

the class XenServerStorageMotionStrategy method handleManagedVolumesAfterFailedMigration.

private void handleManagedVolumesAfterFailedMigration(Map<VolumeInfo, DataStore> volumeToPool, Host destHost) {
    for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
        VolumeInfo volumeInfo = entry.getKey();
        StoragePool storagePool = storagePoolDao.findById(volumeInfo.getPoolId());
        if (storagePool.isManaged()) {
            final Map<String, String> details = new HashMap<>();
            details.put(DeleteStoragePoolCommand.DATASTORE_NAME, getBasicIqn(volumeInfo.getId()));
            final DeleteStoragePoolCommand cmd = new DeleteStoragePoolCommand();
            cmd.setDetails(details);
            cmd.setRemoveDatastore(true);
            final Answer answer = agentMgr.easySend(destHost.getId(), cmd);
            if (answer == null || !answer.getResult()) {
                String errMsg = "Error interacting with host (related to handleManagedVolumesAfterFailedMigration)" + (StringUtils.isNotBlank(answer.getDetails()) ? ": " + answer.getDetails() : "");
                s_logger.error(errMsg);
                // regardless of the success or lack thereof concerning this method
                return;
            }
            final PrimaryDataStoreDriver pdsd = (PrimaryDataStoreDriver) volumeInfo.getDataStore().getDriver();
            VolumeDetailVO volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_REVOKE_ACCESS, Boolean.TRUE.toString(), false);
            volumeDetailsDao.persist(volumeDetailVo);
            pdsd.revokeAccess(volumeInfo, destHost, volumeInfo.getDataStore());
            volumeDetailVo = new VolumeDetailVO(volumeInfo.getId(), PrimaryDataStoreDriver.BASIC_DELETE_FAILURE, Boolean.TRUE.toString(), false);
            volumeDetailsDao.persist(volumeDetailVo);
            pdsd.deleteAsync(volumeInfo.getDataStore(), volumeInfo, null);
        }
    }
}
Also used : MigrateWithStorageCompleteAnswer(com.cloud.agent.api.MigrateWithStorageCompleteAnswer) MigrateWithStorageSendAnswer(com.cloud.agent.api.MigrateWithStorageSendAnswer) Answer(com.cloud.agent.api.Answer) MigrateWithStorageReceiveAnswer(com.cloud.agent.api.MigrateWithStorageReceiveAnswer) MigrateWithStorageAnswer(com.cloud.agent.api.MigrateWithStorageAnswer) StoragePool(com.cloud.storage.StoragePool) HashMap(java.util.HashMap) PrimaryDataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand) VolumeDetailVO(com.cloud.storage.VolumeDetailVO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with VolumeDetailVO

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

the class SolidFirePrimaryDataStoreDriver method addBasicCreateInfoToVolumeDetails.

private void addBasicCreateInfoToVolumeDetails(long volumeId, SolidFireUtil.SolidFireVolume sfVolume) {
    VolumeDetailVO volumeDetailVo = new VolumeDetailVO(volumeId, BASIC_SF_ID, String.valueOf(sfVolume.getId()), false);
    volumeDetailsDao.persist(volumeDetailVo);
    volumeDetailVo = new VolumeDetailVO(volumeId, BASIC_IQN, sfVolume.getIqn(), false);
    volumeDetailsDao.persist(volumeDetailVo);
}
Also used : VolumeDetailVO(com.cloud.storage.VolumeDetailVO)

Aggregations

VolumeDetailVO (com.cloud.storage.VolumeDetailVO)10 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 Answer (com.cloud.agent.api.Answer)3 MigrateWithStorageAnswer (com.cloud.agent.api.MigrateWithStorageAnswer)3 MigrateWithStorageCompleteAnswer (com.cloud.agent.api.MigrateWithStorageCompleteAnswer)3 MigrateWithStorageReceiveAnswer (com.cloud.agent.api.MigrateWithStorageReceiveAnswer)3 MigrateWithStorageSendAnswer (com.cloud.agent.api.MigrateWithStorageSendAnswer)3 VolumeVO (com.cloud.storage.VolumeVO)3 HashMap (java.util.HashMap)3 PrimaryDataStoreDriver (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver)3 DeleteStoragePoolCommand (com.cloud.agent.api.DeleteStoragePoolCommand)2 HostVO (com.cloud.host.HostVO)2 SnapshotVO (com.cloud.storage.SnapshotVO)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 CopyCommandResult (org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)2 VolumeApiResult (org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult)2 CopyCmdAnswer (org.apache.cloudstack.storage.command.CopyCmdAnswer)2 CreateStoragePoolCommand (com.cloud.agent.api.CreateStoragePoolCommand)1 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1