Search in sources :

Example 11 with BlockConsistencyGroupRestRep

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

the class BlockProvider method getVolumesByType.

@Asset("blockVolumeByType")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getVolumesByType(AssetOptionsContext ctx, URI project, String type) {
    debug("getting volumes (project=%s)", project);
    final ViPRCoreClient client = api(ctx);
    if (isVolumeType(type)) {
        return createVolumeOptions(client, listVolumesWithoutConsistencyGroup(client, project));
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = api(ctx).blockConsistencyGroups().search().byProject(project).run();
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 12 with BlockConsistencyGroupRestRep

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

the class BlockStorageUtils method addVolumesToConsistencyGroup.

public static Task<BlockConsistencyGroupRestRep> addVolumesToConsistencyGroup(URI consistencyGroupId, List<URI> volumeIds) {
    Task<BlockConsistencyGroupRestRep> task = execute(new AddVolumesToConsistencyGroup(consistencyGroupId, volumeIds));
    addAffectedResource(task);
    return task;
}
Also used : AddVolumesToConsistencyGroup(com.emc.sa.service.vipr.block.tasks.AddVolumesToConsistencyGroup) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep)

Example 13 with BlockConsistencyGroupRestRep

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

the class BlockProvider method getProtectedVolumes.

@Asset("protectedBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getProtectedVolumes(AssetOptionsContext ctx, URI project, String volumeOrConsistencyType) {
    ViPRCoreClient client = api(ctx);
    if (isVolumeType(volumeOrConsistencyType)) {
        debug("getting protected volumes (project=%s)", project);
        // Allow recoverpoint or SRDF sources
        ResourceFilter<VolumeRestRep> filter = RecoverPointPersonalityFilter.SOURCE.or(new SRDFSourceFilter());
        List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project, filter);
        // We need to filter out SRDF Metro volumes as they are not eligible for FAILOVER or SWAP
        List<VolumeRestRep> filteredVols = new ArrayList<>();
        for (VolumeRestRep currentVolume : volumes) {
            ProtectionRestRep protection = currentVolume.getProtection();
            if (protection != null && protection.getSrdfRep() != null && protection.getSrdfRep().getSRDFTargetVolumes() != null && !protection.getSrdfRep().getSRDFTargetVolumes().isEmpty()) {
                for (VolumeRestRep srdfTarget : client.blockVolumes().getByRefs(protection.getSrdfRep().getSRDFTargetVolumes(), new SRDFTargetFilter())) {
                    SRDFRestRep srdf = (srdfTarget.getProtection() != null) ? srdfTarget.getProtection().getSrdfRep() : null;
                    if (srdf != null && (srdf.getAssociatedSourceVolume() != null) && (srdf.getSrdfCopyMode() != null) && (!ACTIVE.equalsIgnoreCase(srdf.getSrdfCopyMode()))) {
                        filteredVols.add(currentVolume);
                        break;
                    }
                }
            } else {
                // Add the volume as before
                filteredVols.add(currentVolume);
            }
        }
        return createVolumeOptions(client, filteredVols);
    } else {
        debug("getting protected consistency groups (project=%s)", project);
        // Allow recoverpoint or SRDF sources
        ResourceFilter<BlockConsistencyGroupRestRep> filter = new ConsistencyGroupFilter(BlockConsistencyGroup.Types.RP.name(), false).or(new ConsistencyGroupFilter(BlockConsistencyGroup.Types.SRDF.name(), false));
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).filter(filter).run();
        // We need to filter out SRDF Metro volumes as they are not eligible for FAILOVER or SWAP
        List<BlockConsistencyGroupRestRep> filteredCgs = new ArrayList<>();
        for (BlockConsistencyGroupRestRep cg : consistencyGroups) {
            // Get SRDF source volumes
            if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
                List<VolumeRestRep> srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), new SRDFSourceFilter());
                if (srcVolumes != null && !srcVolumes.isEmpty()) {
                    // Get the first source volume and obtain its target references
                    VolumeRestRep srcVolume = srcVolumes.get(0);
                    for (VolumeRestRep srdfTarget : client.blockVolumes().getByRefs(srcVolume.getProtection().getSrdfRep().getSRDFTargetVolumes(), new SRDFTargetFilter())) {
                        SRDFRestRep srdf = (srdfTarget.getProtection() != null) ? srdfTarget.getProtection().getSrdfRep() : null;
                        if (srdf != null && (srdf.getAssociatedSourceVolume() != null) && (srdf.getSrdfCopyMode() != null) && (!ACTIVE.equalsIgnoreCase(srdf.getSrdfCopyMode()))) {
                            filteredCgs.add(cg);
                            break;
                        }
                    }
                }
            } else {
                // Add the cg as before
                filteredCgs.add(cg);
            }
        }
        return createBaseResourceOptions(filteredCgs);
    }
}
Also used : SRDFSourceFilter(com.emc.vipr.client.core.filters.SRDFSourceFilter) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) SRDFRestRep(com.emc.storageos.model.block.VolumeRestRep.SRDFRestRep) ArrayList(java.util.ArrayList) ProtectionRestRep(com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) SRDFTargetFilter(com.emc.vipr.client.core.filters.SRDFTargetFilter) ConsistencyGroupFilter(com.emc.vipr.client.core.filters.ConsistencyGroupFilter) BlockVolumeConsistencyGroupFilter(com.emc.vipr.client.core.filters.BlockVolumeConsistencyGroupFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 14 with BlockConsistencyGroupRestRep

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

the class BlockStorageUtils method swapCGContinuousCopy.

public static Tasks<BlockConsistencyGroupRestRep> swapCGContinuousCopy(URI protectionSource, URI protectionTarget, String type) {
    Tasks<BlockConsistencyGroupRestRep> copies = execute(new SwapCGContinuousCopies(protectionSource, protectionTarget, type));
    addAffectedResources(copies);
    return copies;
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) SwapCGContinuousCopies(com.emc.sa.service.vipr.block.tasks.SwapCGContinuousCopies)

Example 15 with BlockConsistencyGroupRestRep

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

the class BlockProvider method getBlockSnapshotType.

@Asset("blockSnapshotType")
@AssetDependencies({ "blockVolumeOrConsistencyType", "snapshotBlockVolume" })
public List<AssetOption> getBlockSnapshotType(AssetOptionsContext ctx, String storageType, URI blockVolumeOrCG) {
    // These are hard coded values for now. In the future, this may be available through an API
    List<AssetOption> options = Lists.newArrayList();
    if (isConsistencyGroupType(blockVolumeOrCG)) {
        options.add(CG_SNAPSHOT_TYPE_OPTION);
        // Only add cg session option if the CG selected supports it
        ViPRCoreClient client = api(ctx);
        BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(blockVolumeOrCG);
        if (isSnapshotSessionSupportedForCG(cg)) {
            options.add(CG_SNAPSHOT_SESSION_TYPE_OPTION);
        }
    } else {
        debug("getting blockSnapshotTypes (blockVolume=%s)", blockVolumeOrCG);
        ViPRCoreClient client = api(ctx);
        VolumeRestRep volume = client.blockVolumes().get(blockVolumeOrCG);
        BlockVirtualPoolRestRep virtualPool = client.blockVpools().get(volume.getVirtualPool());
        if (isLocalSnapshotSupported(virtualPool)) {
            options.add(LOCAL_ARRAY_SNAPSHOT_TYPE_OPTION);
        }
        if (isRPSourceVolume(volume)) {
            options.add(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_OPTION);
        }
        if (isSnapshotSessionSupportedForVolume(volume)) {
            options.add(SNAPSHOT_SESSION_TYPE_OPTION);
        }
    }
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)28 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)15 Asset (com.emc.sa.asset.annotation.Asset)12 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)10 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)10 URI (java.net.URI)9 ArrayList (java.util.ArrayList)8 AssetOption (com.emc.vipr.model.catalog.AssetOption)6 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)3 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)3 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)2 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)2 ProtectionRestRep (com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep)2 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)2 SRDFSourceFilter (com.emc.vipr.client.core.filters.SRDFSourceFilter)2 FlashException (controllers.util.FlashException)2 HashSet (java.util.HashSet)2 CreateConsistencyGroupFullCopy (com.emc.sa.service.vipr.block.consistency.tasks.CreateConsistencyGroupFullCopy)1 DetachConsistencyGroupFullCopy (com.emc.sa.service.vipr.block.consistency.tasks.DetachConsistencyGroupFullCopy)1