Search in sources :

Example 1 with DeactivateBlockSnapshot

use of com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot in project coprhd-controller by CoprHD.

the class BlockStorageUtils method removeSnapshot.

public static void removeSnapshot(URI snapshotId, VolumeDeleteTypeEnum type) {
    Tasks<BlockSnapshotRestRep> task = execute(new DeactivateBlockSnapshot(snapshotId, type));
    addAffectedResources(task);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) DeactivateBlockSnapshot(com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)

Example 2 with DeactivateBlockSnapshot

use of com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot in project coprhd-controller by CoprHD.

the class BlockStorageUtils method deactivateSnapshot.

private static void deactivateSnapshot(URI snapshotId, VolumeDeleteTypeEnum type) {
    Tasks<BlockSnapshotRestRep> tasks = execute(new DeactivateBlockSnapshot(snapshotId, type));
    addAffectedResources(tasks);
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) DeactivateBlockSnapshot(com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)

Example 3 with DeactivateBlockSnapshot

use of com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot in project coprhd-controller by CoprHD.

the class CreateBlockSnapshotService method checkAndPurgeObsoleteSnapshots.

/**
 * Check retention policy and delete obsolete snapshots if necessary
 *
 * @param volumeOrCgId - volume id or consistency group id
 */
private void checkAndPurgeObsoleteSnapshots(String volumeOrCgId) {
    if (!isRetentionRequired()) {
        return;
    }
    List<RetainedReplica> replicas = findObsoleteReplica(volumeOrCgId);
    for (RetainedReplica replica : replicas) {
        if (replica.getAssociatedReplicaIds() == null || replica.getAssociatedReplicaIds().isEmpty())
            continue;
        for (String obsoleteSnapshotId : replica.getAssociatedReplicaIds()) {
            info("Deactivating snapshot %s since it exceeds max number of snapshots allowed", obsoleteSnapshotId);
            if (ConsistencyUtils.isVolumeStorageType(storageType)) {
                if (BlockProvider.SNAPSHOT_SESSION_TYPE_VALUE.equals(type)) {
                    BlockSnapshotSessionRestRep obsoloteCopy = getClient().blockSnapshotSessions().get(uri(obsoleteSnapshotId));
                    info("Deactivating snapshot session %s", obsoloteCopy.getName());
                    execute(new DeactivateBlockSnapshotSession(uri(obsoleteSnapshotId)));
                } else {
                    BlockObjectRestRep obsoleteCopy = BlockStorageUtils.getVolume(uri(obsoleteSnapshotId));
                    info("Deactivating snapshot %s", obsoleteCopy.getName());
                    execute(new DeactivateBlockSnapshot(uri(obsoleteSnapshotId), VolumeDeleteTypeEnum.FULL));
                }
            } else {
                if (BlockProvider.CG_SNAPSHOT_SESSION_TYPE_VALUE.equals(type)) {
                    BlockSnapshotSessionRestRep obsoloteCopy = getClient().blockSnapshotSessions().get(uri(obsoleteSnapshotId));
                    info("Deactivating snapshot session %s", obsoloteCopy.getName());
                    ConsistencyUtils.removeSnapshotSession(uri(volumeOrCgId), uri(obsoleteSnapshotId));
                } else {
                    BlockObjectRestRep obsoleteCopy = BlockStorageUtils.getVolume(uri(obsoleteSnapshotId));
                    info("Deactivating snapshot %s", obsoleteCopy.getName());
                    ConsistencyUtils.removeSnapshot(uri(volumeOrCgId), uri(obsoleteSnapshotId));
                }
            }
        }
        getModelClient().delete(replica);
    }
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) DeactivateBlockSnapshotSession(com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshotSession) DeactivateBlockSnapshot(com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot) RetainedReplica(com.emc.storageos.db.client.model.uimodels.RetainedReplica) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Aggregations

DeactivateBlockSnapshot (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)3 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)2 DeactivateBlockSnapshotSession (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshotSession)1 RetainedReplica (com.emc.storageos.db.client.model.uimodels.RetainedReplica)1 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)1 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)1