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);
}
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);
}
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);
}
}
Aggregations