use of org.ovirt.engine.core.common.action.RunVmOnceParams in project ovirt-engine by oVirt.
the class BackendVmResource method createRunVmOnceParams.
private RunVmOnceParams createRunVmOnceParams(Vm vm, boolean volatileRun) {
VM entity = getEntity(entityType, QueryType.GetVmByVmId, new IdQueryParameters(guid), id, true);
RunVmOnceParams params = map(vm, map(map(entity, new Vm()), new RunVmOnceParams(guid)));
if (vm.isSetPlacementPolicy()) {
Set<Guid> hostsGuidsSet = parent.validateAndUpdateHostsInPlacementPolicy(vm.getPlacementPolicy());
if (hostsGuidsSet.size() > 0) {
// take the arbitrary first host for run destination
params.setDestinationVdsId(hostsGuidsSet.iterator().next());
}
}
if (vm.isSetInitialization()) {
if (vm.getInitialization().isSetCloudInit()) {
params.setInitializationType(InitializationType.CloudInit);
}
params.setVmInit(InitializationMapper.map(vm.getInitialization(), entity.getVmInit()));
}
params.setVolatileRun(volatileRun);
return params;
}
use of org.ovirt.engine.core.common.action.RunVmOnceParams in project ovirt-engine by oVirt.
the class VmMapper method map.
@Mapping(from = Vm.class, to = RunVmOnceParams.class)
public static RunVmOnceParams map(Vm vm, RunVmOnceParams template) {
RunVmOnceParams params = template != null ? template : new RunVmOnceParams();
if (vm.isSetStateless() && vm.isStateless()) {
params.setRunAsStateless(true);
}
if (vm.isSetDisplay()) {
if (vm.getDisplay().isSetKeyboardLayout()) {
String vncKeyboardLayout = vm.getDisplay().getKeyboardLayout();
params.setVncKeyboardLayout(vncKeyboardLayout);
}
DisplayMapper.fillDisplayInParams(vm, params);
}
if (vm.isSetOs() && vm.getOs().isSetBoot() && vm.getOs().getBoot().isSetDevices() && vm.getOs().getBoot().getDevices().isSetDevices()) {
params.setBootSequence(map(vm.getOs().getBoot(), null));
}
if (vm.isSetCdroms() && vm.getCdroms().isSetCdroms()) {
String file = vm.getCdroms().getCdroms().get(0).getFile().getId();
if (file != null) {
params.setDiskPath(file);
}
}
if (vm.isSetFloppies() && vm.getFloppies().isSetFloppies()) {
String file = vm.getFloppies().getFloppies().get(0).getFile().getId();
if (file != null) {
params.setFloppyPath(file);
}
}
if (vm.isSetCustomProperties()) {
params.setCustomProperties(CustomPropertiesParser.parse(vm.getCustomProperties().getCustomProperties()));
}
if (vm.isSetBios()) {
if (vm.getBios().isSetBootMenu()) {
params.setBootMenuEnabled(vm.getBios().getBootMenu().isEnabled());
}
}
if (vm.isSetOs()) {
if (vm.getOs().isSetBoot() && vm.getOs().getBoot().isSetDevices() && vm.getOs().getBoot().getDevices().isSetDevices()) {
params.setBootSequence(map(vm.getOs().getBoot(), null));
}
if (vm.getOs().isSetKernel()) {
params.setKernelUrl(vm.getOs().getKernel());
}
if (vm.getOs().isSetInitrd()) {
params.setInitrdUrl(vm.getOs().getInitrd());
}
if (vm.getOs().isSetCmdline()) {
params.setKernelParams(vm.getOs().getCmdline());
}
}
if (vm.isSetDomain() && vm.getDomain().isSetName()) {
params.setSysPrepDomainName(vm.getDomain().getName());
if (vm.getDomain().isSetUser()) {
if (vm.getDomain().getUser().isSetUserName()) {
params.setSysPrepUserName(vm.getDomain().getUser().getUserName());
}
if (vm.getDomain().getUser().isSetPassword()) {
params.setSysPrepPassword(vm.getDomain().getUser().getPassword());
}
}
}
if (vm.isSetCustomCpuModel()) {
params.setCustomCpuName(vm.getCustomCpuModel());
}
if (vm.isSetCustomEmulatedMachine()) {
params.setCustomEmulatedMachine(vm.getCustomEmulatedMachine());
}
return params;
}
use of org.ovirt.engine.core.common.action.RunVmOnceParams in project ovirt-engine by oVirt.
the class WebadminRunOnceModel method createRunVmOnceParams.
@Override
protected RunVmOnceParams createRunVmOnceParams() {
RunVmOnceParams params = super.createRunVmOnceParams();
if (getIsAutoAssign().getEntity()) {
params.setDestinationVdsId(null);
} else {
// set destination host if specified
VDS defaultHost = getDefaultHost().getSelectedItem();
params.setDestinationVdsId(defaultHost != null ? defaultHost.getId() : null);
}
return params;
}
use of org.ovirt.engine.core.common.action.RunVmOnceParams in project ovirt-engine by oVirt.
the class RunOnceModel method createRunVmOnceParams.
protected RunVmOnceParams createRunVmOnceParams() {
RunVmOnceParams params = new RunVmOnceParams();
params.setVmId(vm.getId());
params.setBootSequence(getBootSequence().getSequence());
params.setDiskPath(getIsoImagePath());
params.setFloppyPath(getFloppyImagePath());
params.setBootMenuEnabled(getBootMenuEnabled().getEntity());
params.setRunAndPause(getRunAndPause().getEntity());
params.setRunAsStateless(getRunAsStateless().getEntity());
params.setInitializationType(getInitializationType());
params.setCustomProperties(getCustomPropertySheet().serialize());
// kernel params
String selectedKernelImage = getKernelImage().getSelectedItem();
if (StringHelper.isNotNullOrEmpty(selectedKernelImage)) {
params.setKernelUrl(selectedKernelImage);
}
if (getKernelParameters().getEntity() != null) {
params.setKernelParams(getKernelParameters().getEntity());
}
String selectedInitrdImage = getInitrdImage().getSelectedItem();
if (StringHelper.isNotNullOrEmpty(selectedInitrdImage)) {
params.setInitrdUrl(selectedInitrdImage);
}
// Sysprep params
if (getSysPrepUserName().getEntity() != null) {
params.setSysPrepUserName(getSysPrepUserName().getEntity());
}
if (getSysPrepPassword().getEntity() != null) {
params.setSysPrepPassword(getSysPrepPassword().getEntity());
}
if (getIsCloudInitEnabled() != null && getIsCloudInitEnabled().getEntity() || getIsSysprepEnabled() != null && getIsSysprepEnabled().getEntity()) {
params.setVmInit(getVmInitModel().buildCloudInitParameters(this));
}
if (getRunOnceHeadlessModeIsSelected().getEntity()) {
params.getRunOnceGraphics().clear();
params.setRunOnceDisplayType(DisplayType.none);
} else {
params.getRunOnceGraphics().add(Boolean.TRUE.equals(getDisplayConsole_Vnc_IsSelected().getEntity()) ? GraphicsType.VNC : GraphicsType.SPICE);
if (vm.getDefaultDisplayType() == DisplayType.none) {
params.setRunOnceDisplayType(params.getRunOnceGraphics().contains(GraphicsType.SPICE) ? DisplayType.qxl : DisplayType.cirrus);
}
}
params.setVncKeyboardLayout(getVncKeyboardLayout().getSelectedItem());
String selectedDomain = getSysPrepSelectedDomainName().getEntity();
if (!StringHelper.isNullOrEmpty(selectedDomain)) {
params.setSysPrepDomainName(selectedDomain);
}
String selectedEmulatedMachine = getEmulatedMachine().getSelectedItem();
if (!StringHelper.isNullOrEmpty(selectedEmulatedMachine)) {
params.setCustomEmulatedMachine(selectedEmulatedMachine);
}
String selectedCustomCpu = getCustomCpu().getSelectedItem();
if (!StringHelper.isNullOrEmpty(selectedCustomCpu)) {
params.setCustomCpuName(selectedCustomCpu);
}
params.setSpiceFileTransferEnabled(getSpiceFileTransferEnabled().getEntity());
params.setSpiceCopyPasteEnabled(getSpiceCopyPasteEnabled().getEntity());
params.setVolatileRun(getVolatileRun().getEntity());
return params;
}
Aggregations