use of com.emc.sa.service.vipr.application.tasks.DeleteSnapshotForApplication in project coprhd-controller by CoprHD.
the class CreateSnapshotOfApplicationService method checkAndPurgeObsoleteSnapshots.
/**
* Check retention policy and delete obsolete snapshots if necessary
*
* @param applicationId - application id
*/
private void checkAndPurgeObsoleteSnapshots(URI applicationId) {
if (!isRetentionRequired()) {
return;
}
List<RetainedReplica> replicas = findObsoleteReplica(applicationId.toString());
for (RetainedReplica replica : replicas) {
for (String applicationCopySet : replica.getAssociatedReplicaIds()) {
info("Delete application snapshots %s since it exceeds max number of clones allowed", applicationCopySet);
List<URI> snapshotSessionIds = BlockStorageUtils.getSingleSnapshotSessionPerSubGroupAndStorageSystem(applicationId, applicationCopySet, subGroups);
if (snapshotSessionIds.size() > 0) {
info("Delete snapshot sessions %s ", StringUtils.join(snapshotSessionIds, ","));
execute(new DeleteSnapshotSessionForApplication(applicationId, snapshotSessionIds));
} else {
List<URI> snapshotIds = BlockStorageUtils.getSingleSnapshotPerSubGroupAndStorageSystem(applicationId, applicationCopySet, subGroups);
info("Delete snapshot %s ", StringUtils.join(snapshotIds, ","));
execute(new DeleteSnapshotForApplication(applicationId, snapshotIds));
}
}
getModelClient().delete(replica);
}
}
Aggregations