Search in sources :

Example 61 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class BlockProvider method getCopyNameByConsistencyGroup.

@Asset("journalCopyName")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getCopyNameByConsistencyGroup(AssetOptionsContext ctx, URI consistencyGroupId) {
    ViPRCoreClient client = api(ctx);
    List<RelatedResourceRep> volumes = client.blockConsistencyGroups().get(consistencyGroupId).getVolumes();
    Set<String> copyNames = Sets.newHashSet();
    if (volumes != null && !volumes.isEmpty()) {
        RelatedResourceRep volume = volumes.get(0);
        VolumeRestRep volumeRep = client.blockVolumes().get(volume);
        if (volumeRep.getProtection() != null && volumeRep.getProtection().getRpRep() != null) {
            if (volumeRep.getProtection().getRpRep().getCopyName() != null) {
                String copyName = volumeRep.getProtection().getRpRep().getCopyName();
                copyNames.add(copyName);
            }
            if (volumeRep.getHaVolumes() != null) {
                List<RelatedResourceRep> haVolumes = volumeRep.getHaVolumes();
                List<URI> haVolumeIds = new ArrayList<URI>();
                for (RelatedResourceRep haVolume : haVolumes) {
                    haVolumeIds.add(haVolume.getId());
                }
                List<VolumeRestRep> haVolumeReps = client.blockVolumes().getByIds(haVolumeIds, null);
                for (VolumeRestRep haVolumeRep : haVolumeReps) {
                    if (haVolumeRep.getProtection() != null && haVolumeRep.getProtection().getRpRep() != null && haVolumeRep.getProtection().getRpRep().getCopyName() != null) {
                        String copyName = haVolumeRep.getProtection().getRpRep().getCopyName();
                        copyNames.add(copyName);
                    }
                }
            }
            if (volumeRep.getProtection().getRpRep().getRpTargets() != null) {
                List<VirtualArrayRelatedResourceRep> targetVolumes = volumeRep.getProtection().getRpRep().getRpTargets();
                List<URI> targetVolumeIds = new ArrayList<URI>();
                for (VirtualArrayRelatedResourceRep targetVolume : targetVolumes) {
                    targetVolumeIds.add(targetVolume.getId());
                }
                List<VolumeRestRep> targetVolumeReps = client.blockVolumes().getByIds(targetVolumeIds, null);
                for (VolumeRestRep targetVolumeRep : targetVolumeReps) {
                    String copyName = targetVolumeRep.getProtection().getRpRep().getCopyName();
                    copyNames.add(copyName);
                }
            }
        }
    }
    List<AssetOption> copyNameAssets = Lists.newArrayList();
    for (String copyName : copyNames) {
        copyNameAssets.add(newAssetOption(copyName, copyName));
    }
    AssetOptionsUtils.sortOptionsByLabel(copyNameAssets);
    return copyNameAssets;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ArrayList(java.util.ArrayList) URI(java.net.URI) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 62 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class BlockProvider method getAffectedExports.

@Asset("exportPathAffectedExports")
@AssetDependencies({ "host", "exportPathVirtualArray", "exportPathExport", "exportPathMinPathsOptions", "exportPathMaxPathsOptions", "exportPathPathsPerInitiatorOptions", "exportPathExistingPath", "exportPathStorageSystem", "exportPathPorts" })
public List<AssetOption> getAffectedExports(AssetOptionsContext ctx, URI hostOrClusterId, URI vArrayId, URI exportId, Integer minPaths, Integer maxPaths, Integer pathsPerInitiator, String useExisting, URI storageSystemId, String ports) {
    ViPRCoreClient client = api(ctx);
    // the asset option list
    List<AssetOption> options = Lists.newArrayList();
    List<URI> exportPathPorts = parseExportPathPorts(ports);
    ExportPathsAdjustmentPreviewRestRep portPreview = generateExportPathPreview(ctx, hostOrClusterId, vArrayId, exportId, minPaths, maxPaths, pathsPerInitiator, useExisting, storageSystemId, exportPathPorts);
    List<NamedRelatedResourceRep> affectedList = portPreview.getAffectedExportGroups();
    List<URI> exportIds = new ArrayList<URI>();
    for (NamedRelatedResourceRep affected : affectedList) {
        exportIds.add(affected.getId());
    }
    List<ExportGroupRestRep> exports = client.blockExports().getByIds(exportIds);
    for (ExportGroupRestRep export : exports) {
        // TODO: need to optimize the way that we retrieve the project name.
        String projectName = client.projects().get(export.getProject().getId()).getName();
        String label = getMessage("exportPathAdjustment.affectedExports", projectName, export.getName());
        options.add(new AssetOption(export.getName(), label));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ExportPathsAdjustmentPreviewRestRep(com.emc.storageos.model.block.export.ExportPathsAdjustmentPreviewRestRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 63 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class BlockProvider method createVpoolChangeOptions.

protected List<AssetOption> createVpoolChangeOptions(String vpoolChangeOperation, List<VirtualPoolChangeRep> vpoolChanges) {
    List<AssetOption> options = Lists.newArrayList();
    List<AssetOption> available = Lists.newArrayList();
    List<AssetOption> wrongOperation = Lists.newArrayList();
    List<AssetOption> notAllowed = Lists.newArrayList();
    for (VirtualPoolChangeRep vpoolChange : vpoolChanges) {
        if (vpoolChange.getAllowed() && vpoolChange.getAllowedChangeOperations() != null) {
            for (StringHashMapEntry allowedChangeOperation : vpoolChange.getAllowedChangeOperations()) {
                String operation = allowedChangeOperation.getName();
                boolean isCorrectOperation = StringUtils.isNotBlank(operation) && operation.equalsIgnoreCase(vpoolChangeOperation);
                if (isCorrectOperation) {
                    available.add(new AssetOption(vpoolChange.getId(), vpoolChange.getName()));
                } else {
                    wrongOperation.add(new AssetOption(EMPTY_STRING, getMessage("block.virtualPool.vpoolChangeOperation", vpoolChange.getName(), getAllowedChangeOperationNames(vpoolChange.getAllowedChangeOperations()))));
                }
            }
        } else {
            notAllowed.add(new AssetOption(EMPTY_STRING, getMessage("block.virtualPool.vpoolChangeReason", vpoolChange.getName(), vpoolChange.getNotAllowedReason())));
        }
    }
    options.addAll(available);
    options.addAll(wrongOperation);
    options.addAll(notAllowed);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualPoolChangeRep(com.emc.storageos.model.vpool.VirtualPoolChangeRep) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry)

Example 64 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption in project coprhd-controller by CoprHD.

the class BlockProvider method getExportVolumeForHostPortGroups.

@Asset("exportVolumeForHostPortGroups")
@AssetDependencies({ "virtualArray", "blockVirtualPool", "host", "project" })
public List<AssetOption> getExportVolumeForHostPortGroups(AssetOptionsContext ctx, URI vArrayId, URI vpoolId, URI hostOrClusterId, URI projectId) {
    final ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
    if (value.getValue().equalsIgnoreCase("true")) {
        ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, vArrayId, client);
        StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(vArrayId, (export != null ? export.getId() : null), null, vpoolId, null, true);
        return createPortGroupOptions(portGroups.getStoragePortGroups());
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 65 with AssetOption

use of com.emc.vipr.model.catalog.AssetOption 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)

Aggregations

AssetOption (com.emc.vipr.model.catalog.AssetOption)107 Asset (com.emc.sa.asset.annotation.Asset)74 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)63 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)41 URI (java.net.URI)36 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)20 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)14 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)14 ArrayList (java.util.ArrayList)12 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)11 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)10 Map (java.util.Map)9 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)8 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)8 HashMap (java.util.HashMap)8 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)7 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)6 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)6 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5