Search in sources :

Example 6 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class UpdateVmVersionCommand method init.

@Override
protected void init() {
    super.init();
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VM, getParameters().getVmId()));
    if (getVm() != null) {
        if (getParameters().getNewTemplateVersion() != null) {
            setVmTemplate(vmTemplateDao.get(getParameters().getNewTemplateVersion()));
        } else {
            setVmTemplate(vmTemplateDao.getTemplateWithLatestVersionInChain(getVm().getVmtGuid()));
        }
    }
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 7 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class CreateSnapshotForVmCommand method init.

@Override
public void init() {
    getParameters().setUseCinderCommandCallback(isCinderDisksExist());
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId()));
    setSnapshotName(getParameters().getDescription());
    setStoragePoolId(getVm() != null ? getVm().getStoragePoolId() : null);
}
Also used : EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 8 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class RemoveSnapshotCommand method executeCommand.

@Override
protected void executeCommand() {
    if (!getVm().isDown() && !getVm().isQualifiedForSnapshotMerge()) {
        log.error("Cannot remove VM snapshot. Vm is not Down, Up or Paused");
        throw new EngineException(EngineError.VM_NOT_QUALIFIED_FOR_SNAPSHOT_MERGE);
    }
    final Snapshot snapshot = snapshotDao.get(getParameters().getSnapshotId());
    boolean snapshotHasImages = hasImages();
    boolean removeSnapshotMemory = isMemoryVolumeRemoveable(snapshot);
    // No need for locking, VDSM tasks, and all that jazz.
    if (!snapshotHasImages && !removeSnapshotMemory) {
        snapshotDao.remove(getParameters().getSnapshotId());
        setSucceeded(true);
        return;
    }
    lockSnapshot(snapshot);
    if (getParameters().isFreeLockNeeded()) {
        freeLock();
    }
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId()));
    boolean useTaskManagerToRemoveMemory = false;
    if (snapshotHasImages) {
        removeImages();
        if (getSnapshotActionType() == ActionType.RemoveSnapshotSingleDiskLive) {
            persistCommand(getParameters().getParentCommand(), true);
            useTaskManagerToRemoveMemory = true;
        }
    }
    if (removeSnapshotMemory) {
        removeMemory(snapshot, useTaskManagerToRemoveMemory);
        if (!snapshotHasImages) {
            // no async tasks - ending command manually
            endVmCommand();
        }
    }
    setSucceeded(true);
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 9 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class AddVmAndCloneImageCommand method createCopyParameters.

protected MoveOrCopyImageGroupParameters createCopyParameters(DiskImage diskImage, Guid srcStorageDomainId, Guid srcImageGroupId, Guid srcImageId, ActionType parentCommandType) {
    MoveOrCopyImageGroupParameters params = new MoveOrCopyImageGroupParameters(getVmId(), srcImageGroupId, srcImageId, diskImage.getId(), diskImage.getImageId(), diskImage.getStorageIds().get(0), ImageOperation.Copy);
    params.setAddImageDomainMapping(false);
    params.setCopyVolumeType(CopyVolumeType.LeafVol);
    params.setVolumeFormat(diskImage.getVolumeFormat());
    params.setVolumeType(diskImage.getVolumeType());
    params.setUseCopyCollapse(true);
    params.setSourceDomainId(srcStorageDomainId);
    params.setWipeAfterDelete(diskImage.isWipeAfterDelete());
    params.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId()));
    params.setParentParameters(getParameters());
    params.setParentCommand(parentCommandType);
    return params;
}
Also used : MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo)

Example 10 with EntityInfo

use of org.ovirt.engine.core.common.asynctasks.EntityInfo in project ovirt-engine by oVirt.

the class AttachUserToVmFromPoolAndRunCommand method runVm.

private ActionReturnValue runVm() {
    RunVmParams runVmParams = new RunVmParams(getVmId());
    runVmParams.setSessionId(getParameters().getSessionId());
    runVmParams.setEntityInfo(new EntityInfo(VdcObjectType.VM, getVmId()));
    runVmParams.setParentCommand(getActionType());
    runVmParams.setParentParameters(getParameters());
    runVmParams.setEndProcedure(EndProcedure.COMMAND_MANAGED);
    runVmParams.setRunAsStateless(!getVmPool().isStateful());
    ExecutionContext runVmContext = createRunVmContext();
    ActionReturnValue actionReturnValue = runInternalAction(ActionType.RunVm, runVmParams, cloneContext().withExecutionContext(runVmContext).withCompensationContext(null));
    getTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
    return actionReturnValue;
}
Also used : ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams)

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