Search in sources :

Example 6 with RetainedReplica

use of com.emc.storageos.db.client.model.uimodels.RetainedReplica 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)

Example 7 with RetainedReplica

use of com.emc.storageos.db.client.model.uimodels.RetainedReplica 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)

Example 8 with RetainedReplica

use of com.emc.storageos.db.client.model.uimodels.RetainedReplica in project coprhd-controller by CoprHD.

the class CreateFullCopyService method checkAndPurgeObsoleteCopies.

/**
 * Check retention policy and delete obsolete full copies if necessary
 *
 * @param volumeOrCgId - volume id or CG id
 */
private void checkAndPurgeObsoleteCopies(String volumeOrCgId) {
    if (!isRetentionRequired()) {
        return;
    }
    List<RetainedReplica> replicas = findObsoleteReplica(volumeOrCgId);
    for (RetainedReplica replica : replicas) {
        for (String obsoleteCopyId : replica.getAssociatedReplicaIds()) {
            BlockObjectRestRep obsoleteCopy = BlockStorageUtils.getVolume(uri(obsoleteCopyId));
            info("Delete full copy %s (%s) since it exceeds max number of copies allowed", obsoleteCopyId, obsoleteCopy.getName());
            if (ConsistencyUtils.isVolumeStorageType(storageType)) {
                BlockStorageUtils.removeFullCopy(uri(obsoleteCopyId), VolumeDeleteTypeEnum.FULL);
            } else {
                ConsistencyUtils.removeFullCopy(uri(volumeOrCgId), uri(obsoleteCopyId));
            }
        }
        getModelClient().delete(replica);
    }
}
Also used : RetainedReplica(com.emc.storageos.db.client.model.uimodels.RetainedReplica) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Aggregations

RetainedReplica (com.emc.storageos.db.client.model.uimodels.RetainedReplica)8 ScheduledEvent (com.emc.storageos.db.client.model.uimodels.ScheduledEvent)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)2 URI (java.net.URI)2 DeleteSnapshotForApplication (com.emc.sa.service.vipr.application.tasks.DeleteSnapshotForApplication)1 DeleteSnapshotSessionForApplication (com.emc.sa.service.vipr.application.tasks.DeleteSnapshotSessionForApplication)1 DeactivateBlockSnapshot (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)1 DeactivateBlockSnapshotSession (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshotSession)1 NamedElement (com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)1 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)1 OrderCreateParam (com.emc.vipr.model.catalog.OrderCreateParam)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1