protected Map<GraphicsType, GraphicsInfo> extractGraphicsInofs(VM vm) { return vm.getGraphicsInfos(); }
@Override public boolean canBeSelected() { return getEntity().getGraphicsInfos().containsKey(GraphicsType.VNC); }
public void setVm(VM newVm) { boolean graphicsTypeChanged = false; if (!getVm().getGraphicsInfos().equals(newVm.getGraphicsInfos())) { graphicsTypeChanged = true; } int oldOs = getVm().getOs(); this.vm = newVm; for (ConsoleModel cModel : consoleModels.values()) { // update my console models too cModel.setEntity(newVm); } // if display types changed, we'd like to update the default selected protocol as the old one may be invalid if (graphicsTypeChanged || newVm.getOs() != oldOs) { setDefaultSelectedProtocol(); } } }
private GraphicsType deriveGraphicsType() { org.ovirt.engine.core.common.businessentities.VM vm = getEntity(org.ovirt.engine.core.common.businessentities.VM.class, QueryType.GetVmByVmId, new IdQueryParameters(guid), "GetVmByVmId"); return (vm == null) ? null : VmMapper.deriveGraphicsType(vm.getGraphicsInfos()); }
@Override public boolean canBeSelected() { boolean hasVmSpiceSupport = Boolean.TRUE.equals( AsyncDataProvider.getInstance().hasSpiceSupport( getEntity().getOs(), getEntity().getCompatibilityVersion())); return getEntity().getGraphicsInfos().containsKey(GraphicsType.SPICE) && hasVmSpiceSupport; }
@Test public void testDisplayPort() { org.ovirt.engine.core.common.businessentities.VM entity = new org.ovirt.engine.core.common.businessentities.VM(); entity.setStatus(VMStatus.Up); entity.getGraphicsInfos().put(GraphicsType.SPICE, new GraphicsInfo()); entity.getGraphicsInfos().get(GraphicsType.SPICE) .setPort(5900) .setTlsPort(9999); Vm model = VmMapper.map(entity, (Vm) null); entity.getGraphicsInfos().put(GraphicsType.SPICE, new GraphicsInfo()); entity.getGraphicsInfos().get(GraphicsType.SPICE) .setPort(null) .setTlsPort(null); model = VmMapper.map(entity, (Vm) null); assertNull(model.getDisplay().getPort()); assertNull(model.getDisplay().getSecurePort()); }
private void invokeConsole() { final GraphicsInfo vncInfo = getEntity().getGraphicsInfos().get(GraphicsType.VNC); if (vncInfo == null) { throw new IllegalStateException("Trying to invoke VNC console but VM GraphicsInfo is null."); //$NON-NLS-1$ } vncImpl.getOptions().setVmId(getEntity().getId()); ConfigureConsoleOptionsParams parameters = new ConfigureConsoleOptionsParams(vncImpl.getOptions(), true); parameters.setEngineBaseUrl(FrontendUrlUtils.getRootURL()); parameters.setConsoleClientResourcesUrl(dynamicMessages.consoleClientResourcesUrl()); Frontend.getInstance().runQuery( QueryType.ConfigureConsoleOptions, parameters, new ShowErrorAsyncQuery(returnValue -> { ConsoleOptions configuredOptions = ((QueryReturnValue) returnValue).getReturnValue(); // overriding global server settings by frontend settings configuredOptions.setRemapCtrlAltDelete(vncImpl.getOptions().isRemapCtrlAltDelete()); vncImpl.setOptions(configuredOptions); vncImpl.getOptions().setTitle(getClientTitle()); vncImpl.getOptions().setVmName(getEntity().getName()); vncImpl.invokeClient(); })); }
public void invokeClient() { final GraphicsInfo spiceInfo = getEntity().getGraphicsInfos().get(GraphicsType.SPICE); if (spiceInfo == null) { throw new IllegalStateException("Trying to invoke SPICE console but VM GraphicsInfo is null.");//$NON-NLS-1$
static org.ovirt.engine.core.common.businessentities.VM setUpEntityExpectations( org.ovirt.engine.core.common.businessentities.VM entity, VmStatistics statistics, int index, Guid vmId) { entity.setId(vmId); entity.setClusterId(GUIDS[2]); entity.setName(NAMES[index]); entity.setVmDescription(DESCRIPTIONS[index]); entity.setCpuPerSocket(4); entity.setNumOfSockets(2); entity.setUsageMemPercent(20); entity.getGraphicsInfos().put(GraphicsType.VNC, new GraphicsInfo()); entity.setNumOfMonitors(2); entity.setVmType(VmType.Server); entity.setRunOnVdsName(NAMES[NAMES.length - 1]); entity.setOrigin(index == 0 ? OriginType.HOSTED_ENGINE : OriginType.OVIRT); entity.setBootSequence(null); entity.getStaticData().setSmallIconId(GUIDS[2]); entity.getStaticData().setLargeIconId(GUIDS[3]); setUpStatisticalEntityExpectations(entity, statistics); return entity; }
org.ovirt.engine.core.common.businessentities.GraphicsType graphicsType = deriveGraphicsType(entity.getGraphicsInfos()); if (graphicsType != null) { model.getDisplay().setType(DisplayMapper.map(graphicsType, null)); GraphicsInfo graphicsInfo = entity.getGraphicsInfos().get(graphicsType); model.getDisplay().setAddress(graphicsInfo == null ? null : graphicsInfo.getIp()); Integer displayPort = graphicsInfo == null ? null : graphicsInfo.getPort();
vm.getGraphicsInfos().putAll(instance.getGraphicsInfos()); vm.getDynamicData().setVncKeyboardLayout(instance.getDynamicData().getVncKeyboardLayout()); vm.setElapsedTime(instance.getElapsedTime());