Search in sources :

Example 1 with ExportGroupRestRep

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

the class BlockProvider method getExportedVolumes.

/**
 * Gets the set of volume IDs for volumes in the given project that are exported to the given host/cluster
 *
 * @param client An instance of the ViPRCoreClient
 * @param projectId The ViPR ID of the project
 * @param hostOrClusterId The ViPR ID of the host/cluster
 *
 * @return The set of Volume IDs
 */
protected static Set<URI> getExportedVolumes(ViPRCoreClient client, URI projectId, URI hostOrClusterId, URI virtualArrayId) {
    // determine host and cluster id
    URI hostId = BlockStorageUtils.isHost(hostOrClusterId) ? hostOrClusterId : null;
    URI clusterId = BlockStorageUtils.isCluster(hostOrClusterId) ? hostOrClusterId : null;
    // get a list of all the exports in this project that expose resources to this host/cluster
    ResourceFilter<ExportGroupRestRep> filter;
    if (virtualArrayId == null) {
        filter = new ExportHostOrClusterFilter(hostId, clusterId);
    } else {
        filter = new ExportHostOrClusterFilter(hostId, clusterId).and(new ExportVirtualArrayFilter(virtualArrayId));
    }
    List<ExportGroupRestRep> exports = client.blockExports().findByProject(projectId, filter);
    return getBlockVolumeIdsForExports(exports);
}
Also used : ExportVirtualArrayFilter(com.emc.vipr.client.core.filters.ExportVirtualArrayFilter) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ExportHostOrClusterFilter(com.emc.vipr.client.core.filters.ExportHostOrClusterFilter) URI(java.net.URI)

Example 2 with ExportGroupRestRep

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

the class BlockProvider method getExportedBlockContinuousCopyByVolume.

@Asset("exportedBlockContinuousCopy")
@AssetDependencies({ "project", "volumeWithContinuousCopies" })
public List<AssetOption> getExportedBlockContinuousCopyByVolume(AssetOptionsContext ctx, URI project, URI volume) {
    debug("getting exported blockContinuousCopy (project=%s) (parent=%s)", project, volume);
    final ViPRCoreClient client = api(ctx);
    Set<URI> exportedMirrors = new HashSet<URI>();
    for (ExportGroupRestRep export : client.blockExports().findByProject(project)) {
        for (ExportBlockParam resource : export.getVolumes()) {
            if (ResourceType.isType(ResourceType.BLOCK_CONTINUOUS_COPY, resource.getId())) {
                exportedMirrors.add(resource.getId());
            }
        }
    }
    ExportedBlockResourceFilter<BlockMirrorRestRep> exportedMirrorFilter = new ExportedBlockResourceFilter<BlockMirrorRestRep>(exportedMirrors);
    List<BlockMirrorRestRep> mirrors = client.blockVolumes().getContinuousCopies(volume, exportedMirrorFilter);
    return createVolumeOptions(client, mirrors);
}
Also used : ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) URI(java.net.URI) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with ExportGroupRestRep

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

the class BlockProvider method getCurrentExportPortGroups.

@Asset("exportCurrentPortGroup")
@AssetDependencies({ "host", "exportPathExport", "exportPathVirtualArray" })
public List<AssetOption> getCurrentExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI exportId, URI varrayId) {
    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 exportGroup = client.blockExports().get(exportId);
        List<StoragePortGroupRestRep> storagePortGroups = new ArrayList<StoragePortGroupRestRep>();
        List<ExportBlockParam> blockParams = exportGroup.getVolumes();
        Set<URI> storageSystemURISet = new HashSet<URI>();
        if (!CollectionUtils.isEmpty(blockParams)) {
            for (ExportBlockParam blockParam : blockParams) {
                // Get each volume in the export group to get the storage system ID
                if (blockParam != null) {
                    URI resourceId = blockParam.getId();
                    URI storageDeviceURI = null;
                    if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
                        VolumeRestRep volume = client.blockVolumes().get(resourceId);
                        storageDeviceURI = volume.getStorageController();
                    } else if (ResourceType.isType(ResourceType.BLOCK_SNAPSHOT, resourceId)) {
                        BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
                        storageDeviceURI = snapshot.getStorageController();
                    }
                    if (storageDeviceURI != null) {
                        storageSystemURISet.add(storageDeviceURI);
                    }
                } else {
                    log.error("Block param not found in export group: {}", exportId);
                }
            }
        }
        if (!CollectionUtils.isEmpty(storageSystemURISet)) {
            Set<URI> portGroupSet = new HashSet<URI>();
            for (URI storageSystemURI : storageSystemURISet) {
                // Now use the storage system ID as well to query the storage port groups
                StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, exportId, storageSystemURI, null, null, false);
                List<StoragePortGroupRestRep> portGroupList = portGroups.getStoragePortGroups();
                if (!CollectionUtils.isEmpty(portGroupList)) {
                    for (StoragePortGroupRestRep portGroup : portGroupList) {
                        if (portGroupSet.add(portGroup.getId())) {
                            storagePortGroups.add(portGroup);
                        }
                    }
                }
            }
        }
        return createPortGroupOptions(storagePortGroups);
    }
    return options;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) ArrayList(java.util.ArrayList) URI(java.net.URI) ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) StoragePortGroupRestRep(com.emc.storageos.model.portgroup.StoragePortGroupRestRep) 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 4 with ExportGroupRestRep

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

the class BlockProvider method getExportPathExports.

@Asset("exportPathExport")
@AssetDependencies({ "project", "host" })
public List<AssetOption> getExportPathExports(AssetOptionsContext ctx, URI projectId, URI hostOrClusterId) {
    ViPRCoreClient client = api(ctx);
    List<ExportGroupRestRep> exports = findExportGroups(hostOrClusterId, projectId, null, client);
    return createExportWithVarrayOptions(client, exports);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 5 with ExportGroupRestRep

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

the class BlockStorageUtils method removeExportIfEmpty.

public static void removeExportIfEmpty(URI exportId) {
    boolean retryNeeded = false;
    int retryCount = 0;
    do {
        retryNeeded = false;
        ExportGroupRestRep export = getExport(exportId);
        if (ResourceUtils.isActive(export) && export.getVolumes().isEmpty()) {
            try {
                log.info(String.format("Attampting deletion of ExportGroup %s (%s)", export.getGeneratedName(), export.getId()));
                Task<ExportGroupRestRep> response = execute(new DeactivateBlockExport(exportId));
                addAffectedResource(response);
            } catch (ExecutionException e) {
                if (e.getCause() instanceof ServiceErrorException) {
                    ServiceErrorException svcexp = (ServiceErrorException) e.getCause();
                    if (retryCount++ < MAX_RETRY_COUNT && ServiceCode.toServiceCode(svcexp.getCode()) == ServiceCode.API_TASK_EXECUTION_IN_PROGRESS) {
                        log.info(String.format("ExportGroup %s deletion waiting on pending task execution", export.getId()));
                        retryNeeded = true;
                        try {
                            Thread.sleep(RETRY_DELAY_MSEC);
                        } catch (InterruptedException ex) {
                            log.debug("Sleep interrupted");
                        }
                    } else {
                        throw e;
                    }
                }
            }
        }
    } while (retryNeeded);
}
Also used : DeactivateBlockExport(com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ExecutionException(com.emc.sa.engine.ExecutionException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Aggregations

ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)60 URI (java.net.URI)37 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)25 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 AssetOption (com.emc.vipr.model.catalog.AssetOption)9 FlashException (controllers.util.FlashException)9 ArrayList (java.util.ArrayList)9 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)8 ExportUpdateParam (com.emc.storageos.model.block.export.ExportUpdateParam)8 HashSet (java.util.HashSet)6 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 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)5 ITLRestRep (com.emc.storageos.model.block.export.ITLRestRep)5 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)5 HostRestRep (com.emc.storageos.model.host.HostRestRep)5 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)5