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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations