Search in sources :

Example 1 with GraphicsParameters

use of org.ovirt.engine.core.common.action.GraphicsParameters in project ovirt-engine by oVirt.

the class AddVmCommand method addGraphicsDevice.

private void addGraphicsDevice() {
    for (GraphicsDevice graphicsDevice : getParameters().getGraphicsDevices().values()) {
        if (graphicsDevice == null) {
            continue;
        }
        graphicsDevice.setVmId(getVmId());
        backend.runInternalAction(ActionType.AddGraphicsDevice, new GraphicsParameters(graphicsDevice));
    }
}
Also used : GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters)

Example 2 with GraphicsParameters

use of org.ovirt.engine.core.common.action.GraphicsParameters in project ovirt-engine by oVirt.

the class AddVmTemplateCommand method addGraphicsDevice.

/**
 * Add graphics based on parameters.
 */
private void addGraphicsDevice() {
    for (GraphicsDevice graphicsDevice : getParameters().getGraphicsDevices().values()) {
        if (graphicsDevice == null) {
            continue;
        }
        graphicsDevice.setVmId(getVmTemplateId());
        GraphicsParameters parameters = new GraphicsParameters(graphicsDevice).setVm(false);
        backend.runInternalAction(ActionType.AddGraphicsDevice, parameters);
    }
}
Also used : GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters)

Example 3 with GraphicsParameters

use of org.ovirt.engine.core.common.action.GraphicsParameters in project ovirt-engine by oVirt.

the class UpdateVmCommand method addOrUpdateGraphicsDevice.

private void addOrUpdateGraphicsDevice(GraphicsDevice device) {
    GraphicsDevice existingGraphicsDevice = getGraphicsDevOfType(device.getGraphicsType());
    device.setVmId(getVmId());
    backend.runInternalAction(existingGraphicsDevice == null ? ActionType.AddGraphicsDevice : ActionType.UpdateGraphicsDevice, new GraphicsParameters(device));
}
Also used : GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters)

Example 4 with GraphicsParameters

use of org.ovirt.engine.core.common.action.GraphicsParameters in project ovirt-engine by oVirt.

the class UpdateVmTemplateCommand method updateGraphicsDevice.

private void updateGraphicsDevice() {
    for (GraphicsType type : getParameters().getGraphicsDevices().keySet()) {
        GraphicsDevice vmGraphicsDevice = getGraphicsDevOfType(type);
        if (vmGraphicsDevice == null) {
            if (getParameters().getGraphicsDevices().get(type) != null) {
                getParameters().getGraphicsDevices().get(type).setVmId(getVmTemplateId());
                GraphicsParameters parameters = new GraphicsParameters(getParameters().getGraphicsDevices().get(type));
                parameters.setVm(false);
                backend.runInternalAction(ActionType.AddGraphicsDevice, parameters);
            }
        } else {
            if (getParameters().getGraphicsDevices().get(type) == null) {
                GraphicsParameters parameters = new GraphicsParameters(vmGraphicsDevice);
                parameters.setVm(false);
                backend.runInternalAction(ActionType.RemoveGraphicsDevice, parameters);
            } else {
                getParameters().getGraphicsDevices().get(type).setVmId(getVmTemplateId());
                GraphicsParameters parameters = new GraphicsParameters(getParameters().getGraphicsDevices().get(type));
                parameters.setVm(false);
                backend.runInternalAction(ActionType.UpdateGraphicsDevice, parameters);
            }
        }
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters)

Example 5 with GraphicsParameters

use of org.ovirt.engine.core.common.action.GraphicsParameters in project ovirt-engine by oVirt.

the class BackendGraphicsConsoleHelper method remove.

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()));
}
Also used : SetVmTicketParameters(org.ovirt.engine.core.common.action.SetVmTicketParameters) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) EnumMap(java.util.EnumMap) Guid(org.ovirt.engine.core.compat.Guid) GraphicsConsole(org.ovirt.engine.api.model.GraphicsConsole) DisplayHelper(org.ovirt.engine.api.restapi.util.DisplayHelper) Ticketing.generateOTP(org.ovirt.engine.core.utils.Ticketing.generateOTP) Supplier(java.util.function.Supplier) Ticket(org.ovirt.engine.api.model.Ticket) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters) CreationStatus(org.ovirt.engine.api.model.CreationStatus) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) VmMapper(org.ovirt.engine.api.restapi.types.VmMapper) GraphicsType(org.ovirt.engine.api.model.GraphicsType) ActionType(org.ovirt.engine.core.common.action.ActionType) List(java.util.List) GraphicsConsoles(org.ovirt.engine.api.model.GraphicsConsoles) Response(javax.ws.rs.core.Response) Map(java.util.Map) WebApplicationException(javax.ws.rs.WebApplicationException) URI(java.net.URI) HexUtils(org.ovirt.engine.api.restapi.utils.HexUtils) Action(org.ovirt.engine.api.model.Action) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) WebApplicationException(javax.ws.rs.WebApplicationException) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters)

Aggregations

GraphicsParameters (org.ovirt.engine.core.common.action.GraphicsParameters)5 GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)5 URI (java.net.URI)1 EnumMap (java.util.EnumMap)1 List (java.util.List)1 Map (java.util.Map)1 Supplier (java.util.function.Supplier)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Response (javax.ws.rs.core.Response)1 Action (org.ovirt.engine.api.model.Action)1 CreationStatus (org.ovirt.engine.api.model.CreationStatus)1 GraphicsConsole (org.ovirt.engine.api.model.GraphicsConsole)1 GraphicsConsoles (org.ovirt.engine.api.model.GraphicsConsoles)1 GraphicsType (org.ovirt.engine.api.model.GraphicsType)1 Ticket (org.ovirt.engine.api.model.Ticket)1 VmMapper (org.ovirt.engine.api.restapi.types.VmMapper)1 DisplayHelper (org.ovirt.engine.api.restapi.util.DisplayHelper)1 HexUtils (org.ovirt.engine.api.restapi.utils.HexUtils)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 SetVmTicketParameters (org.ovirt.engine.core.common.action.SetVmTicketParameters)1