Search in sources :

Example 76 with Operation

use of com.emc.storageos.db.client.model.Operation 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)

Example 77 with Operation

use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.

the class FileMirrorServiceApiImpl method failFileShareCreateRequest.

private void failFileShareCreateRequest(String task, TaskList taskList, List<FileShare> preparedFileShares, String errorMsg) {
    String errorMessage = String.format("Controller error: %s", errorMsg);
    for (TaskResourceRep fileShareTask : taskList.getTaskList()) {
        fileShareTask.setState(Operation.Status.error.name());
        fileShareTask.setMessage(errorMessage);
        Operation statusUpdate = new Operation(Operation.Status.error.name(), errorMessage);
        _dbClient.updateTaskOpStatus(FileShare.class, fileShareTask.getResource().getId(), task, statusUpdate);
    }
    for (FileShare fileShare : preparedFileShares) {
        fileShare.setInactive(true);
        _dbClient.updateObject(fileShare);
    }
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 78 with Operation

use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.

the class FileQuotaDirectoryService method deactivateQuotaDirectory.

/**
 * Deactivate Quota directory of file system, this will move the
 * Quota directory to a "marked-for-delete" state
 * <p>
 * NOTE: This is an asynchronous operation.
 *
 * @param id
 *            the URN of the QuotaDirectory
 * @param param
 *            QuotaDirectory delete param for optional force delete
 * @brief Delete file system quota directory
 * @return Task resource representation
 * @throws com.emc.storageos.svcs.errorhandling.resources.InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep deactivateQuotaDirectory(@PathParam("id") URI id, QuotaDirectoryDeleteParam param) throws InternalException {
    _log.info("FileService::deactivateQtree Request recieved {}", id);
    String task = UUID.randomUUID().toString();
    ArgValidator.checkFieldUriType(id, QuotaDirectory.class, "id");
    QuotaDirectory quotaDirectory = queryResource(id);
    FileShare fs = queryFileShareResource(quotaDirectory.getParent().getURI());
    ArgValidator.checkFieldNotNull(fs, "filesystem");
    // if the delete request is with force flag!!!
    if (param.getForceDelete()) {
        _log.error("Quota directory delete operation is not supported with force delete {}", param.getForceDelete());
        throw APIException.badRequests.quotaDirectoryDeleteNotSupported(param.getForceDelete());
    } else {
        // Fail to delete quota directory, if there are any dependency objects like exports, shares
        if (quotaDirectoryHasExportsOrShares(fs, quotaDirectory.getName())) {
            throw APIException.badRequests.resourceCannotBeDeleted("Quota directory " + quotaDirectory.getName() + " has exports/shares ");
        }
    }
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR);
    quotaDirectory.getOpStatus().createTaskStatus(task, op);
    fs.setOpStatus(new OpStatusMap());
    fs.getOpStatus().createTaskStatus(task, op);
    _dbClient.persistObject(fs);
    _dbClient.persistObject(quotaDirectory);
    // Now get ready to make calls into the controller
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
    FileController controller = getController(FileController.class, device.getSystemType());
    try {
        controller.deleteQuotaDirectory(device.getId(), quotaDirectory.getId(), fs.getId(), task);
    } catch (InternalException e) {
        throw e;
    }
    auditOp(OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, true, AuditLogManager.AUDITOP_BEGIN, quotaDirectory.getLabel(), quotaDirectory.getId().toString(), fs.getId().toString());
    fs = _dbClient.queryObject(FileShare.class, fs.getId());
    _log.debug("FileService::Quota directory Before sending response, FS ID : {}, Taks : {} ; Status {}", fs.getOpStatus().get(task), fs.getOpStatus().get(task).getStatus());
    return toTask(quotaDirectory, task, op);
}
Also used : FileController(com.emc.storageos.volumecontroller.FileController) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) MapQuotaDirectory(com.emc.storageos.api.mapper.functions.MapQuotaDirectory) FileShareQuotaDirectory(com.emc.storageos.volumecontroller.FileShareQuotaDirectory) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 79 with Operation

use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.

the class DefaultBlockServiceApiImpl method establishVolumeAndSnapshotGroupRelation.

/**
 * {@inheritDoc}
 *
 * @throws ControllerException
 */
@Override
public TaskResourceRep establishVolumeAndSnapshotGroupRelation(StorageSystem storageSystem, Volume sourceVolume, BlockSnapshot snapshot, String taskId) throws ControllerException {
    _log.info("START establish Volume and Snapshot group relation");
    // Create the task on the block snapshot
    Operation op = _dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), taskId, ResourceOperationTypeEnum.ESTABLISH_VOLUME_SNAPSHOT);
    snapshot.getOpStatus().put(taskId, op);
    try {
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        controller.establishVolumeAndSnapshotGroupRelation(storageSystem.getId(), sourceVolume.getId(), snapshot.getId(), taskId);
    } catch (ControllerException e) {
        String errorMsg = String.format("Failed to establish group relation between volume group and snapshot group." + "Source volume: %s, Snapshot: %s", sourceVolume.getId(), snapshot.getId());
        _log.error(errorMsg, e);
        _dbClient.error(BlockSnapshot.class, snapshot.getId(), taskId, e);
    }
    return toTask(snapshot, taskId, op);
}
Also used : ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockController(com.emc.storageos.volumecontroller.BlockController) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Operation(com.emc.storageos.db.client.model.Operation)

Example 80 with Operation

use of com.emc.storageos.db.client.model.Operation in project coprhd-controller by CoprHD.

the class DefaultBlockServiceApiImpl method addVolumeTask.

/**
 * Creates tasks against consistency groups associated with a request and adds them to the given task list.
 *
 * @param group
 * @param taskList
 * @param taskId
 * @param operationTypeEnum
 */
protected void addVolumeTask(Volume volume, TaskList taskList, String taskId, ResourceOperationTypeEnum operationTypeEnum) {
    Operation op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), taskId, operationTypeEnum);
    taskList.getTaskList().add(TaskMapper.toTask(volume, taskId, op));
}
Also used : Operation(com.emc.storageos.db.client.model.Operation)

Aggregations

Operation (com.emc.storageos.db.client.model.Operation)272 URI (java.net.URI)114 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)105 Path (javax.ws.rs.Path)105 Produces (javax.ws.rs.Produces)103 Volume (com.emc.storageos.db.client.model.Volume)93 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)92 ArrayList (java.util.ArrayList)83 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)70 Consumes (javax.ws.rs.Consumes)70 NamedURI (com.emc.storageos.db.client.model.NamedURI)68 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)68 POST (javax.ws.rs.POST)67 TaskList (com.emc.storageos.model.TaskList)59 FileShare (com.emc.storageos.db.client.model.FileShare)56 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)49 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)40 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)36 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)35 ControllerException (com.emc.storageos.volumecontroller.ControllerException)35