Skip to content

Commit

Permalink
Allow setting all DisplayType's via API
Browse files Browse the repository at this point in the history
After updating the api model, we can accept all the known DisplayType's
via the API.

Signed-off-by: Jean-Louis Dupond <[email protected]>
  • Loading branch information
dupondje committed May 31, 2023
1 parent 1511d64 commit fd55595
Showing 1 changed file with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public static DisplayType map(GraphicsType graphicsType, DisplayType displayType
public static GraphicsType map(DisplayType displayType, GraphicsType graphicsType) {
switch (displayType) {
case SPICE:
case QXL:
return GraphicsType.SPICE;
case VNC:
case CIRRUS:
case VGA:
case BOCHS:
return GraphicsType.VNC;
default:
return null;
Expand Down Expand Up @@ -74,34 +78,21 @@ public static void fillDisplayInParams(Vm vm, RunVmOnceParams params) {
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:
case bochs:
graphics.add(GraphicsType.VNC);
break;
}
params.setRunOnceGraphics(graphics);
Set<GraphicsType> graphics = new HashSet<>();
switch (displayType) {
case SPICE:
case QXL:
graphics.add(GraphicsType.SPICE);
break;
case VNC:
case VGA:
case CIRRUS:
case BOCHS:
graphics.add(GraphicsType.VNC);
break;
}
params.setRunOnceGraphics(graphics);
}
}
}

@Mapping(from = DisplayType.class, to = org.ovirt.engine.core.common.businessentities.DisplayType.class)
public static org.ovirt.engine.core.common.businessentities.DisplayType mapDisplayType(DisplayType type, org.ovirt.engine.core.common.businessentities.DisplayType incoming) {
switch (type) {
case VNC:
return org.ovirt.engine.core.common.businessentities.DisplayType.vga;
case SPICE:
return org.ovirt.engine.core.common.businessentities.DisplayType.qxl;
default:
return null;
}
}
}

0 comments on commit fd55595

Please sign in to comment.