public static List<GraphicsType> getGraphicsTypesForEntity(BackendResource backendResource, Guid id, Map<Guid, List<GraphicsDevice>> cache, boolean nextRun) { List<GraphicsType> graphicsTypes = new ArrayList<>(); List<GraphicsDevice> graphicsDevices; if (cache == null) { graphicsDevices = getGraphicsDevicesForEntity(backendResource, id, nextRun); } else { graphicsDevices = cache.get(id); } if (graphicsDevices != null) { for (GraphicsDevice graphicsDevice : graphicsDevices) { graphicsTypes.add(graphicsDevice.getGraphicsType()); } } return graphicsTypes; }
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())); }
private void updateDisplayProtocols() { Frontend.getInstance().runQuery(QueryType.GetGraphicsDevices, new IdQueryParameters(vm.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> { boolean selectVnc = false; List<GraphicsDevice> graphicsDevices = returnValue.getReturnValue(); if (graphicsDevices.size() == 1 && graphicsDevices.get(0).getGraphicsType() == GraphicsType.VNC) { selectVnc = true; } getDisplayConsole_Vnc_IsSelected().setEntity(selectVnc); getDisplayConsole_Spice_IsSelected().setEntity(!selectVnc); })); }
protected void updateProperties(Guid entityId) { if (entityId == null) { return; } Frontend.getInstance().runQuery(QueryType.GetGraphicsDevices, new IdQueryParameters(entityId).withoutRefresh(), new AsyncQuery<QueryReturnValue>(returnValue -> { List<GraphicsDevice> graphicsDevices = returnValue.getReturnValue(); Set<GraphicsType> graphicsTypesCollection = new HashSet<>(); for (GraphicsDevice graphicsDevice : graphicsDevices) { graphicsTypesCollection.add(graphicsDevice.getGraphicsType()); } UnitVmModel.GraphicsTypes graphicsTypes = UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsTypesCollection); Translator translator = EnumTranslator.getInstance(); setGraphicsType(translator.translate(graphicsTypes)); } )); }
@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); } } }
graphicsTypes.add(graphicsDevice.getGraphicsType());
graphicsTypesCollection.add(graphicsDevice.getGraphicsType());