public static GraphicsType fromVmDeviceType(VmDeviceType type) { for (GraphicsType graphicsType : GraphicsType.values()) { if (graphicsType.getCorrespondingDeviceType() == type) { return graphicsType; } } return null; } }
public GraphicsType getGraphicsType() { return GraphicsType.fromString(getDevice()); }
public static Response remove(BackendResource resource, Guid guid, String consoleId) { List<GraphicsDevice> devices = DisplayHelper.getGraphicsDevicesForEntity(resource, guid, false); if (devices == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } org.ovirt.engine.core.common.businessentities.GraphicsType graphicsType = asGraphicsType(consoleId); return devices.stream() .filter(device -> device.getGraphicsType().equals(graphicsType)) .findFirst() .map(device -> resource.performAction(ActionType.RemoveGraphicsAndVideoDevices, new GraphicsParameters(device))) .orElseThrow(() -> new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build())); }
public GraphicsDevice(VmDevice vmDev) { this(GraphicsType.fromString(vmDev.getDevice()).getCorrespondingDeviceType()); setId(vmDev.getId()); setSpecParams(vmDev.getSpecParams()); }
device = new GraphicsDevice(supportedGraphicsType.getCorrespondingDeviceType()); device.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId())); addManagedVmDevice(device);
protected void initDisplayTypes(DisplayType selected, UnitVmModel.GraphicsTypes selectedGrahicsTypes) { getModel().getDisplayType().getSelectedItemChangedEvent().addListener((ev, sender, args) -> enableSinglePCI(getModel().getDisplayType().getSelectedItem() == DisplayType.qxl)); List<Pair<GraphicsType, DisplayType>> allGraphicsAndDisplays = new ArrayList<>(); for (GraphicsType graphicsType : GraphicsType.values()) { for (DisplayType displayType : DisplayType.values()) { if (displayType != DisplayType.none) { allGraphicsAndDisplays.add(new Pair<>(graphicsType, displayType)); } } } getModel().initDisplayModels(allGraphicsAndDisplays); initGraphicsModel(selectedGrahicsTypes); if (getModel().getDisplayType().getItems().contains(selected)) { getModel().getDisplayType().setSelectedItem(selected); } if (selected == DisplayType.none) { getModel().getDisplayType().setSelectedItem(DisplayType.qxl); getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.SPICE); getModel().getIsHeadlessModeEnabled().setEntity(true); } }
/** * 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())); } } }
private List<Pair<GraphicsType, DisplayType>> parseDisplayProtocols(int osId, Version version) { List<Pair<GraphicsType, DisplayType>> graphicsAndDisplays = new ArrayList<>(); String displayAndGraphicsLine = getValueByVersion(idToUnameLookup.get(osId), "devices.display.protocols", version); // todo - use different key? for (String displayAndGraphics : displayAndGraphicsLine.split(",")) { Pair<String, String> pair = parseSlashSeparatedPair(displayAndGraphics); if (pair != null) { GraphicsType graphics = GraphicsType.fromString(pair.getFirst()); DisplayType display = DisplayType.valueOf(pair.getSecond()); graphicsAndDisplays.add(new Pair<>(graphics, display)); } } return graphicsAndDisplays; }
@Override protected void build(UnitVmModel source, HasGraphicsDevices destination) { if (source.getDisplayType().getSelectedItem() == null || source.getGraphicsType().getSelectedItem() == null) { return; } for (GraphicsType graphicsType : GraphicsType.values()) { destination.getGraphicsDevices().put(graphicsType, null); // reset // if not headless VM then set the selected graphic devices if (!source.getIsHeadlessModeEnabled().getEntity() && source.getGraphicsType().getSelectedItem().getBackingGraphicsTypes().contains(graphicsType)) { GraphicsDevice d = new GraphicsDevice(graphicsType.getCorrespondingDeviceType()); destination.getGraphicsDevices().put(d.getGraphicsType(), d); } } }
protected void updateGraphics(Guid id) { Frontend.getInstance().runQuery(QueryType.GetGraphicsDevices, new IdQueryParameters(id), new AsyncQuery<QueryReturnValue>(returnValue -> { List<VmDevice> graphicsVmDevs = returnValue.getReturnValue(); List<GraphicsType> graphicsTypes = new ArrayList<>(); for (VmDevice graphicsVmDev : graphicsVmDevs) { graphicsTypes.add(GraphicsType.fromString(graphicsVmDev.getDevice())); } boolean hasSpiceAndVnc = graphicsTypes.size() == 2 && graphicsTypes.containsAll(Arrays.asList(GraphicsType.SPICE, GraphicsType.VNC)); boolean canBeSelected = getModel().getGraphicsType().getItems().contains(UnitVmModel.GraphicsTypes.SPICE_AND_VNC); if (hasSpiceAndVnc && canBeSelected) { getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.SPICE_AND_VNC); } else if (graphicsVmDevs.size() == 1) { GraphicsType type = GraphicsType.fromString(graphicsVmDevs.get(0).getDevice()); getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.fromGraphicsType(type)); } })); }
private void postDoUpdateManagedFieldsFrom(VmBase vmBase) { if (isNextRunConfigurationExists()) { deactivate(); getModel().getIsSoundcardEnabled().setEntity( VmDeviceCommonUtils.isVmDeviceExists(vmBase.getManagedDeviceMap(), VmDeviceGeneralType.SOUND)); getModel().getIsConsoleDeviceEnabled().setEntity( VmDeviceCommonUtils.isVmDeviceExists(vmBase.getManagedDeviceMap(), VmDeviceType.CONSOLE)); Set<GraphicsType> graphicsTypeSet = new HashSet<>(); for (GraphicsType graphicsType : GraphicsType.values()) { if (VmDeviceCommonUtils.isVmDeviceExists(vmBase.getManagedDeviceMap(), graphicsType.getCorrespondingDeviceType())) { graphicsTypeSet.add(graphicsType); } } getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsTypeSet)); activate(); } updateWatchdog(vmBase, true); }