Search in sources :

Example 31 with SnapshotDetailsVO

use of com.cloud.storage.dao.SnapshotDetailsVO in project cloudstack by apache.

the class SolidFirePrimaryDataStoreDriver method revertSnapshot.

@Override
public void revertSnapshot(SnapshotInfo snapshot, SnapshotInfo snapshot2, AsyncCompletionCallback<CommandResult> callback) {
    VolumeInfo volumeInfo = snapshot.getBaseVolume();
    VolumeVO volumeVO = volumeDao.findById(volumeInfo.getId());
    if (volumeVO == null || volumeVO.getRemoved() != null) {
        String errMsg = "The volume that the snapshot belongs to no longer exists.";
        CommandResult commandResult = new CommandResult();
        commandResult.setResult(errMsg);
        callback.complete(commandResult);
        return;
    }
    SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(volumeVO.getPoolId(), storagePoolDetailsDao);
    long sfVolumeId = Long.parseLong(volumeInfo.getFolder());
    SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(snapshot.getId(), SolidFireUtil.SNAPSHOT_ID);
    long sfSnapshotId = Long.parseLong(snapshotDetails.getValue());
    SolidFireUtil.rollBackVolumeToSnapshot(sfConnection, sfVolumeId, sfSnapshotId);
    SolidFireUtil.SolidFireVolume sfVolume = SolidFireUtil.getVolume(sfConnection, sfVolumeId);
    updateVolumeDetails(volumeVO.getId(), sfVolume.getTotalSize(), sfVolume.getScsiNaaDeviceId());
    CommandResult commandResult = new CommandResult();
    callback.complete(commandResult);
}
Also used : VolumeVO(com.cloud.storage.VolumeVO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) SolidFireUtil(org.apache.cloudstack.storage.datastore.util.SolidFireUtil) SnapshotDetailsVO(com.cloud.storage.dao.SnapshotDetailsVO) CommandResult(org.apache.cloudstack.storage.command.CommandResult) CopyCommandResult(org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)

Example 32 with SnapshotDetailsVO

use of com.cloud.storage.dao.SnapshotDetailsVO in project cloudstack by apache.

the class SolidFirePrimaryDataStoreDriver method updateSnapshotDetails.

private void updateSnapshotDetails(long csSnapshotId, long csVolumeId, long sfVolumeId, long sfNewSnapshotId, long storagePoolId, long sfNewVolumeSize) {
    SnapshotDetailsVO snapshotDetail = new SnapshotDetailsVO(csSnapshotId, SolidFireUtil.ORIG_CS_VOLUME_ID, String.valueOf(csVolumeId), false);
    snapshotDetailsDao.persist(snapshotDetail);
    snapshotDetail = new SnapshotDetailsVO(csSnapshotId, SolidFireUtil.VOLUME_ID, String.valueOf(sfVolumeId), false);
    snapshotDetailsDao.persist(snapshotDetail);
    snapshotDetail = new SnapshotDetailsVO(csSnapshotId, SolidFireUtil.SNAPSHOT_ID, String.valueOf(sfNewSnapshotId), false);
    snapshotDetailsDao.persist(snapshotDetail);
    snapshotDetail = new SnapshotDetailsVO(csSnapshotId, SolidFireUtil.STORAGE_POOL_ID, String.valueOf(storagePoolId), false);
    snapshotDetailsDao.persist(snapshotDetail);
    snapshotDetail = new SnapshotDetailsVO(csSnapshotId, SolidFireUtil.VOLUME_SIZE, String.valueOf(sfNewVolumeSize), false);
    snapshotDetailsDao.persist(snapshotDetail);
}
Also used : SnapshotDetailsVO(com.cloud.storage.dao.SnapshotDetailsVO)

Example 33 with SnapshotDetailsVO

use of com.cloud.storage.dao.SnapshotDetailsVO in project cloudstack by apache.

the class SolidFireIntegrationTestUtil method getSnapshotDetails.

public List<ApiVolumeSnapshotDetailsResponse> getSnapshotDetails(String snapshotUuid) {
    SnapshotVO snapshot = snapshotDao.findByUuid(snapshotUuid);
    if (snapshot == null) {
        throw new CloudRuntimeException("Unable to find Volume for ID: " + snapshotUuid);
    }
    List<SnapshotDetailsVO> snapshotDetails = snapshotDetailsDao.listDetails(snapshot.getId());
    List<ApiVolumeSnapshotDetailsResponse> responses = new ArrayList<>();
    if (snapshotDetails != null) {
        for (SnapshotDetailsVO snapshotDetail : snapshotDetails) {
            ApiVolumeSnapshotDetailsResponse response = new ApiVolumeSnapshotDetailsResponse(snapshotDetail.getResourceId(), snapshotDetail.getName(), snapshotDetail.getValue());
            responses.add(response);
        }
    }
    return responses;
}
Also used : SnapshotVO(com.cloud.storage.SnapshotVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) ApiVolumeSnapshotDetailsResponse(org.apache.cloudstack.api.response.solidfire.ApiVolumeSnapshotDetailsResponse) SnapshotDetailsVO(com.cloud.storage.dao.SnapshotDetailsVO)

Aggregations

SnapshotDetailsVO (com.cloud.storage.dao.SnapshotDetailsVO)33 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)21 SnapshotVO (com.cloud.storage.SnapshotVO)7 VolumeVO (com.cloud.storage.VolumeVO)7 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)6 DateraObject (org.apache.cloudstack.storage.datastore.util.DateraObject)5 SolidFireUtil (org.apache.cloudstack.storage.datastore.util.SolidFireUtil)5 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)4 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)4 HostVO (com.cloud.host.HostVO)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 NoTransitionException (com.cloud.utils.fsm.NoTransitionException)2 VMInstanceVO (com.cloud.vm.VMInstanceVO)2 ArrayList (java.util.ArrayList)2 CopyCommandResult (org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult)2 CommandResult (org.apache.cloudstack.storage.command.CommandResult)2 DataStore (com.cloud.engine.subsystem.api.storage.DataStore)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 VolumeDetailVO (com.cloud.storage.VolumeDetailVO)1 SnapshotAndCopyAnswer (com.cloud.storage.command.SnapshotAndCopyAnswer)1