private static void setGraphicsToEntity(ResultSet rs, VmDynamic entity) throws SQLException { GraphicsInfo graphicsInfo = new GraphicsInfo(); graphicsInfo.setIp(rs.getString("spice_ip")); graphicsInfo.setPort((Integer) rs.getObject("spice_port")); graphicsInfo.setTlsPort((Integer) rs.getObject("spice_tls_port")); if (graphicsInfo.getPort() != null || graphicsInfo.getTlsPort() != null) { entity.getGraphicsInfos().put(GraphicsType.SPICE, graphicsInfo); } graphicsInfo = new GraphicsInfo(); graphicsInfo.setIp(rs.getString("vnc_ip")); graphicsInfo.setPort((Integer) rs.getObject("vnc_port")); if (graphicsInfo.getPort() != null) { entity.getGraphicsInfos().put(GraphicsType.VNC, graphicsInfo); } }
@Mapping(from = Map.Entry.class, to = GraphicsConsole.class) public static GraphicsConsole map(Map.Entry<org.ovirt.engine.core.common.businessentities.GraphicsType, GraphicsInfo> graphicsInfo, GraphicsConsole template) { GraphicsConsole model = template != null ? template : new GraphicsConsole(); GraphicsType graphicsType = map(graphicsInfo.getKey(), null); if (graphicsType != null) { model.setId(HexUtils.string2hex(graphicsType.value())); model.setProtocol(graphicsType); } if (graphicsInfo.getValue() != null) { model.setPort(graphicsInfo.getValue().getPort()); model.setTlsPort(graphicsInfo.getValue().getTlsPort()); model.setAddress(graphicsInfo.getValue().getIp()); } return model; }
@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()); }
@Override protected org.ovirt.engine.core.common.businessentities.VM getInverse(VmStatic to) { VmStatistics statistics = new VmStatistics(); statistics.setCpuUser(10.0); statistics.setCpuSys(20.0); VmDynamic dynamic = new VmDynamic(); dynamic.setStatus(VMStatus.Up); dynamic.setBootSequence(to.getDefaultBootSequence()); dynamic.getGraphicsInfos().put(GraphicsType.SPICE, new GraphicsInfo()); org.ovirt.engine.core.common.businessentities.VM ret = new org.ovirt.engine.core.common.businessentities.VM(to, dynamic, statistics); ret.setUsageMemPercent(50); return ret; }
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; }
.addValue("guest_cpu_count", vm.getGuestCpuCount()) .addValue("emulated_machine", vm.getEmulatedMachine()) .addValue("spice_port", spice != null ? spice.getPort() : null) .addValue("spice_tls_port", spice != null ? spice.getTlsPort() : null) .addValue("spice_ip", spice != null ? spice.getIp() : null) .addValue("vnc_port", vnc != null ? vnc.getPort() : null) .addValue("vnc_ip", vnc != null ? vnc.getIp() : null) .addValue("guest_timezone_name", vm.getGuestOsTimezoneName()) .addValue("guest_timezone_offset", vm.getGuestOsTimezoneOffset())
model.getDisplay().setAddress(graphicsInfo == null ? null : graphicsInfo.getIp()); Integer displayPort = graphicsInfo == null ? null : graphicsInfo.getPort(); model.getDisplay().setPort(displayPort == null || displayPort.equals(-1) ? null : displayPort); Integer displaySecurePort = graphicsInfo == null ? null : graphicsInfo.getTlsPort(); model.getDisplay().setSecurePort(displaySecurePort==null || displaySecurePort.equals(-1) ? null : displaySecurePort);