/** * Set data about graphics from (REST) Template to parameters. * * @param display - display that contains graphics data * @param params - parameters to be updated with graphics data */ public static void setGraphicsToParams(Display display, HasGraphicsDevices params) { if (display != null && display.isSetType()) { DisplayType newDisplayType = display.getType(); if (newDisplayType != null) { for (GraphicsType graphicsType : GraphicsType.values()) { params.getGraphicsDevices().put(graphicsType, null); // reset graphics devices } GraphicsType newGraphicsType = DisplayMapper.map(newDisplayType, null); params.getGraphicsDevices().put(newGraphicsType, new GraphicsDevice(newGraphicsType.getCorrespondingDeviceType())); } } }
/** * For backwards compatibility. Derives graphics type (backend) from display (rest). */ public static void fillDisplayInParams(Vm vm, RunVmOnceParams params) { if (params == null) { return; } if (vm.isSetDisplay() && vm.getDisplay().isSetType()) { DisplayType displayType = vm.getDisplay().getType(); if (displayType != null) { org.ovirt.engine.core.common.businessentities.DisplayType display = mapDisplayType(displayType, null); if (display != null) { Set<GraphicsType> graphics = new HashSet<>(); switch (display) { case qxl: graphics.add(GraphicsType.SPICE); break; case vga: case cirrus: graphics.add(GraphicsType.VNC); break; } params.setRunOnceGraphics(graphics); } } } }
DisplayMapper.fillDisplayInParams(vm, params);
@Mapping(from = org.ovirt.engine.core.common.businessentities.InstanceType.class, to = InstanceType.class) public static InstanceType map(org.ovirt.engine.core.common.businessentities.InstanceType entity, InstanceType incoming) { InstanceType model = incoming != null ? incoming : new InstanceType(); mapCommonEntityToModel(model, (VmTemplate) entity); model.setDisplay(DisplayMapper.map(entity, null)); if (entity.getDefaultBootSequence() != null) { OperatingSystem os = model.getOs(); if (os == null) { os = new OperatingSystem(); } if (entity.getDefaultBootSequence() != null) { Boot boot = VmMapper.map(entity.getDefaultBootSequence(), null); os.setBoot(boot); } model.setOs(os); } return model; }
model.getCpu().setArchitecture(CPUMapper.map(entity.getClusterArch(), null)); model.setDisplay(DisplayMapper.map(entity, null)); model.getDisplay().setDisconnectAction(map(entity.getConsoleDisconnectAction(), null).toString());
org.ovirt.engine.core.common.businessentities.GraphicsType graphicsType = deriveGraphicsType(entity.getGraphicsInfos()); if (graphicsType != null) { model.getDisplay().setType(DisplayMapper.map(graphicsType, null));