Search in sources :

Example 81 with TaskResourceRep

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

the class Tasks method detailsJson.

public static void detailsJson(String taskId) {
    if (StringUtils.isBlank(taskId)) {
        notFound("Task [" + taskId + "]");
    }
    TaskResourceRep task = TaskUtils.getTask(uri(taskId));
    if (task == null) {
        notFound("Task [" + taskId + "]");
    }
    renderJSON(TaskUtils.getTaskSummary(task));
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep)

Example 82 with TaskResourceRep

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

the class Tasks method listAllJson.

public static void listAllJson(Long lastUpdated, Boolean systemTasks) {
    if (systemTasks == null) {
        systemTasks = Boolean.FALSE;
    }
    if (systemTasks && Security.isSystemAdminOrRestrictedSystemAdmin() == false) {
        forbidden();
    }
    Integer maxTasks = params.get("maxTasks", Integer.class);
    if (maxTasks == null) {
        maxTasks = 100;
    }
    if (maxTasks == 0) {
        maxTasks = -1;
    }
    ViPRCoreClient client = getViprClient();
    List<TaskResourceRep> taskResourceReps = null;
    if (lastUpdated == null) {
        if (systemTasks) {
            taskResourceReps = client.tasks().getByRefs(client.tasks().listByTenant(SYSTEM_TENANT, maxTasks));
        } else {
            taskResourceReps = client.tasks().getByRefs(client.tasks().listByTenant(uri(Models.currentAdminTenant()), maxTasks));
        }
    } else {
        taskResourceReps = taskPoll(lastUpdated, systemTasks, maxTasks);
    }
    Collections.sort(taskResourceReps, orderedTaskComparitor);
    List<TasksDataTable.Task> tasks = Lists.newArrayList();
    if (taskResourceReps != null) {
        for (TaskResourceRep taskResourceRep : taskResourceReps) {
            TasksDataTable.Task task = new TasksDataTable.Task(taskResourceRep);
            if (Objects.equals(task.state, "pending") || Objects.equals(task.state, "queued")) {
                task.progress = Math.max(task.progress, MINIMUM_TASK_PROGRESS);
            }
            tasks.add(task);
        }
    }
    renderJSON(DataTablesSupport.createJSON(tasks, params));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) TasksDataTable(models.datatable.TasksDataTable) TaskResourceRep(com.emc.storageos.model.TaskResourceRep)

Example 83 with TaskResourceRep

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

the class Tasks method details.

public static void details(String taskId) {
    if (StringUtils.isBlank(taskId)) {
        listAll(false);
    }
    TaskResourceRep task = TaskUtils.getTask(uri(taskId));
    if (task == null) {
        flash.error(MessagesUtils.get(UNKNOWN, taskId));
        listAll(false);
    }
    if (task != null && task.getResource() != null && task.getResource().getId() != null) {
        ResourceType resourceType = ResourceType.fromResourceId(task.getResource().getId().toString());
        renderArgs.put("resourceType", resourceType);
    }
    String orderId = TagUtils.getOrderIdTagValue(task);
    String orderNumber = TagUtils.getOrderNumberTagValue(task);
    Common.angularRenderArgs().put("task", TaskUtils.getTaskSummary(task));
    TaskLogsDataTable dataTable = new TaskLogsDataTable();
    render(task, dataTable, orderId, orderNumber);
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) TaskLogsDataTable(models.datatable.TaskLogsDataTable) ResourceType(com.emc.sa.util.ResourceType)

Example 84 with TaskResourceRep

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

the class FileProtectionPolicies method saveUnAssignPolicy.

@FlashException(keep = true, referrer = { "unassign" })
public static void saveUnAssignPolicy(AssignPolicyForm assignPolicy) {
    if (assignPolicy == null) {
        Logger.error("No Unassign policy parameters passed");
        badRequest("No Unassign policy parameters passed");
        return;
    }
    assignPolicy.validate("UnassignPolicy");
    if (Validation.hasErrors()) {
        Common.handleError();
    }
    assignPolicy.id = params.get("id");
    FilePolicyUnAssignParam unAssignPolicyParam = new FilePolicyUnAssignParam();
    try {
        if (updateUnAssignPolicyParam(assignPolicy, unAssignPolicyParam)) {
            TaskResourceRep taskRes = getViprClient().fileProtectionPolicies().unassignPolicy(uri(assignPolicy.id), unAssignPolicyParam);
            if (isTaskSuccessful(assignPolicy.id, taskRes)) {
                flash.success(MessagesUtils.get("unAssignPolicy.request.saved", assignPolicy.policyName));
            }
        }
    } catch (Exception ex) {
        flash.error(ex.getMessage(), assignPolicy.policyName);
    }
    if (StringUtils.isNotBlank(assignPolicy.referrerUrl)) {
        redirect(assignPolicy.referrerUrl);
    } else {
        list();
    }
}
Also used : FilePolicyUnAssignParam(com.emc.storageos.model.file.policy.FilePolicyUnAssignParam) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) FlashException(controllers.util.FlashException) FlashException(controllers.util.FlashException)

Example 85 with TaskResourceRep

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

the class BlockVolumes method deactivate.

/**
 * Begins deactivating a block volume by ID.
 * <p>
 * API Call: <tt>POST /block/volumes/{id}/deactivate?type={deletionType}</tt>
 *
 * @param id
 *            the ID of the block volume to deactivate.
 * @param deletionType
 *            {@code FULL} or {@code VIPR_ONLY}
 * @return a task for monitoring the progress of the operation.
 *
 * @see com.emc.storageos.model.block.VolumeDeleteTypeEnum
 */
public Task<VolumeRestRep> deactivate(URI id, VolumeDeleteTypeEnum deletionType) {
    URI uri = client.uriBuilder(getDeactivateUrl()).queryParam("type", deletionType).build(id);
    TaskResourceRep task = client.postURI(TaskResourceRep.class, uri);
    return new Task<>(client, task, resourceClass);
}
Also used : Task(com.emc.vipr.client.Task) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) URI(java.net.URI)

Aggregations

TaskResourceRep (com.emc.storageos.model.TaskResourceRep)160 URI (java.net.URI)85 TaskList (com.emc.storageos.model.TaskList)82 Operation (com.emc.storageos.db.client.model.Operation)68 Produces (javax.ws.rs.Produces)59 ArrayList (java.util.ArrayList)56 Volume (com.emc.storageos.db.client.model.Volume)55 Path (javax.ws.rs.Path)54 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)53 POST (javax.ws.rs.POST)50 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)49 Consumes (javax.ws.rs.Consumes)36 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)35 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 NamedURI (com.emc.storageos.db.client.model.NamedURI)30 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)23 Project (com.emc.storageos.db.client.model.Project)20 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)18 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)17 Copy (com.emc.storageos.model.block.Copy)17