Search in sources :

Example 26 with ExportGroupRestRep

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

the class BlockProvider method getExportPathVirtualArray.

@Asset("exportPathVirtualArray")
@AssetDependencies({ "exportPathExport", "exportPathStorageSystem" })
public List<AssetOption> getExportPathVirtualArray(AssetOptionsContext ctx, URI exportId, URI storageSystemId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    ExportGroupRestRep export = client.blockExports().get(exportId);
    List<URI> vArrayIds = new ArrayList<URI>();
    vArrayIds.add(export.getVirtualArray().getId());
    List<StringHashMapEntry> altArrays = export.getAltVirtualArrays() != null ? export.getAltVirtualArrays() : new ArrayList<StringHashMapEntry>();
    for (StringHashMapEntry altArray : altArrays) {
        if (altArray.getName().equalsIgnoreCase(storageSystemId.toString())) {
            vArrayIds.add(URI.create(altArray.getValue()));
        }
    }
    List<VirtualArrayRestRep> vArrays = client.varrays().getByIds(vArrayIds);
    for (VirtualArrayRestRep vArray : vArrays) {
        options.add(new AssetOption(vArray.getId(), vArray.getName()));
    }
    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) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) ArrayList(java.util.ArrayList) URI(java.net.URI) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 27 with ExportGroupRestRep

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

the class BlockProvider method getExportedVolumeIds.

/**
 * Return a list of all exported volume ids for a given project id.
 *
 * @param ctx asset option content
 * @param project id
 * @return list of exported volume ids
 */
private List<URI> getExportedVolumeIds(AssetOptionsContext ctx, URI project) {
    final ViPRCoreClient client = api(ctx);
    List<URI> volumeIds = Lists.newArrayList();
    for (ExportGroupRestRep export : client.blockExports().findByProject(project)) {
        for (ExportBlockParam resource : export.getVolumes()) {
            if (ResourceType.isType(ResourceType.VOLUME, resource.getId())) {
                volumeIds.add(resource.getId());
            }
        }
    }
    return volumeIds;
}
Also used : ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) URI(java.net.URI)

Example 28 with ExportGroupRestRep

use of com.emc.storageos.model.block.export.ExportGroupRestRep 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 29 with ExportGroupRestRep

use of com.emc.storageos.model.block.export.ExportGroupRestRep 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 30 with ExportGroupRestRep

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

the class BlockProvider method getExportContinousCopyForHostPortGroups.

@Asset("exportContinousCopyForHostPortGroups")
@AssetDependencies({ "volumeWithContinuousCopies", "unassignedBlockContinuousCopies", "host", "project" })
public List<AssetOption> getExportContinousCopyForHostPortGroups(AssetOptionsContext ctx, URI volumeId, String selectedCopies, 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")) {
        List<URI> snapshotIds = Lists.newArrayList();
        info("Continous Copies selected by user: %s", selectedCopies);
        List<String> parsedCopiesIds = TextUtils.parseCSV(selectedCopies);
        for (String id : parsedCopiesIds) {
            snapshotIds.add(uri(id));
        }
        List<BlockMirrorRestRep> copies = client.blockVolumes().getContinuousCopies(volumeId);
        Set<URI> virtualArrays = new HashSet<URI>();
        Set<URI> storageSystems = new HashSet<URI>();
        Set<URI> virtualPools = new HashSet<URI>();
        for (BlockMirrorRestRep copy : copies) {
            virtualArrays.add(copy.getVirtualArray().getId());
            storageSystems.add(copy.getStorageController());
            virtualPools.add(copy.getVirtualPool().getId());
        }
        if (virtualArrays.size() == 1 && storageSystems.size() == 1 && virtualPools.size() == 1) {
            Iterator<URI> it = virtualArrays.iterator();
            URI varrayId = it.next();
            ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, varrayId, client);
            Iterator<URI> ssIt = storageSystems.iterator();
            Iterator<URI> vpIt = virtualPools.iterator();
            StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, export != null ? export.getId() : null, ssIt.next(), vpIt.next(), 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) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) URI(java.net.URI) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)59 URI (java.net.URI)36 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)24 Asset (com.emc.sa.asset.annotation.Asset)10 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)10 FlashException (controllers.util.FlashException)9 ExportUpdateParam (com.emc.storageos.model.block.export.ExportUpdateParam)8 AssetOption (com.emc.vipr.model.catalog.AssetOption)8 ArrayList (java.util.ArrayList)8 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)7 DeactivateBlockExport (com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport)5 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)5 ITLRestRep (com.emc.storageos.model.block.export.ITLRestRep)5 HostRestRep (com.emc.storageos.model.host.HostRestRep)5 HashSet (java.util.HashSet)5 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)4 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)4