Search in sources :

Example 1 with SRDFTargetFilter

use of com.emc.vipr.client.core.filters.SRDFTargetFilter 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 2 with SRDFTargetFilter

use of com.emc.vipr.client.core.filters.SRDFTargetFilter in project coprhd-controller by CoprHD.

the class BlockProvider method getSrdfFailoverTargets.

protected List<AssetOption> getSrdfFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
    Map<String, String> targetVolumes = Maps.newLinkedHashMap();
    CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
    List<VirtualArrayRelatedResourceRep> srdfTargets = volume.getProtection().getSrdfRep().getSRDFTargetVolumes();
    for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(srdfTargets, new SRDFTargetFilter())) {
        VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
        String label = getMessage("srdf.target", name(protectionSetVolume), name(virtualArray));
        targetVolumes.put(stringId(protectionSetVolume), label);
    }
    List<AssetOption> options = Lists.newArrayList();
    for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
        options.add(new AssetOption(entry.getKey(), entry.getValue()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) CachedResources(com.emc.vipr.client.core.util.CachedResources) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) SRDFTargetFilter(com.emc.vipr.client.core.filters.SRDFTargetFilter) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)2 SRDFTargetFilter (com.emc.vipr.client.core.filters.SRDFTargetFilter)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)1 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)1 ProtectionRestRep (com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep)1 SRDFRestRep (com.emc.storageos.model.block.VolumeRestRep.SRDFRestRep)1 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1 BlockVolumeConsistencyGroupFilter (com.emc.vipr.client.core.filters.BlockVolumeConsistencyGroupFilter)1 ConsistencyGroupFilter (com.emc.vipr.client.core.filters.ConsistencyGroupFilter)1 SRDFSourceFilter (com.emc.vipr.client.core.filters.SRDFSourceFilter)1 CachedResources (com.emc.vipr.client.core.util.CachedResources)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1