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