use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class AttachUserToVmFromPoolAndRunCommand method init.
@Override
protected void init() {
super.init();
if (Guid.Empty.equals(getParameters().getVmId()) && getVmPool() != null) {
boolean vmPrestarted = true;
Guid vmToAttach = vmPoolHandler.selectPrestartedVm(getVmPoolId(), getVmPool().isStateful(), (vmId, errors) -> getReturnValue().getValidationMessages().addAll(errors));
if (Guid.Empty.equals(vmToAttach)) {
vmPrestarted = false;
vmToAttach = vmPoolHandler.selectNonPrestartedVm(getVmPoolId(), (vmId, errors) -> getReturnValue().getValidationMessages().addAll(errors));
}
getParameters().setVmId(vmToAttach);
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VM, vmToAttach));
getParameters().setVmPrestarted(vmPrestarted);
getParameters().setNonPrestartedVmLocked(!vmPrestarted);
}
setVmId(getParameters().getVmId());
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class MergeSPMBaseCommand method executeSPMMergeCommand.
protected void executeSPMMergeCommand(VDSCommandType vdsCommandType) {
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getSubchainInfo().getImageGroupId()));
SPMColdMergeVDSCommandParameters parameters = new SPMColdMergeVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getSubchainInfo());
VDSReturnValue vdsReturnValue = runVdsCommand(vdsCommandType, parameters);
if (vdsReturnValue.getSucceeded()) {
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
getTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId()));
setSucceeded(true);
}
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class MoveImageGroupCommand method removeImage.
private void removeImage(Guid storageDomainId) {
RemoveImageParameters removeImageParams = new RemoveImageParameters(getParameters().getImageId());
removeImageParams.setStorageDomainId(storageDomainId);
removeImageParams.setParentCommand(ActionType.RemoveImage);
removeImageParams.setDbOperationScope(ImageDbOperationScope.NONE);
removeImageParams.setShouldLockImage(false);
removeImageParams.setCorrelationId(getParameters().getCorrelationId());
// TODO: should be removed as async task manager issues would be resolved, done in order
// to avoid operations on the image to wait for this remove operation as currently async
// task manager calls the end methods of command based on the entity id.
// the remove done here is a "clenaup", either on the source domain or on the target - so
// other operations on the image shouldn't be dependent and wait for it.
removeImageParams.setEntityInfo(new EntityInfo(VdcObjectType.Disk, Guid.newGuid()));
ActionReturnValue returnValue = runInternalAction(ActionType.RemoveImage, removeImageParams, cloneContextAndDetachFromParent());
if (returnValue.getSucceeded()) {
startPollingAsyncTasks(returnValue.getInternalVdsmTaskIdList());
} else {
addAuditLogOnRemoveFailure();
}
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class CreateImageTemplateCommand method revertTasks.
@Override
protected void revertTasks() {
Guid destImageId = getDestinationDiskImage().getImageId();
RemoveImageParameters p = new RemoveImageParameters(destImageId);
p.setEntityInfo(new EntityInfo(VdcObjectType.Disk, destImageId));
p.setParentParameters(p);
p.setParentCommand(ActionType.RemoveImage);
ActionReturnValue returnValue = checkAndPerformRollbackUsingCommand(ActionType.RemoveImage, p, null);
if (returnValue.getSucceeded()) {
startPollingAsyncTasks(returnValue.getInternalVdsmTaskIdList());
}
}
use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.
the class BackendVmDiskResourceTest method testRemove.
@Test
public void testRemove() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(1);
UriInfo uriInfo = setUpActionExpectations(ActionType.DetachDiskFromVm, AttachDetachVmDiskParameters.class, new String[] { "VmId", "EntityInfo" }, new Object[] { VM_ID, new EntityInfo(VdcObjectType.Disk, DISK_ID) }, true, true, false);
setUriInfo(uriInfo);
verifyRemove(resource.remove());
}
Aggregations