Search in sources :

Example 16 with SnapshotDetailsVO

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

the class SolidFirePrimaryDataStoreDriver method deleteSolidFireSnapshot.

private void deleteSolidFireSnapshot(SolidFireUtil.SolidFireConnection sfConnection, long csSnapshotId, long sfSnapshotId) {
    SolidFireUtil.deleteSnapshot(sfConnection, sfSnapshotId);
    final long volumeId;
    final VolumeVO volume;
    SnapshotVO snapshot = snapshotDao.findById(csSnapshotId);
    SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.ORIG_CS_VOLUME_ID);
    if (snapshotDetails != null && snapshotDetails.getValue() != null) {
        volumeId = Long.valueOf(snapshotDetails.getValue());
    } else {
        volumeId = snapshot.getVolumeId();
    }
    volume = volumeDao.findById(volumeId);
    if (volume == null) {
        // if the CloudStack volume has been deleted
        List<SnapshotVO> lstSnapshots = getNonDestroyedSnapshots(snapshot.getVolumeId());
        List<SnapshotVO> lstSnapshots2 = new ArrayList<>();
        for (SnapshotVO snapshotVo : lstSnapshots) {
            // sure snapshotVo.getId() != csSnapshotId when determining if any volume snapshots remain for the given CloudStack volume.
            if (snapshotVo.getId() != csSnapshotId) {
                snapshotDetails = snapshotDetailsDao.findDetail(snapshotVo.getId(), SolidFireUtil.SNAPSHOT_ID);
                // that make use of SolidFire volumes).
                if (snapshotDetails != null && snapshotDetails.getValue() != null) {
                    lstSnapshots2.add(snapshotVo);
                }
            }
        }
        if (lstSnapshots2.isEmpty()) {
            VolumeVO volumeToDelete = volumeDao.findByIdIncludingRemoved(volumeId);
            SolidFireUtil.deleteVolume(sfConnection, Long.parseLong(volumeToDelete.getFolder()));
        }
    }
}
Also used : SnapshotVO(com.cloud.storage.SnapshotVO) VolumeVO(com.cloud.storage.VolumeVO) ArrayList(java.util.ArrayList) SnapshotDetailsVO(com.cloud.storage.dao.SnapshotDetailsVO)

Example 17 with SnapshotDetailsVO

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

the class SolidFirePrimaryDataStoreDriver method createTempVolume.

private void createTempVolume(SnapshotInfo snapshotInfo, long storagePoolId) {
    long csSnapshotId = snapshotInfo.getId();
    SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.SNAPSHOT_ID);
    if (snapshotDetails == null || snapshotDetails.getValue() == null) {
        throw new CloudRuntimeException("'createTempVolume(SnapshotInfo, long)' should not be invoked unless " + SolidFireUtil.SNAPSHOT_ID + " exists.");
    }
    SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, storagePoolDetailsDao);
    snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, "tempVolume");
    if (snapshotDetails != null && snapshotDetails.getValue() != null && snapshotDetails.getValue().equalsIgnoreCase("create")) {
        long sfAccountId = getCreateSolidFireAccountId(sfConnection, snapshotInfo.getAccountId(), storagePoolId);
        SolidFireUtil.SolidFireVolume sfVolume = createCloneFromSnapshot(sfConnection, csSnapshotId, sfAccountId);
        addTempVolumeId(csSnapshotId, String.valueOf(sfVolume.getId()));
        handleSnapshotDetails(csSnapshotId, DiskTO.IQN, sfVolume.getIqn());
        handleSnapshotDetails(csSnapshotId, DiskTO.SCSI_NAA_DEVICE_ID, sfVolume.getScsiNaaDeviceId());
    } else if (snapshotDetails != null && snapshotDetails.getValue() != null && snapshotDetails.getValue().equalsIgnoreCase("delete")) {
        snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.VOLUME_ID);
        SolidFireUtil.deleteVolume(sfConnection, Long.parseLong(snapshotDetails.getValue()));
        removeTempVolumeId(csSnapshotId);
        snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, DiskTO.IQN);
        snapshotDetailsDao.remove(snapshotDetails.getId());
        snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, DiskTO.SCSI_NAA_DEVICE_ID);
        snapshotDetailsDao.remove(snapshotDetails.getId());
    } else {
        throw new CloudRuntimeException("Invalid state in 'createTempVolume(SnapshotInfo, long)'");
    }
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) SolidFireUtil(org.apache.cloudstack.storage.datastore.util.SolidFireUtil) SnapshotDetailsVO(com.cloud.storage.dao.SnapshotDetailsVO)

Example 18 with SnapshotDetailsVO

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

the class SolidFirePrimaryDataStoreDriver method addTempVolumeId.

private void addTempVolumeId(long csSnapshotId, String tempVolumeId) {
    SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.VOLUME_ID);
    if (snapshotDetails == null || snapshotDetails.getValue() == null) {
        throw new CloudRuntimeException("'addTempVolumeId' should not be invoked unless " + SolidFireUtil.VOLUME_ID + " exists.");
    }
    String originalVolumeId = snapshotDetails.getValue();
    handleSnapshotDetails(csSnapshotId, SolidFireUtil.TEMP_VOLUME_ID, originalVolumeId);
    handleSnapshotDetails(csSnapshotId, SolidFireUtil.VOLUME_ID, tempVolumeId);
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) SnapshotDetailsVO(com.cloud.storage.dao.SnapshotDetailsVO)

Example 19 with SnapshotDetailsVO

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

the class SolidFirePrimaryDataStoreDriver method handleSnapshotDetails.

private void handleSnapshotDetails(long csSnapshotId, String name, String value) {
    snapshotDetailsDao.removeDetail(csSnapshotId, name);
    SnapshotDetailsVO snapshotDetails = new SnapshotDetailsVO(csSnapshotId, name, value, false);
    snapshotDetailsDao.persist(snapshotDetails);
}
Also used : SnapshotDetailsVO(com.cloud.storage.dao.SnapshotDetailsVO)

Example 20 with SnapshotDetailsVO

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

the class SolidFirePrimaryDataStoreDriver method createCloneFromSnapshot.

private SolidFireUtil.SolidFireVolume createCloneFromSnapshot(SolidFireUtil.SolidFireConnection sfConnection, long csSnapshotId, long sfAccountId) {
    SnapshotDetailsVO snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.VOLUME_ID);
    long sfVolumeId = Long.parseLong(snapshotDetails.getValue());
    snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.SNAPSHOT_ID);
    long sfSnapshotId = Long.parseLong(snapshotDetails.getValue());
    SolidFireUtil.SolidFireSnapshot sfSnapshot = SolidFireUtil.getSnapshot(sfConnection, sfVolumeId, sfSnapshotId);
    long newSfVolumeId = SolidFireUtil.createClone(sfConnection, sfVolumeId, sfSnapshotId, sfAccountId, SolidFireUtil.getSolidFireVolumeName(sfSnapshot.getName()), null);
    snapshotDetails = snapshotDetailsDao.findDetail(csSnapshotId, SolidFireUtil.STORAGE_POOL_ID);
    long storagePoolId = Long.parseLong(snapshotDetails.getValue());
    final Iops iops = getIops(MIN_IOPS_FOR_TEMP_VOLUME, MAX_IOPS_FOR_TEMP_VOLUME, storagePoolId);
    SolidFireUtil.modifyVolume(sfConnection, newSfVolumeId, null, null, iops.getMinIops(), iops.getMaxIops(), iops.getBurstIops());
    return SolidFireUtil.getVolume(sfConnection, newSfVolumeId);
}
Also used : SolidFireUtil(org.apache.cloudstack.storage.datastore.util.SolidFireUtil) 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