@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; } }
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[] {}, new Object[] {}, Collections.singletonList(new GraphicsDevice(VmDeviceType.SPICE))); } }
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); }
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 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 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))); } }
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))); } }
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); }
/** * 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())); } } }
@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); } } }
device = new GraphicsDevice(supportedGraphicsType.getCorrespondingDeviceType()); device.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId())); addManagedVmDevice(device);