Search in sources :

Example 1 with BlockExportController

use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.

the class BlockExportControllerImpl method blockRMI.

/**
 * Puts the operation in the zkQueue so it can Dispatch'd to a Device Controller
 *
 * @param methodName
 * @param args
 * @throws com.emc.storageos.volumecontroller.ControllerException
 */
private void blockRMI(String methodName, Object... args) throws ControllerException {
    final URI export = (URI) args[0];
    BlockExportController controller = getExportController();
    _dispatcher.queue(export, "export", controller, methodName, args);
}
Also used : BlockExportController(com.emc.storageos.volumecontroller.BlockExportController) URI(java.net.URI)

Example 2 with BlockExportController

use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.

the class BlockExportControllerImpl method updatePolicyAndLimits.

/**
 * Updates the Auto-tiering policy from a new vPool for the given volumes.
 *
 * @param volumeURIs the volume uris
 * @param newVpoolURI - URI of new Vpool
 * @param opId the op id
 * @throws ControllerException the controller exception
 */
@Override
public void updatePolicyAndLimits(List<URI> volumeURIs, URI newVpoolURI, String opId) throws ControllerException {
    BlockExportController controller = getExportController();
    _dispatcher.queue(volumeURIs.get(0), "export", controller, "updatePolicyAndLimits", volumeURIs, newVpoolURI, opId);
}
Also used : BlockExportController(com.emc.storageos.volumecontroller.BlockExportController)

Example 3 with BlockExportController

use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.

the class AbstractBlockServiceApiImpl method checkCommonVpoolUpdates.

/**
 * Checks for Vpool updates that can be done on any device type.
 * For now, this is just the Export Path Params or Auto-tiering policy change.
 * If the update was processed, return true, else false.
 *
 * @param volumes
 * @param newVirtualPool
 * @param taskId
 * @return true if update processed
 * @throws InternalException
 */
protected boolean checkCommonVpoolUpdates(List<Volume> volumes, VirtualPool newVirtualPool, String taskId) throws InternalException {
    VirtualPool volumeVirtualPool = _dbClient.queryObject(VirtualPool.class, volumes.get(0).getVirtualPool());
    StringBuffer notSuppReasonBuff = new StringBuffer();
    if (VirtualPoolChangeAnalyzer.isSupportedPathParamsChange(volumes.get(0), volumeVirtualPool, newVirtualPool, _dbClient, notSuppReasonBuff)) {
        BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
        for (Volume volume : volumes) {
            exportController.updateVolumePathParams(volume.getId(), newVirtualPool.getId(), taskId);
        }
        return true;
    }
    if (VirtualPoolChangeAnalyzer.isSupportedAutoTieringPolicyAndLimitsChange(volumes.get(0), volumeVirtualPool, newVirtualPool, _dbClient, notSuppReasonBuff)) {
        /**
         * If it is a Auto-tiering policy change, it is sufficient to check on one volume in the list.
         * Mixed type volumes case has already been taken care in BlockService API.
         */
        BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
        List<URI> volumeURIs = new ArrayList<URI>();
        for (Volume volume : volumes) {
            volumeURIs.add(volume.getId());
        }
        exportController.updatePolicyAndLimits(volumeURIs, newVirtualPool.getId(), taskId);
        return true;
    }
    return false;
}
Also used : BlockExportController(com.emc.storageos.volumecontroller.BlockExportController) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 4 with BlockExportController

use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.

the class ExportGroupService method deactivateExportGroup.

/**
 * Deactivate block export. It will be deleted by the garbage collector on a
 * subsequent iteration
 * <p>
 * This removes visibility of shared storage in the block export to servers through initiators in the block export.
 * <p>
 * If SAN Zones were created as a result of this Export Group (see Export Group Create), they will be removed if they are not in use by
 * other Export Groups.
 * <p>
 *
 * NOTE: This is an asynchronous operation.
 *
 * @param groupId Block export identifier
 * @brief Delete block export
 * @return Task resource representation
 * @throws ControllerException
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep deactivateExportGroup(@PathParam("id") URI groupId) throws ControllerException {
    String task = UUID.randomUUID().toString();
    Operation op = null;
    ExportGroup exportGroup = lookupExportGroup(groupId);
    Map<URI, Map<URI, Integer>> storageMap = ExportUtils.getStorageToVolumeMap(exportGroup, true, _dbClient);
    validateExportGroupNoPendingEvents(exportGroup);
    // Validate that none of the volumes are mounted (datastores, etc)
    if (exportGroup.getVolumes() != null) {
        validateVolumesNotMounted(exportGroup, URIUtil.toURIList(exportGroup.getVolumes().keySet()));
    }
    // Don't allow deactivation if there is an operation in progress.
    Set<URI> tenants = new HashSet<URI>();
    tenants.add(exportGroup.getTenant().getURI());
    Set<ExportGroup> dataObjects = new HashSet<ExportGroup>();
    dataObjects.add(exportGroup);
    checkForPendingTasks(tenants, dataObjects);
    // Mark deletion in progress. This will cause future updates to fail.
    exportGroup.addInternalFlags(DataObject.Flag.DELETION_IN_PROGRESS);
    // Remove any associated ExportPathParam
    if (exportGroup.getVolumes() != null && !exportGroup.getVolumes().isEmpty() && !exportGroup.getPathParameters().isEmpty()) {
        removeBlockObjectsFromPathParamMap(URIUtil.uris(exportGroup.getVolumes().keySet()), exportGroup);
    }
    if (storageMap.isEmpty()) {
        op = initTaskStatus(exportGroup, task, Operation.Status.ready, ResourceOperationTypeEnum.DELETE_EXPORT_GROUP);
        _dbClient.markForDeletion(exportGroup);
    } else {
        op = initTaskStatus(exportGroup, task, Operation.Status.pending, ResourceOperationTypeEnum.DELETE_EXPORT_GROUP);
        _dbClient.persistObject(exportGroup);
        BlockExportController exportController = getExportController();
        exportController.exportGroupDelete(exportGroup.getId(), task);
    }
    auditOp(OperationTypeEnum.DELETE_EXPORT_GROUP, true, AuditLogManager.AUDITOP_BEGIN, exportGroup.getLabel(), exportGroup.getId().toString(), exportGroup.getVirtualArray().toString(), exportGroup.getProject().toString());
    return toTask(exportGroup, task, op);
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) BlockExportController(com.emc.storageos.volumecontroller.BlockExportController) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with BlockExportController

use of com.emc.storageos.volumecontroller.BlockExportController in project coprhd-controller by CoprHD.

the class ExportGroupService method pathsAdjustment.

/**
 * Export paths adjustment
 *
 * @param id The export group id
 * @param param The parameters including addedPaths, removedPaths, storage system URI, exportPathParameters,
 *                  and waitBeforeRemovePaths
 * @brief Initiate port allocations for export
 * @return The pending task
 * @throws ControllerException
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/paths-adjustment")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep pathsAdjustment(@PathParam("id") URI id, ExportPathsAdjustmentParam param) throws ControllerException {
    // Basic validation of ExportGroup and the request
    ExportGroup exportGroup = queryObject(ExportGroup.class, id, true);
    if (exportGroup.checkInternalFlags(DataObject.Flag.DELETION_IN_PROGRESS)) {
        throw BadRequestException.badRequests.deletionInProgress(exportGroup.getClass().getSimpleName(), exportGroup.getLabel());
    }
    validateExportGroupNoPendingEvents(exportGroup);
    validateSuspendSetForNonDiscoverableHosts(exportGroup, param.getWaitBeforeRemovePaths(), param.getRemovedPaths().isEmpty());
    ArgValidator.checkUri(param.getStorageSystem());
    StorageSystem system = queryObject(StorageSystem.class, param.getStorageSystem(), true);
    // Log the input parameters
    param.logParameters(_log);
    // Get the virtual array, default to Export Group varray. Validate it matches.
    URI varray = param.getVirtualArray();
    if (varray != null) {
        boolean validVarray = varray.equals(exportGroup.getVirtualArray());
        if (exportGroup.getAltVirtualArrays() != null && varray.toString().equals(exportGroup.getAltVirtualArrays().get(system.getId().toString()))) {
            validVarray = true;
        }
        if (!validVarray) {
            throw APIException.badRequests.varrayNotInExportGroup(varray.toString());
        }
    } else {
        varray = exportGroup.getVirtualArray();
    }
    validatePathAdjustment(exportGroup, system, param, varray);
    Boolean wait = new Boolean(param.getWaitBeforeRemovePaths());
    String task = UUID.randomUUID().toString();
    Operation op = initTaskStatus(exportGroup, task, Operation.Status.pending, ResourceOperationTypeEnum.EXPORT_PATHS_ADJUSTMENT);
    // persist the export group to the database
    _dbClient.updateObject(exportGroup);
    auditOp(OperationTypeEnum.EXPORT_PATH_ADJUSTMENT, true, AuditLogManager.AUDITOP_BEGIN, exportGroup.getLabel(), exportGroup.getId().toString(), exportGroup.getVirtualArray().toString(), exportGroup.getProject().toString());
    TaskResourceRep taskRes = toTask(exportGroup, task, op);
    BlockExportController exportController = getExportController();
    _log.info("Submitting export path adjustment request.");
    Map<URI, List<URI>> addedPaths = convertInitiatorPathParamToMap(param.getAdjustedPaths());
    Map<URI, List<URI>> removedPaths = convertInitiatorPathParamToMap(param.getRemovedPaths());
    ExportPathParams pathParam = new ExportPathParams(param.getExportPathParameters(), exportGroup);
    exportController.exportGroupPortRebalance(param.getStorageSystem(), id, varray, addedPaths, removedPaths, pathParam, wait, task);
    return taskRes;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) BlockExportController(com.emc.storageos.volumecontroller.BlockExportController) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) BulkList(com.emc.storageos.api.service.impl.response.BulkList) SearchedResRepList(com.emc.storageos.api.service.impl.response.SearchedResRepList) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) ExportPathParams(com.emc.storageos.db.client.model.ExportPathParams) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

BlockExportController (com.emc.storageos.volumecontroller.BlockExportController)12 URI (java.net.URI)10 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)8 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Operation (com.emc.storageos.db.client.model.Operation)4 HashSet (java.util.HashSet)4 ExportPathParams (com.emc.storageos.db.client.model.ExportPathParams)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)2 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)2 Initiator (com.emc.storageos.db.client.model.Initiator)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 ClientControllerException (com.emc.storageos.exceptions.ClientControllerException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)2 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)2