Search in sources :

Example 11 with EntityInfo

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());
}
Also used : QuotaVdsDependent(org.ovirt.engine.core.bll.quota.QuotaVdsDependent) StepEnum(org.ovirt.engine.core.common.job.StepEnum) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) LockProperties(org.ovirt.engine.core.common.action.LockProperties) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) CommandCoordinatorUtil(org.ovirt.engine.core.bll.tasks.CommandCoordinatorUtil) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) AttachUserToVmFromPoolAndRunParameters(org.ovirt.engine.core.common.action.AttachUserToVmFromPoolAndRunParameters) PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) Map(java.util.Map) Permission(org.ovirt.engine.core.common.businessentities.Permission) QuotaClusterConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaClusterConsumptionParameter) Instance(javax.enterprise.inject.Instance) Pair(org.ovirt.engine.core.common.utils.Pair) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) EndProcedure(org.ovirt.engine.core.common.action.ActionParametersBase.EndProcedure) ExecutionMessageDirector(org.ovirt.engine.core.dal.job.ExecutionMessageDirector) Scope(org.ovirt.engine.core.common.action.LockProperties.Scope) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Typed(javax.enterprise.inject.Typed) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) CommandStatus(org.ovirt.engine.core.compat.CommandStatus) PermissionDao(org.ovirt.engine.core.dao.PermissionDao) VmDao(org.ovirt.engine.core.dao.VmDao) TransactionScopeOption(org.ovirt.engine.core.compat.TransactionScopeOption) DbUserDao(org.ovirt.engine.core.dao.DbUserDao) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) CommandCallback(org.ovirt.engine.core.bll.tasks.interfaces.CommandCallback) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) Collections(java.util.Collections) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter) Step(org.ovirt.engine.core.common.job.Step) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 12 with EntityInfo

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);
    }
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) SPMColdMergeVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SPMColdMergeVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 13 with EntityInfo

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();
    }
}
Also used : RemoveImageParameters(org.ovirt.engine.core.common.action.RemoveImageParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 14 with EntityInfo

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());
    }
}
Also used : RemoveImageParameters(org.ovirt.engine.core.common.action.RemoveImageParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Guid(org.ovirt.engine.core.compat.Guid)

Example 15 with EntityInfo

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());
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Aggregations

EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)33 Guid (org.ovirt.engine.core.compat.Guid)14 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)6 MoveOrCopyImageGroupParameters (org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters)5 RemoveImageParameters (org.ovirt.engine.core.common.action.RemoveImageParameters)5 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 Test (org.junit.Test)3 RunVmParams (org.ovirt.engine.core.common.action.RunVmParams)3 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)3 ArrayList (java.util.ArrayList)2 Response (javax.ws.rs.core.Response)2 Disk (org.ovirt.engine.api.model.Disk)2 ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)2 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Instance (javax.enterprise.inject.Instance)1 Typed (javax.enterprise.inject.Typed)1