Search in sources :

Example 86 with VolumeRestRep

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

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

the class BlockProvider method getSnapshotBlockVolumes.

@Asset("snapshotBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getSnapshotBlockVolumes(AssetOptionsContext context, URI project, String storageType) {
    final ViPRCoreClient client = api(context);
    if (isVolumeType(storageType)) {
        List<VolumeRestRep> volumes = listVolumes(client, project);
        List<VolumeDetail> volumeDetails = getVolumeDetails(client, volumes);
        Map<URI, VolumeRestRep> volumeNames = ResourceUtils.mapById(volumes);
        List<AssetOption> options = Lists.newArrayList();
        for (VolumeDetail detail : volumeDetails) {
            if (detail.vpool == null) {
                continue;
            }
            boolean localSnapSupported = isLocalSnapshotSupported(detail.vpool);
            boolean isRPTargetVolume = isRPTargetVolume(detail.volume);
            boolean isRPSourceVolume = isRPSourceVolume(detail.volume);
            boolean isInConsistencyGroup = BlockProvider.isInConsistencyGroup(detail.volume);
            debug("filter[ localSnapSupported=%s, isRPTargetVolume=%s, isRPSourceVolume=%s, isInConsistencyGroup=%s]", localSnapSupported, isRPTargetVolume, isRPSourceVolume, isInConsistencyGroup);
            if (isRPSourceVolume || (localSnapSupported && (!isInConsistencyGroup || isRPTargetVolume))) {
                options.add(createVolumeOption(client, null, detail.volume, volumeNames));
            }
        }
        return options;
    } else {
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
        return createBaseResourceOptions(consistencyGroups);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 88 with VolumeRestRep

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

the class BlockProvider method getApplicationFullCopyNames.

@Asset("fullCopyName")
@AssetDependencies("application")
public List<AssetOption> getApplicationFullCopyNames(AssetOptionsContext ctx, URI applicationId) {
    List<VolumeRestRep> fullCopies = getFullCopiesForApplication(ctx, applicationId);
    Set<String> fullCopyNames = new HashSet<String>();
    for (VolumeRestRep vol : fullCopies) {
        if (vol != null && vol.getProtection() != null && vol.getProtection().getFullCopyRep() != null && vol.getProtection().getFullCopyRep().getFullCopySetName() != null) {
            fullCopyNames.add(vol.getProtection().getFullCopyRep().getFullCopySetName());
        }
    }
    return createStringOptions(fullCopyNames);
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 89 with VolumeRestRep

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

Example 90 with VolumeRestRep

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

the class BlockProvider method getUnexportedSourceVolumesWithDeletion.

@Asset("unexportedSourceBlockVolumeWithDeletion")
@AssetDependencies({ "project", "deletionType" })
public List<AssetOption> getUnexportedSourceVolumesWithDeletion(final AssetOptionsContext ctx, URI project, String deletionType) {
    debug("getting unexported source block volumes (project=%s)", project);
    final ViPRCoreClient client = api(ctx);
    Set<URI> volumeIds = new HashSet<URI>(getExportedVolumeIds(ctx, project));
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(volumeIds);
    List<VolumeRestRep> volumes = listSourceVolumes(client, project, unexportedFilter);
    return createVolumeOptions(null, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)136 URI (java.net.URI)74 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)49 Asset (com.emc.sa.asset.annotation.Asset)35 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)35 ArrayList (java.util.ArrayList)25 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)23 AssetOption (com.emc.vipr.model.catalog.AssetOption)20 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)13 HashSet (java.util.HashSet)13 UnManagedVolumeRestRep (com.emc.storageos.model.block.UnManagedVolumeRestRep)12 Test (org.junit.Test)12 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)11 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)10 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)9 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)7 VolumeCreate (com.emc.storageos.model.block.VolumeCreate)7 List (java.util.List)7 SnapshotList (com.emc.storageos.model.SnapshotList)6