Search in sources :

Example 16 with BlockSnapshotSessionRestRep

use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationSnapshotSessionCopySetsForRestore.

private Set<String> getApplicationSnapshotSessionCopySetsForRestore(AssetOptionsContext ctx, URI application) {
    Set<String> restoreCopySets = new HashSet<String>();
    Set<String> copySetNames = api(ctx).application().getVolumeGroupSnapsetSessionSets(application).getCopySets();
    boolean isRP = false;
    NamedVolumesList volsInApp = api(ctx).application().getVolumeByApplication(application);
    if (volsInApp != null && volsInApp.getVolumes() != null && !volsInApp.getVolumes().isEmpty()) {
        VolumeRestRep firstVol = api(ctx).blockVolumes().get(volsInApp.getVolumes().get(0).getId());
        isRP = BlockStorageUtils.isRPVolume(firstVol);
    }
    if (isRP) {
        List<VolumeRestRep> applicationVolumes = api(ctx).blockVolumes().getByRefs(api(ctx).application().getVolumeByApplication(application).getVolumes());
        Set<String> sourceRepGrpNames = new HashSet<String>();
        for (VolumeRestRep volume : applicationVolumes) {
            if (volume.getReplicationGroupInstance() != null && BlockStorageUtils.isRPSourceVolume(volume)) {
                sourceRepGrpNames.add(volume.getReplicationGroupInstance());
            }
        }
        for (String copySetName : copySetNames) {
            VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
            input.setCopySetName(copySetName);
            BlockSnapshotSessionList sessions = api(ctx).application().getVolumeGroupSnapshotSessionsByCopySet(application, input);
            if (sessions != null && sessions.getSnapSessionRelatedResourceList() != null && !sessions.getSnapSessionRelatedResourceList().isEmpty()) {
                BlockSnapshotSessionRestRep sessionRep = api(ctx).blockSnapshotSessions().get(sessions.getSnapSessionRelatedResourceList().get(0));
                if (sessionRep != null && sessionRep.getReplicationGroupInstance() != null && sourceRepGrpNames.contains(sessionRep.getReplicationGroupInstance())) {
                    restoreCopySets.add(copySetName);
                }
            }
        }
    } else {
        restoreCopySets.addAll(copySetNames);
    }
    return restoreCopySets;
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) HashSet(java.util.HashSet)

Example 17 with BlockSnapshotSessionRestRep

use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getReplicationGroupsForApplicationSnapshotSession.

protected Set<String> getReplicationGroupsForApplicationSnapshotSession(ViPRCoreClient client, URI applicationId, String copySet) {
    Set<String> options = Sets.newHashSet();
    VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
    input.setCopySetName(copySet);
    BlockSnapshotSessionList sessions = client.application().getVolumeGroupSnapshotSessionsByCopySet(applicationId, input);
    for (NamedRelatedResourceRep session : sessions.getSnapSessionRelatedResourceList()) {
        BlockSnapshotSessionRestRep sessionRep = client.blockSnapshotSessions().get(session);
        if (sessionRep != null && sessionRep.getReplicationGroupInstance() != null) {
            options.add(sessionRep.getReplicationGroupInstance());
        }
    }
    return BlockStorageUtils.stripRPTargetFromReplicationGroup(options);
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList)

Example 18 with BlockSnapshotSessionRestRep

use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.

the class BlockStorageUtils method removeSnapshotSession.

public static void removeSnapshotSession(URI snapshotSessionId, VolumeDeleteTypeEnum type) {
    Tasks<BlockSnapshotSessionRestRep> task = execute(new DeactivateBlockSnapshotSession(snapshotSessionId, type));
    addAffectedResources(task);
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) DeactivateBlockSnapshotSession(com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshotSession)

Example 19 with BlockSnapshotSessionRestRep

use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.

the class BlockSnapshotSessions method deleteSnapshotSession.

@FlashException(referrer = { "snapshotSessionDetails" })
public static void deleteSnapshotSession(String snapshotId, VolumeDeleteTypeEnum deleteType) {
    if (StringUtils.isNotBlank(snapshotId)) {
        ViPRCoreClient client = BourneUtil.getViprClient();
        Tasks<BlockSnapshotSessionRestRep> task = client.blockSnapshotSessions().deactivate(uri(snapshotId), deleteType);
        flash.put("info", MessagesUtils.get("resources.snapshot.deactivate", snapshotId));
    }
    snapshotSessionDetails(snapshotId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) FlashException(controllers.util.FlashException)

Example 20 with BlockSnapshotSessionRestRep

use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep 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)

Aggregations

BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)20 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)9 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)8 URI (java.net.URI)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 ArrayList (java.util.ArrayList)5 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)4 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)4 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 Asset (com.emc.sa.asset.annotation.Asset)3 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)3 DeactivateBlockSnapshotSession (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshotSession)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 GetBlockSnapshotSession (com.emc.sa.service.vipr.application.tasks.GetBlockSnapshotSession)1 GetBlockSnapshotSessionList (com.emc.sa.service.vipr.application.tasks.GetBlockSnapshotSessionList)1 DeactivateBlockSnapshot (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)1