@Mapping(from = GraphicsConsole.class, to = GraphicsDevice.class) public static GraphicsDevice map(GraphicsConsole graphicsConsole, GraphicsDevice template) { if (template != null) { return template; } switch (graphicsConsole.getProtocol()) { case SPICE: return new GraphicsDevice(VmDeviceType.SPICE); case VNC: return new GraphicsDevice(VmDeviceType.VNC); default: return template; } }
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 GraphicsType getGraphicsType() { return GraphicsType.fromString(getDevice()); }
public GraphicsDevice(VmDeviceType type) { setType(VmDeviceGeneralType.GRAPHICS); setDevice(type.name().toLowerCase()); setId(new VmDeviceId()); setAddress(""); setPlugged(true); setManaged(true); }
public static void addGraphicsDevice(VmBase vmBase, VmDeviceType vmDeviceType) { GraphicsDevice graphicsDevice = new GraphicsDevice(vmDeviceType); graphicsDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId())); vmBase.getManagedDeviceMap().put(graphicsDevice.getDeviceId(), graphicsDevice); }
@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 setUpGetGraphicsExpectations(int times) { for (int i = 0; i < times; i++) { setUpGetEntityExpectations(QueryType.GetGraphicsDevices, IdQueryParameters.class, new String[] {}, new Object[] {}, Collections.singletonList(new GraphicsDevice(VmDeviceType.SPICE))); } }
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())); }
protected void setUpGetGraphicsMultipleExpectations(int times) { Map<Guid, List<GraphicsDevice>> vmDevices = new HashMap<>(); for (int i = 0; i < times; i++) { vmDevices.put(GUIDS[i], Collections.singletonList(new GraphicsDevice(VmDeviceType.SPICE))); } setUpGetEntityExpectations(QueryType.GetGraphicsDevicesMultiple, QueryParametersBase.class, new String[]{}, new Object[]{}, vmDevices); }
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 setUpGetGraphicsExpectations(int times) { for (int i = 0; i < times; i++) { setUpGetEntityExpectations(QueryType.GetGraphicsDevices, IdQueryParameters.class, new String[] {}, new Object[] {}, Collections.singletonList(new GraphicsDevice(VmDeviceType.SPICE))); } }
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)); } )); }
protected void setUpGetGraphicsExpectations(int times) { for (int i = 0; i < times; i++) { setUpGetEntityExpectations(QueryType.GetGraphicsDevices, IdQueryParameters.class, new String[] {}, new Object[] {}, Collections.singletonList(new GraphicsDevice(VmDeviceType.SPICE))); } }
graphicsTypes.add(graphicsDevice.getGraphicsType());
protected void setUpGetNextRunGraphicsExpectations(int times) { for (int i = 0; i < times; i++) { setUpGetEntityExpectations(QueryType.GetNextRunGraphicsDevices, IdQueryParameters.class, new String[] {}, new Object[] {}, Collections.singletonList(new GraphicsDevice(VmDeviceType.SPICE))); } }
graphicsTypesCollection.add(graphicsDevice.getGraphicsType());
protected void setUpGetGraphicsExpectations(int times) { for (int i = 0; i < times; i++) { setUpGetEntityExpectations(QueryType.GetGraphicsDevices, IdQueryParameters.class, new String[]{"Id"}, new Object[]{GUIDS[i]}, Collections.singletonList(new GraphicsDevice(VmDeviceType.SPICE))); } }
protected void setUpGetGraphicsExpectations(int times) { for (int i = 0; i < times; i++) { setUpGetEntityExpectations(QueryType.GetGraphicsDevices, IdQueryParameters.class, new String[]{"Id"}, new Object[]{GUIDS[i]}, Collections.singletonList(new GraphicsDevice(VmDeviceType.SPICE))); } }
/** * 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())); } } }
device = new GraphicsDevice(supportedGraphicsType.getCorrespondingDeviceType()); device.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId())); addManagedVmDevice(device);