Search in sources :

Example 11 with GraphicsDevice

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

the class AddUnmanagedVmsCommand method importHostedEngineVm.

// Visible for testing
protected void importHostedEngineVm(Map<String, Object> vmStruct) {
    VM vm = VdsBrokerObjectsBuilder.buildVmsDataFromExternalProvider(vmStruct);
    if (vm != null) {
        vm.setImages(VdsBrokerObjectsBuilder.buildDiskImagesFromDevices(vmStruct, vm.getId()));
        vm.setInterfaces(VdsBrokerObjectsBuilder.buildVmNetworkInterfacesFromDevices(vmStruct));
        for (DiskImage diskImage : vm.getImages()) {
            vm.getDiskMap().put(diskImage.getId(), diskImage);
        }
        vm.setClusterId(getClusterId());
        vm.setRunOnVds(getVdsId());
        List<GraphicsDevice> graphicsDevices = extractGraphicsDevices(vm.getId(), (Object[]) vmStruct.get(VdsProperties.Devices));
        if (graphicsDevices.size() == 1 && VmDeviceType.valueOf(graphicsDevices.get(0).getDevice().toUpperCase()) == VmDeviceType.VNC) {
            vm.setDefaultDisplayType(DisplayType.vga);
        } else {
            vm.setDefaultDisplayType(DisplayType.qxl);
        }
        // HE VM does not support that feature, disable it
        vm.setSingleQxlPci(false);
        for (GraphicsDevice graphicsDevice : graphicsDevices) {
            vm.getManagedVmDeviceMap().put(graphicsDevice.getDeviceId(), graphicsDevice);
        }
        VmDevice consoleDevice = VdsBrokerObjectsBuilder.buildConsoleDevice(vmStruct, vm.getId());
        if (consoleDevice != null) {
            vm.getManagedVmDeviceMap().put(consoleDevice.getDeviceId(), consoleDevice);
        }
        importHostedEngineVm(vm);
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 12 with GraphicsDevice

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

the class GetGraphicsDevicesQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<GraphicsDevice> result = new LinkedList<>();
    // we must use getVmDeviceByVmIdTypeAndDevice since it supports user filtering
    List<VmDevice> spiceDevs = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(getParameters().getId(), VmDeviceGeneralType.GRAPHICS, VmDeviceType.SPICE.getName(), getUserID(), getParameters().isFiltered());
    if (spiceDevs != null && !spiceDevs.isEmpty()) {
        result.add(new GraphicsDevice(spiceDevs.get(0)));
    }
    List<VmDevice> vncDevs = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(getParameters().getId(), VmDeviceGeneralType.GRAPHICS, VmDeviceType.VNC.getName(), getUserID(), getParameters().isFiltered());
    if (vncDevs != null && !vncDevs.isEmpty()) {
        result.add(new GraphicsDevice(vncDevs.get(0)));
    }
    setReturnValue(result);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) LinkedList(java.util.LinkedList)

Example 13 with GraphicsDevice

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

the class GetNextRunGraphicsDevicesQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    QueryReturnValue nextRun = runInternalQuery(QueryType.GetVmNextRunConfiguration, new IdQueryParameters(getParameters().getId()));
    VM vm = nextRun.getReturnValue();
    if (vm != null && vm.isNextRunConfigurationExists()) {
        List<GraphicsDevice> result = new LinkedList<>();
        for (GraphicsType graphicsType : GraphicsType.values()) {
            VmDevice device = VmDeviceCommonUtils.findVmDeviceByType(vm.getManagedVmDeviceMap(), graphicsType.getCorrespondingDeviceType());
            if (device != null) {
                result.add(new GraphicsDevice(device));
            }
        }
        setReturnValue(result);
    } else {
        super.executeQueryCommand();
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VM(org.ovirt.engine.core.common.businessentities.VM) LinkedList(java.util.LinkedList)

Example 14 with GraphicsDevice

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

the class ImportUtils method getCompatibleGraphics.

private GraphicsDevice getCompatibleGraphics(VmDeviceType videoDeviceType, Version clusterVersion, VmBase vmBase) {
    GraphicsDevice graphicsDevice = null;
    GraphicsType compatibleType = null;
    for (Pair<GraphicsType, DisplayType> graphicsDisplayPair : osRepository.getGraphicsAndDisplays(vmBase.getOsId(), clusterVersion)) {
        if (graphicsDisplayPair.getSecond().getDefaultVmDeviceType() == videoDeviceType) {
            compatibleType = graphicsDisplayPair.getFirst();
            // previously to spice+vnc, QXL was only used by spice, so prefer spice if available
            if (videoDeviceType == VmDeviceType.QXL && compatibleType == GraphicsType.SPICE) {
                break;
            }
        }
    }
    if (compatibleType != null) {
        graphicsDevice = new GraphicsDevice(compatibleType.getCorrespondingDeviceType());
        graphicsDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId()));
    }
    return graphicsDevice;
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 15 with GraphicsDevice

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

the class UpdateVmCommandTest method mockGraphicsDevice.

private void mockGraphicsDevice() {
    VmDevice graphicsDevice = new GraphicsDevice(VmDeviceType.SPICE);
    graphicsDevice.setDeviceId(Guid.Empty);
    graphicsDevice.setVmId(vm.getId());
    mockVmDevice(graphicsDevice);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice)

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