Search in sources :

Example 6 with GraphicsDevice

use of org.ovirt.engine.core.common.businessentities.GraphicsDevice 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 7 with GraphicsDevice

use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.

the class ProcessDownVmCommand method createUpdateVmParameters.

private VmManagementParametersBase createUpdateVmParameters() {
    // clear non updateable fields got from config
    getVm().setExportDate(null);
    getVm().setOvfVersion(null);
    VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getVm());
    updateVmParams.setUpdateWatchdog(true);
    updateVmParams.setSoundDeviceEnabled(false);
    updateVmParams.setBalloonEnabled(false);
    updateVmParams.setVirtioScsiEnabled(false);
    updateVmParams.setClearPayload(true);
    updateVmParams.setUpdateRngDevice(true);
    for (GraphicsType graphicsType : GraphicsType.values()) {
        updateVmParams.getGraphicsDevices().put(graphicsType, null);
    }
    for (VmDevice device : getVm().getManagedVmDeviceMap().values()) {
        switch(device.getType()) {
            case WATCHDOG:
                updateVmParams.setWatchdog(new VmWatchdog(device));
                break;
            case SOUND:
                updateVmParams.setSoundDeviceEnabled(true);
                break;
            case BALLOON:
                updateVmParams.setBalloonEnabled(true);
                break;
            case CONTROLLER:
                if (VmDeviceType.VIRTIOSCSI.getName().equals(device.getDevice())) {
                    updateVmParams.setVirtioScsiEnabled(true);
                }
                break;
            case DISK:
                if (VmPayload.isPayload(device.getSpecParams())) {
                    updateVmParams.setVmPayload(new VmPayload(device));
                }
                break;
            case CONSOLE:
                updateVmParams.setConsoleEnabled(true);
                break;
            case RNG:
                updateVmParams.setRngDevice(new VmRngDevice(device));
                break;
            case GRAPHICS:
                updateVmParams.getGraphicsDevices().put(GraphicsType.fromString(device.getDevice()), new GraphicsDevice(device));
                break;
            default:
        }
    }
    // clear these fields as these are non updatable
    getVm().getManagedVmDeviceMap().clear();
    getVm().getUnmanagedDeviceList().clear();
    return updateVmParams;
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 8 with GraphicsDevice

use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.

the class BackendInstanceTypeGraphicsConsolesResource method add.

@Override
public Response add(GraphicsConsole console) {
    GraphicsDevice device = getMapper(GraphicsConsole.class, GraphicsDevice.class).map(console, null);
    device.setVmId(guid);
    ActionReturnValue res = doCreateEntity(ActionType.AddGraphicsAndVideoDevices, createAddGraphicsDeviceParams(device));
    if (res != null && res.getSucceeded()) {
        return BackendGraphicsConsoleHelper.find(console, this::list);
    }
    throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
Also used : GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) WebApplicationException(javax.ws.rs.WebApplicationException) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GraphicsConsole(org.ovirt.engine.api.model.GraphicsConsole)

Example 9 with GraphicsDevice

use of org.ovirt.engine.core.common.businessentities.GraphicsDevice 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)

Example 10 with GraphicsDevice

use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.

the class AddUnmanagedVmsCommand method extractGraphicsDevices.

private List<GraphicsDevice> extractGraphicsDevices(Guid vmId, Object[] devices) {
    List<GraphicsDevice> graphicsDevices = new ArrayList<>();
    for (Object o : devices) {
        Map device = (Map<String, Object>) o;
        String deviceName = (String) device.get(VdsProperties.Device);
        if (graphicsDeviceTypes.contains(deviceName)) {
            GraphicsDevice graphicsDevice = new GraphicsDevice(VmDeviceType.valueOf(deviceName.toUpperCase()));
            graphicsDevice.setVmId(vmId);
            graphicsDevice.setDeviceId(Guid.newGuid());
            graphicsDevice.setManaged(true);
            graphicsDevices.add(graphicsDevice);
        }
    }
    return graphicsDevices;
}
Also used : GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)26 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)12 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)11 GraphicsParameters (org.ovirt.engine.core.common.action.GraphicsParameters)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 GraphicsConsole (org.ovirt.engine.api.model.GraphicsConsole)4 DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)4 Guid (org.ovirt.engine.core.compat.Guid)4 Map (java.util.Map)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)3 VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)3 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)3 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)3 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)3 VmDeviceType (org.ovirt.engine.core.common.utils.VmDeviceType)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2