Search in sources :

Example 1 with DeactivateBlockExport

use of com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport 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)

Example 2 with DeactivateBlockExport

use of com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport in project coprhd-controller by CoprHD.

the class BlockStorageUtils method createClusterExport.

public static URI createClusterExport(URI projectId, URI virtualArrayId, List<URI> volumeIds, Integer hlu, Cluster cluster, Map<URI, Integer> volumeHlus, Integer minPaths, Integer maxPaths, Integer pathsPerInitiator, URI portGroup) {
    String exportName = cluster.getLabel();
    Task<ExportGroupRestRep> task = execute(new CreateExport(exportName, virtualArrayId, projectId, volumeIds, hlu, cluster.getLabel(), null, cluster.getId(), volumeHlus, minPaths, maxPaths, pathsPerInitiator, portGroup));
    URI exportId = task.getResourceId();
    addRollback(new DeactivateBlockExport(exportId));
    addAffectedResource(exportId);
    return exportId;
}
Also used : DeactivateBlockExport(com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) CreateExport(com.emc.sa.service.vipr.block.tasks.CreateExport) URI(java.net.URI)

Example 3 with DeactivateBlockExport

use of com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport in project coprhd-controller by CoprHD.

the class BlockStorageUtils method createHostExport.

public static URI createHostExport(URI projectId, URI virtualArrayId, List<URI> volumeIds, Integer hlu, Host host, Map<URI, Integer> volumeHlus, Integer minPaths, Integer maxPaths, Integer pathsPerInitiator, URI portGroup) {
    String exportName = host.getHostName();
    Task<ExportGroupRestRep> task = execute(new CreateExport(exportName, virtualArrayId, projectId, volumeIds, hlu, host.getHostName(), host.getId(), null, volumeHlus, minPaths, maxPaths, pathsPerInitiator, portGroup));
    URI exportId = task.getResourceId();
    addRollback(new DeactivateBlockExport(exportId));
    addAffectedResource(exportId);
    return exportId;
}
Also used : DeactivateBlockExport(com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) CreateExport(com.emc.sa.service.vipr.block.tasks.CreateExport) URI(java.net.URI)

Example 4 with DeactivateBlockExport

use of com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport in project coprhd-controller by CoprHD.

the class BlockStorageUtils method addHostToExport.

public static void addHostToExport(URI exportId, URI host, Integer minPaths, Integer maxPaths, Integer pathsPerInitiator, URI portGroup) {
    Task<ExportGroupRestRep> task = execute(new AddHostToExport(exportId, host, minPaths, maxPaths, pathsPerInitiator, portGroup));
    addRollback(new DeactivateBlockExport(exportId));
    addAffectedResource(task);
}
Also used : DeactivateBlockExport(com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport) AddHostToExport(com.emc.sa.service.vipr.block.tasks.AddHostToExport) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep)

Example 5 with DeactivateBlockExport

use of com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport in project coprhd-controller by CoprHD.

the class BlockStorageUtils method addClusterToExport.

public static void addClusterToExport(URI exportId, URI cluster, Integer minPaths, Integer maxPaths, Integer pathsPerInitiator, URI portGroup) {
    Task<ExportGroupRestRep> task = execute(new AddClusterToExport(exportId, cluster, minPaths, maxPaths, pathsPerInitiator, portGroup));
    addRollback(new DeactivateBlockExport(exportId));
    addAffectedResource(task);
}
Also used : DeactivateBlockExport(com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) AddClusterToExport(com.emc.sa.service.vipr.block.tasks.AddClusterToExport)

Aggregations

DeactivateBlockExport (com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport)5 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 CreateExport (com.emc.sa.service.vipr.block.tasks.CreateExport)2 URI (java.net.URI)2 ExecutionException (com.emc.sa.engine.ExecutionException)1 AddClusterToExport (com.emc.sa.service.vipr.block.tasks.AddClusterToExport)1 AddHostToExport (com.emc.sa.service.vipr.block.tasks.AddHostToExport)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1