Search in sources :

Example 1 with DeleteSnapshotForApplication

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);
    }
}
Also used : DeleteSnapshotSessionForApplication(com.emc.sa.service.vipr.application.tasks.DeleteSnapshotSessionForApplication) RetainedReplica(com.emc.storageos.db.client.model.uimodels.RetainedReplica) URI(java.net.URI) DeleteSnapshotForApplication(com.emc.sa.service.vipr.application.tasks.DeleteSnapshotForApplication)

Aggregations

DeleteSnapshotForApplication (com.emc.sa.service.vipr.application.tasks.DeleteSnapshotForApplication)1 DeleteSnapshotSessionForApplication (com.emc.sa.service.vipr.application.tasks.DeleteSnapshotSessionForApplication)1 RetainedReplica (com.emc.storageos.db.client.model.uimodels.RetainedReplica)1 URI (java.net.URI)1