use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class HostService method hostHasPendingTasks.
/**
* Check for pending tasks on the Host
*
* @param hostURI Host ID
* @return true if the host has pending tasks, false otherwise
*/
private boolean hostHasPendingTasks(URI hostURI) {
boolean hasPendingTasks = false;
List<Task> taskList = TaskUtils.findResourceTasks(_dbClient, hostURI);
for (Task task : taskList) {
if (task.isPending()) {
hasPendingTasks = true;
break;
}
}
return hasPendingTasks;
}
use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class ExportService method waitForTaskCompletion.
boolean waitForTaskCompletion(URI resourceId, String task) throws InterruptedException {
int tryCnt = 0;
Task taskObj = null;
// while(tryCnt < RETRY_COUNT){
while (true) {
_log.info("THE TASK var is {}", task);
Thread.sleep(40000);
taskObj = TaskUtils.findTaskForRequestId(_dbClient, resourceId, task);
_log.info("THE TASKOBJ is {}", taskObj.toString());
_log.info("THE TASKOBJ.GETSTATUS is {}", taskObj.getStatus().toString());
if (taskObj != null) {
if (taskObj.getStatus().equals("ready")) {
return true;
}
if (taskObj.getStatus().equals("error")) {
return false;
} else {
tryCnt++;
}
} else {
return false;
}
}
}
use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class WorkflowService method isTopLevelWorkflowForUserTenant.
/**
* Determines if the passed top-level workflow is valid for the user's tenant.
* Child workflows should not be passed to this routine.
*
* @param topLevelWorkflow A reference to a top-level workflow.
*
* @return true if the user's tenant is the workflow tenant.
*/
private boolean isTopLevelWorkflowForUserTenant(Workflow topLevelWorkflow) {
boolean workflowForTenant = false;
// Since the tenant is not directly associated to a workflow, we find the
// Task instance(s) whose request id is the same as the orchestration task
// id for the workflow. We can then get the tenant from the task and compare
// that tenant to the user tenant.
String wfOrchTaskId = topLevelWorkflow.getOrchTaskId();
List<Task> wfTasks = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Task.class, AlternateIdConstraint.Factory.getTasksByRequestIdConstraint(wfOrchTaskId));
if (!wfTasks.isEmpty()) {
for (Task wfTask : wfTasks) {
// the tenant.
if (wfTask.getTenant().toString().equals(getUserFromContext().getTenantId())) {
workflowForTenant = true;
break;
}
}
}
return workflowForTenant;
}
use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class TaskService method deleteTask.
/**
* Deletes the specified task. After this operation has been called, the task will no longer be accessible.
*
* @brief Deletes a task
* @param taskId
* ID of the task to be deleted
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{taskId}/delete")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN }, acls = { ACL.OWN })
public Response deleteTask(@PathParam("taskId") URI taskId) {
Task task = queryResource(taskId);
// Permission Check
if (task.getTenant().equals(TenantOrg.SYSTEM_TENANT)) {
verifySystemAdmin();
} else {
verifyUserHasAccessToTenants(Lists.newArrayList(task.getTenant()));
}
_dbClient.removeObject(task);
auditOp(OperationTypeEnum.DELETE_TASK, true, null, task.getId().toString(), task.getLabel());
return Response.ok().build();
}
use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class TaskService method queryResource.
protected Task queryResource(URI id) {
ArgValidator.checkUri(id);
Task task = _dbClient.queryObject(Task.class, id);
ArgValidator.checkEntityNotNull(task, id, isIdEmbeddedInURL(id));
return task;
}
Aggregations