Search in sources :

Example 1 with DisplayType

use of org.ovirt.engine.api.model.DisplayType in project ovirt-engine by oVirt.

the class DisplayHelper method setGraphicsToParams.

/**
 * 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()) {
                // reset graphics devices
                params.getGraphicsDevices().put(graphicsType, null);
            }
            GraphicsType newGraphicsType = DisplayMapper.map(newDisplayType, null);
            params.getGraphicsDevices().put(newGraphicsType, new GraphicsDevice(newGraphicsType.getCorrespondingDeviceType()));
        }
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) DisplayType(org.ovirt.engine.api.model.DisplayType)

Example 2 with DisplayType

use of org.ovirt.engine.api.model.DisplayType in project ovirt-engine by oVirt.

the class DisplayMapper method fillDisplayInParams.

/**
 * For backwards compatibility. Derives graphics type (backend) from display (rest).
 */
public static void fillDisplayInParams(Vm vm, RunVmOnceParams params) {
    if (params == null) {
        return;
    }
    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:
                        graphics.add(GraphicsType.VNC);
                        break;
                }
                params.setRunOnceGraphics(graphics);
            }
        }
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) DisplayType(org.ovirt.engine.api.model.DisplayType) HashSet(java.util.HashSet)

Example 3 with DisplayType

use of org.ovirt.engine.api.model.DisplayType in project ovirt-engine by oVirt.

the class BackendVmResourceTest method testStartWithModifiedGraphics.

private void testStartWithModifiedGraphics(GraphicsType graphicsType) throws Exception {
    setUpWindowsGetEntityExpectations(1, false);
    setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId", "RunOnceGraphics" }, new Object[] { GUIDS[0], Collections.singleton(graphicsType) }));
    Action action = new Action();
    action.setVm(new Vm());
    action.getVm().setDisplay(new Display());
    DisplayType display = (graphicsType == GraphicsType.VNC) ? DisplayType.VNC : DisplayType.SPICE;
    action.getVm().getDisplay().setType(display);
    verifyActionResponse(resource.start(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) RunVmOnceParams(org.ovirt.engine.core.common.action.RunVmOnceParams) DisplayType(org.ovirt.engine.api.model.DisplayType) Vm(org.ovirt.engine.api.model.Vm) Display(org.ovirt.engine.api.model.Display)

Aggregations

DisplayType (org.ovirt.engine.api.model.DisplayType)3 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)2 HashSet (java.util.HashSet)1 Action (org.ovirt.engine.api.model.Action)1 Display (org.ovirt.engine.api.model.Display)1 Vm (org.ovirt.engine.api.model.Vm)1 RunVmOnceParams (org.ovirt.engine.core.common.action.RunVmOnceParams)1 GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)1