Search in sources :

Example 1 with RunVmParams

use of org.ovirt.engine.core.common.action.RunVmParams in project ovirt-engine by oVirt.

the class VmListModel method run.

private void run() {
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VM a = (VM) item;
        list.add(new RunVmParams(a.getId()));
    }
    Frontend.getInstance().runMultipleAction(ActionType.RunVm, list, result -> {
    }, null);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 2 with RunVmParams

use of org.ovirt.engine.core.common.action.RunVmParams 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)

Example 3 with RunVmParams

use of org.ovirt.engine.core.common.action.RunVmParams in project ovirt-engine by oVirt.

the class VdsEventListener method buildRunVmParameters.

private RunVmParams buildRunVmParameters(Guid vmId) {
    RunVmParams parameters = new RunVmParams(vmId);
    parameters.setRunInUnknownStatus(true);
    return parameters;
}
Also used : RunVmParams(org.ovirt.engine.core.common.action.RunVmParams)

Example 4 with RunVmParams

use of org.ovirt.engine.core.common.action.RunVmParams in project ovirt-engine by oVirt.

the class VmPoolMonitor method runVmFromPool.

/**
 * Run the given VM as stateless.
 */
private boolean runVmFromPool(VmStatic vmToRun, boolean runAsStateless, String poolName) {
    log.info("Running VM '{}' as {}", vmToRun.getName(), runAsStateless ? "stateless" : "stateful");
    RunVmParams runVmParams = new RunVmParams(vmToRun.getId());
    runVmParams.setEntityInfo(new EntityInfo(VdcObjectType.VM, vmToRun.getId()));
    runVmParams.setRunAsStateless(runAsStateless);
    ActionReturnValue actionReturnValueurnValue = Backend.getInstance().runInternalAction(ActionType.RunVm, runVmParams, ExecutionHandler.createInternalJobContext().withLock(vmPoolHandler.createLock(vmToRun.getId())));
    boolean prestartingVmSucceeded = actionReturnValueurnValue.getSucceeded();
    if (!prestartingVmSucceeded) {
        AuditLogable log = new AuditLogableImpl();
        log.addCustomValue("VmPoolName", poolName);
        Injector.get(AuditLogDirector.class).log(log, AuditLogType.VM_FAILED_TO_PRESTART_IN_POOL);
    }
    log.info("Running VM '{}' as {} {}", vmToRun.getName(), runAsStateless ? "stateless" : "stateful", prestartingVmSucceeded ? "succeeded" : "failed");
    return prestartingVmSucceeded;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)

Example 5 with RunVmParams

use of org.ovirt.engine.core.common.action.RunVmParams in project ovirt-engine by oVirt.

the class BackendVmResource method start.

@Override
public Response start(Action action) {
    RunVmParams params;
    ActionType actionType;
    if (action.isSetVm()) {
        Vm vm = action.getVm();
        actionType = ActionType.RunVmOnce;
        params = createRunVmOnceParams(vm, action.isSetVolatile() && action.isVolatile());
    } else {
        actionType = ActionType.RunVm;
        params = new RunVmParams(guid);
    }
    if (action.isSetPause() && action.isPause()) {
        params.setRunAndPause(true);
    }
    boolean useSysprep = action.isSetUseSysprep() && action.isUseSysprep();
    boolean useCloudInit = action.isSetUseCloudInit() && action.isUseCloudInit();
    if (useSysprep && useCloudInit) {
        Fault fault = new Fault();
        fault.setReason(localize(Messages.CANT_USE_SYSPREP_AND_CLOUD_INIT_SIMULTANEOUSLY));
        return Response.status(Response.Status.CONFLICT).entity(fault).build();
    }
    if (useSysprep) {
        params.setInitializationType(InitializationType.Sysprep);
    } else if (useCloudInit) {
        params.setInitializationType(InitializationType.CloudInit);
    } else {
        params.setInitializationType(InitializationType.None);
    }
    return doAction(actionType, params, action);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) Vm(org.ovirt.engine.api.model.Vm) Fault(org.ovirt.engine.api.model.Fault) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams)

Aggregations

RunVmParams (org.ovirt.engine.core.common.action.RunVmParams)6 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 ArrayList (java.util.ArrayList)1 Fault (org.ovirt.engine.api.model.Fault)1 Vm (org.ovirt.engine.api.model.Vm)1 ExecutionContext (org.ovirt.engine.core.bll.job.ExecutionContext)1 RunVmValidator (org.ovirt.engine.core.bll.validator.RunVmValidator)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)1