Search in sources :

Example 1 with ProtectionRestRep

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

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

the class BlockProvider method getFailoverTarget.

@Asset("failoverTarget")
@AssetDependencies("protectedBlockVolume")
public List<AssetOption> getFailoverTarget(AssetOptionsContext ctx, URI protectedBlockVolume) {
    if (protectedBlockVolume != null) {
        ViPRCoreClient client = api(ctx);
        if (BlockProviderUtils.isType(protectedBlockVolume, VOLUME_TYPE)) {
            debug("getting failoverTargets (protectedBlockVolume=%s)", protectedBlockVolume);
            VolumeRestRep volume = client.blockVolumes().get(protectedBlockVolume);
            ProtectionRestRep protection = volume.getProtection();
            if (protection != null) {
                // RecoverPoint protection
                if (protection.getRpRep() != null && protection.getRpRep().getProtectionSet() != null) {
                    return getRpFailoverTargets(client, volume);
                }
                // VMAX SRDF protection
                if (protection.getSrdfRep() != null && protection.getSrdfRep().getSRDFTargetVolumes() != null && !protection.getSrdfRep().getSRDFTargetVolumes().isEmpty()) {
                    return getSrdfFailoverTargets(client, volume);
                }
            }
        } else if (BlockProviderUtils.isType(protectedBlockVolume, BLOCK_CONSISTENCY_GROUP_TYPE)) {
            debug("getting failoverTargets for consistency group %s", protectedBlockVolume);
            BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(protectedBlockVolume);
            List<VolumeRestRep> srcVolumes = null;
            // Get RP source volumes
            if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
                srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), RecoverPointPersonalityFilter.SOURCE);
            }
            // Get SRDF source volumes
            if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
                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);
                if (cg.getTypes() != null) {
                    Map<String, String> targetVolumes = Maps.newLinkedHashMap();
                    CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
                    List<VirtualArrayRelatedResourceRep> targets = new ArrayList<VirtualArrayRelatedResourceRep>();
                    // Process the RP targets
                    if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
                        targets = srcVolume.getProtection().getRpRep().getRpTargets();
                    }
                    // Process the SRDF targets
                    if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
                        targets = srcVolume.getProtection().getSrdfRep().getSRDFTargetVolumes();
                    }
                    for (VolumeRestRep targetVolume : client.blockVolumes().getByRefs(targets)) {
                        VirtualArrayRestRep virtualArray = virtualArrays.get(targetVolume.getVirtualArray());
                        String label = getMessage(name(virtualArray));
                        targetVolumes.put(stringId(virtualArray), 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;
                }
            }
        }
    }
    return Lists.newArrayList();
}
Also used : SRDFSourceFilter(com.emc.vipr.client.core.filters.SRDFSourceFilter) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ProtectionRestRep(com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry) Entry(java.util.Map.Entry) CachedResources(com.emc.vipr.client.core.util.CachedResources) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) SnapshotList(com.emc.storageos.model.SnapshotList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) Map(java.util.Map) HashMap(java.util.HashMap) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with ProtectionRestRep

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

the class BlockMapper method map.

public static VolumeRestRep map(DbClient dbClient, Volume from, Map<URI, Boolean> projectSrdfCapableCache) {
    if (from == null) {
        return null;
    }
    VolumeRestRep to = new VolumeRestRep();
    mapBlockObjectFields(from, to);
    if (from.getProject() != null) {
        to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject().getURI()));
    }
    if (from.getTenant() != null) {
        to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, from.getTenant().getURI()));
    }
    to.setProvisionedCapacity(CapacityUtils.convertBytesToGBInStr(from.getProvisionedCapacity()));
    // For VPLEX virtual volumes return allocated capacity as provisioned capacity (cop-18608)
    to.setAllocatedCapacity(CapacityUtils.convertBytesToGBInStr(from.getAllocatedCapacity()));
    boolean isVplexVolume = DiscoveredDataObject.Type.vplex.name().equalsIgnoreCase(from.getSystemType());
    if (isVplexVolume) {
        to.setAllocatedCapacity(CapacityUtils.convertBytesToGBInStr(from.getProvisionedCapacity()));
    }
    to.setCapacity(CapacityUtils.convertBytesToGBInStr(from.getCapacity()));
    if (from.getThinlyProvisioned()) {
        to.setPreAllocationSize(CapacityUtils.convertBytesToGBInStr(from.getThinVolumePreAllocationSize()));
    }
    to.setVirtualPool(toRelatedResource(ResourceTypeEnum.BLOCK_VPOOL, from.getVirtualPool()));
    to.setIsComposite(from.getIsComposite());
    to.setAutoTierPolicyUri(toRelatedResource(ResourceTypeEnum.AUTO_TIERING_POLICY, from.getAutoTieringPolicyUri(), from.getId()));
    to.setThinlyProvisioned(from.getThinlyProvisioned());
    to.setAccessState(from.getAccessState());
    to.setLinkStatus(from.getLinkStatus());
    // Default snapshot session support to false
    to.setSupportsSnapshotSessions(Boolean.FALSE);
    // set compression ratio
    to.setCompressionRatio(from.getCompressionRatio());
    if (DiscoveredDataObject.Type.vmax3.name().equalsIgnoreCase(from.getSystemType())) {
        to.setSupportsSnapshotSessions(Boolean.TRUE);
    }
    to.setSystemType(from.getSystemType());
    // Extra checks for VPLEX volumes
    Volume srdfVolume = from;
    Volume sourceSideBackingVolume = null;
    if (null != dbClient && null != from.getAssociatedVolumes() && !from.getAssociatedVolumes().isEmpty()) {
        // For snapshot session support of a VPLEX volume, we only need to check the SOURCE side of the
        // volume.
        sourceSideBackingVolume = VPlexUtil.getVPLEXBackendVolume(from, true, dbClient);
        // Check for null in case the VPlex vol was ingested w/o the backend volumes
        if ((sourceSideBackingVolume != null) && DiscoveredDataObject.Type.vmax3.name().equalsIgnoreCase(sourceSideBackingVolume.getSystemType())) {
            to.setSupportsSnapshotSessions(Boolean.TRUE);
        }
        // SrdfRestRep below.
        if (projectSrdfCapable(dbClient, from.getProject().getURI(), projectSrdfCapableCache)) {
            srdfVolume = VPlexSrdfUtil.getSrdfVolumeFromVplexVolume(dbClient, from);
            srdfVolume = (srdfVolume != null ? srdfVolume : from);
        }
        to.setAccessState(srdfVolume.getAccessState());
        to.setLinkStatus(srdfVolume.getLinkStatus());
    }
    if (from.getPool() != null) {
        to.setPool(toRelatedResource(ResourceTypeEnum.STORAGE_POOL, from.getPool()));
    }
    // RecoverPoint specific section
    RecoverPointRestRep toRp = null;
    if (from.checkForRp()) {
        toRp = new RecoverPointRestRep();
        toRp.setProtectionSystem(toRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, from.getProtectionController()));
        toRp.setPersonality(from.getPersonality());
        toRp.setInternalSiteName(from.getInternalSiteName());
        toRp.setCopyName(from.getRpCopyName());
        toRp.setRsetName(from.getRSetName());
        if ((from.getRpTargets() != null) && (!from.getRpTargets().isEmpty())) {
            List<VirtualArrayRelatedResourceRep> rpTargets = new ArrayList<VirtualArrayRelatedResourceRep>();
            for (String target : from.getRpTargets()) {
                rpTargets.add(toTargetVolumeRelatedResource(ResourceTypeEnum.VOLUME, URI.create(target), getVarray(dbClient, target)));
            }
            toRp.setRpTargets(rpTargets);
        }
        if (from.getProtectionSet() != null) {
            toRp.setProtectionSet(toRelatedResource(ResourceTypeEnum.PROTECTION_SET, from.getProtectionSet().getURI(), from.getId()));
        }
    }
    // Mirror specific section
    MirrorRestRep toMirror = null;
    if ((from.getMirrors() != null) && (!from.getMirrors().isEmpty())) {
        toMirror = new MirrorRestRep();
        List<VirtualArrayRelatedResourceRep> mirrors = new ArrayList<VirtualArrayRelatedResourceRep>();
        for (String mirror : from.getMirrors()) {
            mirrors.add(toTargetVolumeRelatedResource(ResourceTypeEnum.BLOCK_MIRROR, URI.create(mirror), from.getId(), getVarray(dbClient, mirror)));
        }
        toMirror.setMirrors(mirrors);
    }
    // Full copy specific section
    FullCopyRestRep toFullCopy = null;
    URI fullCopySourceVolumeURI = from.getAssociatedSourceVolume();
    StringSet fromFullCopies = from.getFullCopies();
    if (!NullColumnValueGetter.isNullURI(fullCopySourceVolumeURI) || (fromFullCopies != null && !fromFullCopies.isEmpty())) {
        toFullCopy = new FullCopyRestRep();
        if (fullCopySourceVolumeURI != null) {
            toFullCopy.setAssociatedSourceVolume(toRelatedResource(ResourceTypeEnum.VOLUME, fullCopySourceVolumeURI));
        }
        if (fromFullCopies != null) {
            List<VirtualArrayRelatedResourceRep> fullCopies = new ArrayList<VirtualArrayRelatedResourceRep>();
            for (String fullCopy : fromFullCopies) {
                fullCopies.add(toTargetVolumeRelatedResource(ResourceTypeEnum.VOLUME, URI.create(fullCopy), getVarray(dbClient, fullCopy)));
            }
            toFullCopy.setFullCopyVolumes(fullCopies);
        }
        if (from.getSyncActive() != null) {
            toFullCopy.setSyncActive(from.getSyncActive());
        }
        if (from.getReplicaState() != null) {
            toFullCopy.setReplicaState(from.getReplicaState());
        }
        if (from.getFullCopySetName() != null) {
            toFullCopy.setFullCopySetName(from.getFullCopySetName());
        }
    }
    // SRDF specific section; uses srdfVolume which is a copy of from unless
    // it's a vplex underlying srdf volume
    SRDFRestRep toSRDF = null;
    if ((srdfVolume.getSrdfTargets() != null) && (!srdfVolume.getSrdfTargets().isEmpty())) {
        toSRDF = new SRDFRestRep();
        List<VirtualArrayRelatedResourceRep> targets = new ArrayList<VirtualArrayRelatedResourceRep>();
        if (srdfVolume != from) {
            // VPLEX; translate targets to corresponding VPLEX volume. if any
            for (String target : VPlexSrdfUtil.getSrdfOrVplexTargets(dbClient, srdfVolume)) {
                targets.add(toTargetVolumeRelatedResource(ResourceTypeEnum.VOLUME, URI.create(target), getVarray(dbClient, target)));
            }
        } else {
            // Non-VPLEX
            for (String target : from.getSrdfTargets()) {
                targets.add(toTargetVolumeRelatedResource(ResourceTypeEnum.VOLUME, URI.create(target), getVarray(dbClient, target)));
            }
        }
        toSRDF.setPersonality(srdfVolume.getPersonality());
        toSRDF.setSRDFTargetVolumes(targets);
    } else if (!NullColumnValueGetter.isNullNamedURI(srdfVolume.getSrdfParent())) {
        toSRDF = new SRDFRestRep();
        toSRDF.setPersonality(srdfVolume.getPersonality());
        toSRDF.setAssociatedSourceVolume(toRelatedResource(ResourceTypeEnum.VOLUME, srdfVolume.getSrdfParent().getURI()));
        toSRDF.setSrdfCopyMode(srdfVolume.getSrdfCopyMode());
        toSRDF.setSrdfGroup(srdfVolume.getSrdfGroup());
    }
    // Protection object encapsulates mirrors and RP
    if (toMirror != null || toRp != null || toFullCopy != null || toSRDF != null) {
        ProtectionRestRep toProtection = new ProtectionRestRep();
        toProtection.setMirrorRep(toMirror);
        toProtection.setRpRep(toRp);
        toProtection.setFullCopyRep(toFullCopy);
        toProtection.setSrdfRep(toSRDF);
        to.setProtection(toProtection);
    }
    String replicationGroupInstance = isVplexVolume ? from.getBackingReplicationGroupInstance() : from.getReplicationGroupInstance();
    if (NullColumnValueGetter.isNotNullValue(replicationGroupInstance)) {
        to.setReplicationGroupInstance(replicationGroupInstance);
    }
    if ((from.getAssociatedVolumes() != null) && (!from.getAssociatedVolumes().isEmpty())) {
        List<RelatedResourceRep> backingVolumes = new ArrayList<RelatedResourceRep>();
        for (String backingVolume : from.getAssociatedVolumes()) {
            backingVolumes.add(toRelatedResource(ResourceTypeEnum.VOLUME, URI.create(backingVolume)));
        }
        to.setHaVolumes(backingVolumes);
    }
    if ((from.getVolumeGroupIds() != null) && (!from.getVolumeGroupIds().isEmpty())) {
        List<RelatedResourceRep> volumeGroups = new ArrayList<RelatedResourceRep>();
        for (String volumeGroup : from.getVolumeGroupIds()) {
            volumeGroups.add(toRelatedResource(ResourceTypeEnum.VOLUME_GROUP, URI.create(volumeGroup)));
        }
        to.setVolumeGroups(volumeGroups);
    }
    return to;
}
Also used : RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) SRDFRestRep(com.emc.storageos.model.block.VolumeRestRep.SRDFRestRep) ArrayList(java.util.ArrayList) MirrorRestRep(com.emc.storageos.model.block.VolumeRestRep.MirrorRestRep) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) VplexMirrorRestRep(com.emc.storageos.model.block.VplexMirrorRestRep) FullCopyRestRep(com.emc.storageos.model.block.VolumeRestRep.FullCopyRestRep) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) RecoverPointRestRep(com.emc.storageos.model.block.VolumeRestRep.RecoverPointRestRep) ProtectionRestRep(com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) UnManagedVolumeRestRep(com.emc.storageos.model.block.UnManagedVolumeRestRep)

Aggregations

VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)3 ProtectionRestRep (com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep)3 ArrayList (java.util.ArrayList)3 Asset (com.emc.sa.asset.annotation.Asset)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)2 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)2 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)2 SRDFRestRep (com.emc.storageos.model.block.VolumeRestRep.SRDFRestRep)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 SRDFSourceFilter (com.emc.vipr.client.core.filters.SRDFSourceFilter)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 Volume (com.emc.storageos.db.client.model.Volume)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 SnapshotList (com.emc.storageos.model.SnapshotList)1 StringHashMapEntry (com.emc.storageos.model.StringHashMapEntry)1 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)1 BlockMirrorRestRep (com.emc.storageos.model.block.BlockMirrorRestRep)1 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)1