Search in sources :

Example 46 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getExportsForExportedVolume.

@Asset("volumeExport")
@AssetDependencies("exportedBlockVolume")
public List<AssetOption> getExportsForExportedVolume(AssetOptionsContext ctx, URI volumeId) {
    final ViPRCoreClient client = api(ctx);
    Set<NamedRelatedResourceRep> exports = getUniqueExportsForVolume(ctx, volumeId);
    return createExportWithVarrayOptions(client, client.blockExports().getByRefs(exports));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 47 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies 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 48 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getVirtualArrayChangeCandidateVolumes.

@Asset("virtualArrayChangeVolume")
@AssetDependencies({ "project", "targetVirtualArray" })
public List<AssetOption> getVirtualArrayChangeCandidateVolumes(AssetOptionsContext ctx, URI projectId, URI varrayId) {
    ViPRCoreClient client = api(ctx);
    NamedVolumesList volumeList = client.blockVolumes().listVirtualArrayChangeCandidates(projectId, varrayId);
    List<VolumeRestRep> volumes = client.blockVolumes().getByRefs(volumeList.getVolumes());
    return createVolumeOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 49 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationVirtualArrays.

@Asset("applicationVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
    final ViPRCoreClient client = api(ctx);
    List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
    List<AssetOption> options = new ArrayList<AssetOption>();
    boolean isRP = false;
    URI sourceVarrayId = null;
    List<VolumeRestRep> allRPSourceVols = null;
    if (volList != null && !volList.isEmpty()) {
        VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
        if (BlockProviderUtils.isVolumeRP(vol)) {
            isRP = true;
            allRPSourceVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.SOURCE);
            if (allRPSourceVols != null && !allRPSourceVols.isEmpty()) {
                VolumeRestRep rpvol = allRPSourceVols.get(0);
                sourceVarrayId = rpvol.getVirtualArray().getId();
            }
        }
    } else {
        options.add(newAssetOption(URI.create("none"), "None"));
        return options;
    }
    // if the volumes are RP (vplex or not) add the RP targets as options
    if (isRP) {
        options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
        Set<URI> targetVarrayIds = new HashSet<URI>();
        List<AssetOption> targetOptions = new ArrayList<AssetOption>();
        List<VolumeRestRep> allRPTargetVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.TARGET);
        for (VolumeRestRep targetVol : allRPTargetVols) {
            targetVarrayIds.add(targetVol.getVirtualArray().getId());
        }
        List<VirtualArrayRestRep> targetVarrays = client.varrays().getByIds(targetVarrayIds);
        for (VirtualArrayRestRep targetVarray : targetVarrays) {
            targetOptions.add(newAssetOption(String.format("tgt:%s", targetVarray.getId().toString()), "protection.site.type.target", targetVarray.getName()));
        }
        // sort the targets
        AssetOptionsUtils.sortOptionsByLabel(targetOptions);
        options.addAll(targetOptions);
    }
    if (options.isEmpty()) {
        options.add(newAssetOption(URI.create("none"), "None"));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) 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 50 with AssetDependencies

use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.

the class BlockProvider method getVolumesWithoutConsistencyGroup.

@Asset("volumeWithoutConsistencyGroup")
@AssetDependencies("project")
public List<AssetOption> getVolumesWithoutConsistencyGroup(AssetOptionsContext ctx, URI project) {
    debug("getting volumes that don't belong to a consistency group (project=%s)", project);
    ViPRCoreClient client = api(ctx);
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project);
    Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
    List<AssetOption> options = Lists.newArrayList();
    for (VolumeRestRep volume : volumes) {
        if (volume.getConsistencyGroup() == null) {
            options.add(createVolumeOption(client, null, volume, volumeNames));
        }
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) 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)

Aggregations

Asset (com.emc.sa.asset.annotation.Asset)102 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)102 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)66 AssetOption (com.emc.vipr.model.catalog.AssetOption)63 URI (java.net.URI)43 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)35 ArrayList (java.util.ArrayList)22 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)17 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)13 HashSet (java.util.HashSet)12 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)11 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)10 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)10 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)7 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)7 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)7 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6