use of com.vmware.vim25.TaskInfoState in project coprhd-controller by CoprHD.
the class VMwareTask method cancelTask.
public void cancelTask(Task task) throws Exception {
if (task == null || task.getTaskInfo() == null) {
warn("VMware task is null or has no task info. Unable to cancel it.");
} else {
TaskInfoState state = task.getTaskInfo().getState();
if (state == TaskInfoState.queued || state == TaskInfoState.running) {
info("Cancelling task '%s'", getDetail());
task.cancelTask();
}
}
}
use of com.vmware.vim25.TaskInfoState in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method isComplete.
/**
* Checks if the VMWare task has completed
*
* @param task
* the task to check
* @return true if the task has completed, otherwise returns false
* @throws Exception
* if an error occurs while monitoring the task
*/
private boolean isComplete(Task task) throws Exception {
TaskInfo info = task.getTaskInfo();
TaskInfoState state = info.getState();
if (state == TaskInfoState.success) {
return true;
} else if (state == TaskInfoState.error) {
return true;
}
return false;
}
use of com.vmware.vim25.TaskInfoState in project coprhd-controller by CoprHD.
the class VMwareTask method isComplete.
private boolean isComplete(Task task) throws Exception {
TaskInfo info = task.getTaskInfo();
TaskInfoState state = info.getState();
if (state == TaskInfoState.success) {
return true;
} else if (state == TaskInfoState.error) {
String reason = info.getError().getLocalizedMessage();
error("Task '%s' failed, reason: %s", getDetail(), StringUtils.defaultIfBlank(reason, "unknown"));
throw stateException("VMwareTask.detail.isCompleteError", reason);
}
return false;
}
Aggregations