Search in sources :

Example 51 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class FileService method createFileTaskList.

/**
 * A method that pre-creates task and FileShare object to return to the caller of the API.
 *
 * @param param
 * @param project
 *            - project of the FileShare
 * @param tenantOrg
 *            - tenant of the FileShare
 * @param varray
 *            - varray of the FileShare
 * @param vpool
 *            - vpool of the Fileshare
 * @param flags
 *            -
 * @param task
 * @return
 */
private TaskList createFileTaskList(FileSystemParam param, Project project, TenantOrg tenantOrg, VirtualArray varray, VirtualPool vpool, DataObject.Flag[] flags, String task) {
    TaskList taskList = new TaskList();
    FileShare fs = prepareEmptyFileSystem(param, project, tenantOrg, varray, vpool, flags, task);
    TaskResourceRep fileTask = toTask(fs, task);
    taskList.getTaskList().add(fileTask);
    _log.info(String.format("FileShare and Task Pre-creation Objects [Init]--  Source FileSystem: %s, Task: %s, Op: %s", fs.getId(), fileTask.getId(), task));
    return taskList;
}
Also used : TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare)

Example 52 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class FileService method pauseContinuousCopies.

/**
 * Pause continuous copies.
 *
 * @prereq none
 * @param id the URN of a ViPR Source file share
 * @brief Pause the replication session between source and target file system.
 * @return TaskResourceRep
 * @throws ControllerException
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/pause")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList pauseContinuousCopies(@PathParam("id") URI id, FileReplicationParam param) throws ControllerException {
    doMirrorOperationValidation(id, ProtectionOp.PAUSE.toString());
    String task = UUID.randomUUID().toString();
    FileShare sourceFileShare = queryResource(id);
    Operation op = _dbClient.createTaskOpStatus(FileShare.class, id, task, ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_PAUSE);
    op.setDescription("pause the replication link between source and target");
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, sourceFileShare.getStorageDevice());
    FileController controller = getController(FileController.class, system.getSystemType());
    controller.performFileReplicationOperation(system.getId(), id, ProtectionOp.PAUSE.toString().toLowerCase(), task);
    TaskList taskList = new TaskList();
    TaskResourceRep taskResp = toTask(sourceFileShare, task, op);
    taskList.getTaskList().add(taskResp);
    return taskList;
}
Also used : FileController(com.emc.storageos.volumecontroller.FileController) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 53 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class FileService method failbackProtection.

/**
 * Request to fail Back the protection link associated with the param.copyID.
 *
 * NOTE: This is an asynchronous operation.
 *
 * @prereq none
 *
 * @param id
 *            the URN of a ViPR Source files hare
 * @param param
 *            FileReplicationParam to fail Back to
 *
 * @brief Fail Back the fileShare protection link
 * @return TaskList
 *
 * @throws ControllerException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failback")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failbackProtection(@PathParam("id") URI id, FileReplicationParam param) throws ControllerException {
    doMirrorOperationValidation(id, ProtectionOp.FAILBACK.toString());
    TaskResourceRep taskResp = null;
    StoragePort storageportNFS = null;
    StoragePort storageportCIFS = null;
    TaskList taskList = new TaskList();
    String task = UUID.randomUUID().toString();
    FileShare sourceFileShare = queryResource(id);
    Operation op = _dbClient.createTaskOpStatus(FileShare.class, id, task, ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILBACK);
    op.setDescription("failback to source file system from target system");
    boolean replicateConfiguration = param.isReplicateConfiguration();
    if (replicateConfiguration) {
        List<String> targetfileUris = new ArrayList<String>();
        targetfileUris.addAll(sourceFileShare.getMirrorfsTargets());
        FileShare targetFileShare = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        SMBShareMap smbShareMap = targetFileShare.getSMBFileShares();
        if (smbShareMap != null) {
            storageportCIFS = _fileScheduler.placeFileShareExport(sourceFileShare, StorageProtocol.File.CIFS.name(), null);
        }
        FSExportMap nfsExportMap = targetFileShare.getFsExports();
        if (nfsExportMap != null) {
            storageportNFS = _fileScheduler.placeFileShareExport(sourceFileShare, StorageProtocol.File.NFS.name(), null);
        }
    }
    FileServiceApi fileServiceApi = getFileShareServiceImpl(sourceFileShare, _dbClient);
    try {
        fileServiceApi.failbackFileShare(sourceFileShare.getId(), storageportNFS, storageportCIFS, replicateConfiguration, task);
    } catch (InternalException e) {
        if (_log.isErrorEnabled()) {
            _log.error("", e);
        }
        op = sourceFileShare.getOpStatus().get(task);
        op.error(e);
        sourceFileShare.getOpStatus().updateTaskStatus(task, op);
        _dbClient.updateObject(sourceFileShare);
        throw e;
    }
    taskResp = toTask(sourceFileShare, task, op);
    taskList.getTaskList().add(taskResp);
    return taskList;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) TaskList(com.emc.storageos.model.TaskList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) 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 54 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class EventService method executeEventMethod.

/**
 * Executes an actionable event method
 *
 * @param event the event to execute
 * @param approve if true, the action is to approve, if false the action is to decline
 * @return list of tasks
 */
public TaskList executeEventMethod(ActionableEvent event, boolean approve) {
    TaskList taskList = new TaskList();
    byte[] method = approve ? event.getApproveMethod() : event.getDeclineMethod();
    String eventStatus = approve ? ActionableEvent.Status.approved.name() : ActionableEvent.Status.declined.name();
    event.setEventExecutionTime(Calendar.getInstance());
    event.setApproveDetails(new StringSet(getEventDetails(event, true)));
    event.setDeclineDetails(new StringSet(getEventDetails(event, false)));
    if (method == null || method.length == 0) {
        _log.info("Method is null or empty for event " + event.getId());
        event.setEventStatus(eventStatus);
        _dbClient.updateObject(event);
        return taskList;
    }
    ActionableEvent.Method eventMethod = ActionableEvent.Method.deserialize(method);
    if (eventMethod == null) {
        _log.info("Event method is null or empty for event " + event.getId());
        event.setEventStatus(eventStatus);
        _dbClient.updateObject(event);
        return taskList;
    }
    try {
        Method classMethod = getMethod(ActionableEventExecutor.class, eventMethod.getMethodName());
        ComputeSystemController controller = getController(ComputeSystemController.class, null);
        ActionableEventExecutor executor = new ActionableEventExecutor(_dbClient, controller);
        Object[] parameters = Arrays.copyOf(eventMethod.getArgs(), eventMethod.getArgs().length + 1);
        parameters[parameters.length - 1] = event.getId();
        event.setEventStatus(eventStatus);
        _dbClient.updateObject(event);
        TaskResourceRep result = (TaskResourceRep) classMethod.invoke(executor, parameters);
        if (result != null && result.getId() != null) {
            Collection<String> taskCollection = Lists.newArrayList(result.getId().toString());
            ActionableEvent updatedEvent = _dbClient.queryObject(ActionableEvent.class, event.getId());
            updatedEvent.setTaskIds(new StringSet(taskCollection));
            _dbClient.updateObject(updatedEvent);
        }
        taskList.addTask(result);
        return taskList;
    } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        _log.error(e.getMessage(), e.getCause());
        throw APIException.badRequests.errorInvokingEventMethod(event.getId(), eventMethod.getMethodName());
    }
}
Also used : ActionableEvent(com.emc.storageos.db.client.model.ActionableEvent) TaskList(com.emc.storageos.model.TaskList) ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) StringSet(com.emc.storageos.db.client.model.StringSet) DataObject(com.emc.storageos.db.client.model.DataObject)

Example 55 with TaskList

use of com.emc.storageos.model.TaskList in project coprhd-controller by CoprHD.

the class BlockService method deleteVolume.

/**
 * Deactivate a volume, will result in permanent deletion of the requested volume(s) from the storage system it was created on and will
 * move the volume to a "marked-for-delete" state after the deletion happens on the array side. The volume will be
 * deleted from the database when all references to this volume of type BlockSnapshot and ExportGroup are deleted.
 *
 * If "?force=true" is added to the path, it will force the delete of internal
 * volumes that have the SUPPORTS_FORCE flag.
 *
 * If "?type=VIPR_ONLY" is added to the path, it will delete volumes only from ViPR data base and leaves the volume on storage array as
 * it is.
 * Possible value for the attribute type : FULL, VIPR_ONLY
 * FULL : Deletes the volumes permanently on array and ViPR data base.
 * VIPR_ONLY : Deletes the volumes only from ViPR data base and leaves the volumes on array as it is.
 *
 * NOTE: This is an asynchronous operation.
 *
 * @prereq Dependent volume resources such as snapshots and export groups must be deleted
 *
 * @param id
 *            the URN of a ViPR volume to delete
 * @param force {@link DefaultValue} false
 * @param type {@link DefaultValue} FULL
 *
 * @brief Delete volume
 * @return Volume information
 *
 * @throws InternalException
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep deleteVolume(@PathParam("id") URI id, @DefaultValue("false") @QueryParam("force") boolean force, @DefaultValue("FULL") @QueryParam("type") String type) throws InternalException {
    // Reuse implementation for deleting multiple volumes.
    BulkDeleteParam deleteParam = new BulkDeleteParam();
    deleteParam.setIds(Lists.newArrayList(id));
    TaskList taskList = deleteVolumes(deleteParam, force, type);
    return taskList.getTaskList().get(0);
}
Also used : BulkDeleteParam(com.emc.storageos.model.block.BulkDeleteParam) TaskList(com.emc.storageos.model.TaskList) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

TaskList (com.emc.storageos.model.TaskList)161 ArrayList (java.util.ArrayList)84 URI (java.net.URI)83 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)82 Volume (com.emc.storageos.db.client.model.Volume)67 Produces (javax.ws.rs.Produces)62 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)57 Operation (com.emc.storageos.db.client.model.Operation)55 POST (javax.ws.rs.POST)55 Path (javax.ws.rs.Path)54 Consumes (javax.ws.rs.Consumes)44 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)35 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)33 NamedURI (com.emc.storageos.db.client.model.NamedURI)28 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)27 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)27 Tasks (com.emc.vipr.client.Tasks)27 List (java.util.List)26 WaitForTasks (com.emc.sa.service.vipr.tasks.WaitForTasks)23