Search in sources :

Example 16 with BlockConsistencyGroupRestRep

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

the class BlockProvider method getSnapshotSessionBlockVolumes.

@Asset("snapshotSessionBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getSnapshotSessionBlockVolumes(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) {
            boolean localSnapSupported = isLocalSnapshotSupported(detail.vpool);
            boolean isRPTargetVolume = isRPTargetVolume(detail.volume);
            boolean isRPSourceVolume = isRPSourceVolume(detail.volume);
            boolean isInConsistencyGroup = !StringUtils.isEmpty(detail.volume.getReplicationGroupInstance());
            boolean isSnapshotSessionSupported = isSnapshotSessionSupportedForVolume(detail.volume);
            debug("filter[ localSnapSupported=%s, isRPTargetVolume=%s, isRPSourceVolume=%s, isInConsistencyGroup=%s, isXio3XVolume=%s ]", localSnapSupported, isRPTargetVolume, isRPSourceVolume, isInConsistencyGroup, isSnapshotSessionSupported);
            if (isSnapshotSessionSupported && localSnapSupported && !isInConsistencyGroup) {
                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 17 with BlockConsistencyGroupRestRep

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

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

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

the class ConsistencyGroupProvider method getAllConsistencyGroup.

@Asset("consistencyGroupAll")
public List<AssetOption> getAllConsistencyGroup(AssetOptionsContext ctx) {
    List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
    List<BlockConsistencyGroupRestRep> cgs = Lists.newArrayList();
    for (ProjectRestRep project : projects) {
        cgs.addAll(api(ctx).blockConsistencyGroups().findByProject(project));
    }
    List<AssetOption> options = createBaseResourceOptions(cgs);
    return options;
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) Asset(com.emc.sa.asset.annotation.Asset)

Example 20 with BlockConsistencyGroupRestRep

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

the class ConsistencyGroupProvider method getConsistencyGroupFilters.

@Asset("consistencyGroupFilter")
public List<AssetOption> getConsistencyGroupFilters(AssetOptionsContext ctx) {
    List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
    List<BlockConsistencyGroupRestRep> cgs = Lists.newArrayList();
    for (ProjectRestRep project : projects) {
        cgs.addAll(api(ctx).blockConsistencyGroups().findByProject(project));
    }
    List<AssetOption> options = createBaseResourceOptions(cgs);
    options.add(0, new AssetOption("None", "None"));
    return options;
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) 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