use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddUseExistingIcons.
@Test
public void testAddUseExistingIcons() throws Exception {
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 0, 1);
setUpGetSoundcardExpectations(1);
setUpGetBallooningExpectations(0, 0);
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
setUpAddExpectations();
setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description" }, new Object[] { NAMES[0], DESCRIPTIONS[0] }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
final Template restModel = getRestModel(0);
restModel.setSmallIcon(IconTestHelpler.createIcon(GUIDS[2]));
restModel.setLargeIcon(IconTestHelpler.createIcon(GUIDS[3]));
Response response = doAdd(restModel);
assertEquals(201, response.getStatus());
verifyModel((Template) response.getEntity(), 0);
assertNull(((Template) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendStorageDomainDisksResourceTest 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));
Disk model = getModel();
setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "StorageDomainId" }, new Object[] { GUIDS[3] }, true, true, GUIDS[0], asList(storagePoolId), 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 CreationMapper method map.
@Mapping(from = List.class, to = Creation.class)
public static Creation map(List<AsyncTaskStatus> entity, Creation template) {
Creation model = template != null ? template : new Creation();
CreationStatus asyncStatus = null;
for (AsyncTaskStatus task : entity) {
asyncStatus = AsyncTaskMapper.map(task, asyncStatus);
}
model.setStatus(asyncStatus.value());
if (asyncStatus == CreationStatus.FAILED) {
model.setFault(new Fault());
for (AsyncTaskStatus task : entity) {
if (task.getException() != null) {
model.getFault().setDetail(task.getException().toString());
break;
}
}
}
return model;
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class ActionMapper method map.
@Mapping(from = List.class, to = Action.class)
public static Action map(List<AsyncTaskStatus> entity, Action template) {
Action model = template != null ? template : new Action();
CreationStatus asyncStatus = null;
for (AsyncTaskStatus task : entity) {
asyncStatus = AsyncTaskMapper.map(task, asyncStatus);
}
model.setStatus(asyncStatus.value());
if (asyncStatus == CreationStatus.FAILED) {
model.setFault(new Fault());
for (AsyncTaskStatus task : entity) {
if (task.getException() != null) {
model.getFault().setDetail(task.getException().toString());
break;
}
}
}
return model;
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class SPMAsyncTask method stopTask.
@Override
public void stopTask(boolean forceFinish) {
if (getState() != AsyncTaskState.AttemptingEndAction && getState() != AsyncTaskState.Cleared && getState() != AsyncTaskState.ClearFailed && !getLastTaskStatus().getTaskIsInUnusualState()) {
try {
log.info("SPMAsyncTask::StopTask: Attempting to stop task '{}' (Parent Command '{}', Parameters" + " Type '{}').", getVdsmTaskId(), getParameters().getDbAsyncTask().getActionType(), getParameters().getClass().getName());
coco.stopTask(getStoragePoolID(), getVdsmTaskId());
} catch (RuntimeException e) {
log.error("SPMAsyncTask::StopTask: Error during stopping task '{}': {}", getVdsmTaskId(), e.getMessage());
log.debug("Exception", e);
} finally {
if (forceFinish) {
// Force finish flag allows to force the task completion, regardless of the result from call to SPMStopTask
setState(AsyncTaskState.Ended);
setLastTaskStatus(new AsyncTaskStatus(AsyncTaskStatusEnum.finished));
} else {
setState(AsyncTaskState.Polling);
}
}
}
}
Aggregations