use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class AsyncTaskManager method pollTasks.
public synchronized ArrayList<AsyncTaskStatus> pollTasks(ArrayList<Guid> vdsmTaskIdList) {
ArrayList<AsyncTaskStatus> returnValue = new ArrayList<>();
if (vdsmTaskIdList != null && vdsmTaskIdList.size() > 0) {
for (Guid vdsmTaskId : vdsmTaskIdList) {
if (tasks.containsKey(vdsmTaskId)) {
// task is still running or is still in the cache:
tasks.get(vdsmTaskId).setLastStatusAccessTime();
returnValue.add(tasks.get(vdsmTaskId).getLastTaskStatus());
} else {
// task doesn't exist in the manager (shouldn't happen) ->
// assume it has been ended successfully.
log.warn("Polling tasks. Task ID '{}' doesn't exist in the manager -> assuming 'finished'.", vdsmTaskId);
AsyncTaskStatus tempVar = new AsyncTaskStatus();
tempVar.setStatus(AsyncTaskStatusEnum.finished);
tempVar.setResult(AsyncTaskResultEnum.success);
returnValue.add(tempVar);
}
}
}
return returnValue;
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class CoCoAsyncTaskHelper method revertTasks.
public void revertTasks(CommandBase<?> command) {
if (command.getParameters().getVdsmTaskIds() != null) {
// list to send to the pollTasks method
ArrayList<Guid> taskIdAsList = new ArrayList<>();
for (Guid taskId : command.getParameters().getVdsmTaskIds()) {
taskIdAsList.add(taskId);
ArrayList<AsyncTaskStatus> tasksStatuses = asyncTaskManager.get().pollTasks(taskIdAsList);
// call revert task only if ended successfully
if (tasksStatuses.get(0).getTaskEndedSuccessfully()) {
getBackend().getResourceManager().runVdsCommand(VDSCommandType.SPMRevertTask, new SPMTaskGuidBaseVDSCommandParameters(command.getStoragePool().getId(), taskId));
}
taskIdAsList.clear();
}
}
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendDisksResourceTest method testAddIdentifyStorageDomainByName.
@Test
public void testAddIdentifyStorageDomainByName() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpEntityQueryExpectations(QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
setUpEntityQueryExpectations(QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getStorageDomains().get(0));
Disk model = getModel();
model.getStorageDomains().getStorageDomains().get(0).setId(null);
model.getStorageDomains().getStorageDomains().get(0).setName("Storage_Domain_1");
setUpEntityQueryExpectations(QueryType.GetAllStorageDomains, QueryParametersBase.class, new String[] {}, new Object[] {}, getStorageDomains());
setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] {}, new Object[] {}, true, true, GUIDS[0], asList(GUIDS[3]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Disk);
verifyModel((Disk) response.getEntity(), 0);
assertNull(((Disk) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendDisksResourceTest method testAdd.
@Test
public void testAdd() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpEntityQueryExpectations(QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
setUpEntityQueryExpectations(QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getStorageDomains().get(0));
Disk model = getModel();
setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "StorageDomainId" }, new Object[] { GUIDS[2] }, true, true, GUIDS[0], asList(GUIDS[3]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Disk);
verifyModel((Disk) response.getEntity(), 0);
assertNull(((Disk) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendAttachedStorageDomainResourceTest method doTestActivateAsync.
private void doTestActivateAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) throws Exception {
setUriInfo(setUpActionExpectations(ActionType.ActivateStorageDomain, StorageDomainPoolParametersBase.class, new String[] { "StorageDomainId", "StoragePoolId" }, new Object[] { STORAGE_DOMAIN_ID, DATA_CENTER_ID }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus))));
Response response = resource.activate(new Action());
verifyActionResponse(response, "datacenters/" + DATA_CENTER_ID + "/storagedomains/" + STORAGE_DOMAIN_ID, true, null);
Action action = (Action) response.getEntity();
assertTrue(action.isSetStatus());
assertEquals(actionStatus.value(), action.getStatus());
}
Aggregations