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