Search in sources :

Example 11 with ExportGroupRestRep

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

the class ClusterAutoExportTest method createExport.

public URI createExport(URI volumeId, ClusterRestRep cluster, VirtualArrayRestRep virtualArray, ProjectRestRep project) {
    ExportCreateParam input = new ExportCreateParam();
    input.setName(cluster.getName());
    input.setType("Cluster");
    input.addCluster(cluster.getId());
    input.setVarray(virtualArray.getId());
    input.addVolume(volumeId);
    input.setProject(project.getId());
    ExportGroupRestRep export = client.blockExports().create(input).get();
    System.out.println("Created Export Group: " + export.getId());
    return export.getId();
}
Also used : ExportCreateParam(com.emc.storageos.model.block.export.ExportCreateParam) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep)

Example 12 with ExportGroupRestRep

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

the class BlockExports method findByHostOrCluster.

/**
 * Finds the exports associated with a host (or that host's cluster) that are for the given project. If a virtual
 * array ID is specified, only exports associated with that virtual array are returned.
 *
 * @param hostId
 *            the ID of the host.
 * @param projectId
 *            the ID of the project.
 * @param virtualArrayId
 *            the ID of the virtual array to restrict the exports to, or null for no restriction.
 * @return the list of export groups associated with the host or any host in the same cluster.
 * @deprecated This method was only used in one test class {@code ViPRClientApp} which doesn't use this method anymore.
 */
@Deprecated
public List<ExportGroupRestRep> findByHostOrCluster(URI hostId, URI projectId, URI virtualArrayId) {
    HostRestRep host = parent.hosts().get(hostId);
    URI clusterId = (host != null) ? id(host.getCluster()) : null;
    ResourceFilter<ExportGroupRestRep> filter;
    if (virtualArrayId == null) {
        filter = new ExportHostOrClusterFilter(hostId, clusterId);
    } else {
        filter = new ExportHostOrClusterFilter(hostId, clusterId).and(new ExportVirtualArrayFilter(virtualArrayId));
    }
    return findByProject(projectId, filter);
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) 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 13 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 14 with ExportGroupRestRep

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

the class BlockStorageUtils method addVolumesToExport.

public static void addVolumesToExport(Collection<URI> volumeIds, Integer hlu, URI exportId, Map<URI, Integer> volumeHlus, Integer minPaths, Integer maxPaths, Integer pathsPerInitiator, URI portGroup) {
    Task<ExportGroupRestRep> task = execute(new AddVolumesToExport(exportId, volumeIds, hlu, volumeHlus, minPaths, maxPaths, pathsPerInitiator, portGroup));
    addRollback(new RemoveBlockResourcesFromExport(exportId, volumeIds));
    addAffectedResource(task);
}
Also used : ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) AddVolumesToExport(com.emc.sa.service.vipr.block.tasks.AddVolumesToExport) RemoveBlockResourcesFromExport(com.emc.sa.service.vipr.block.tasks.RemoveBlockResourcesFromExport)

Example 15 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)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