Search in sources :

Example 21 with GraphicsDevice

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

the class InstanceTypeManager method updateDefaultDisplayRelatedFields.

protected void updateDefaultDisplayRelatedFields(final VmBase vmBase) {
    // Update display protocol selected item
    final Collection<DisplayType> displayTypes = model.getDisplayType().getItems();
    if (displayTypes == null || displayTypes.isEmpty()) {
        return;
    }
    // graphics
    Frontend.getInstance().runQuery(QueryType.GetGraphicsDevices, new IdQueryParameters(vmBase.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
        deactivate();
        List<GraphicsDevice> graphicsDevices = returnValue.getReturnValue();
        model.getIsHeadlessModeEnabled().setEntity(vmBase.getDefaultDisplayType() == DisplayType.none);
        // select display protocol
        // first by default
        DisplayType displayProtocol = displayTypes.iterator().next();
        if (displayTypes.contains(vmBase.getDefaultDisplayType())) {
            // if display types contain DT of a vm, pick this one
            displayProtocol = vmBase.getDefaultDisplayType();
        }
        maybeSetSelectedItem(model.getDisplayType(), displayProtocol);
        Set<GraphicsType> graphicsTypes = new HashSet<>();
        for (GraphicsDevice graphicsDevice : graphicsDevices) {
            graphicsTypes.add(graphicsDevice.getGraphicsType());
        }
        UnitVmModel.GraphicsTypes selected = UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsTypes);
        if (selected != null && getModel().getGraphicsType().getItems().contains(selected)) {
            maybeSetSelectedItem(getModel().getGraphicsType(), selected);
        }
        maybeSetSelectedItem(model.getNumOfMonitors(), vmBase.getNumOfMonitors());
        maybeSetSelectedItem(model.getUsbPolicy(), vmBase.getUsbPolicy());
        maybeSetEntity(model.getIsSmartcardEnabled(), vmBase.isSmartcardEnabled());
        maybeSetSingleQxlPci(vmBase);
        activate();
    }));
}
Also used : VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType) PriorityUtil(org.ovirt.engine.ui.uicommonweb.models.vms.PriorityUtil) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) CustomInstanceType(org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType) Event(org.ovirt.engine.ui.uicompat.Event) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmWatchdogType(org.ovirt.engine.core.common.businessentities.VmWatchdogType) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) VirtioScsiUtil(org.ovirt.engine.ui.uicommonweb.models.vms.VirtioScsiUtil) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashSet(java.util.HashSet) Set(java.util.Set) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) ArrayList(java.util.ArrayList) List(java.util.List)

Example 22 with GraphicsDevice

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

the class VmDeviceCommonUtils method addGraphicsDevice.

public static void addGraphicsDevice(VmBase vmBase, VmDeviceType vmDeviceType) {
    GraphicsDevice graphicsDevice = new GraphicsDevice(vmDeviceType);
    graphicsDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId()));
    vmBase.getManagedDeviceMap().put(graphicsDevice.getDeviceId(), graphicsDevice);
}
Also used : GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 23 with GraphicsDevice

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

the class GetGraphicsDevicesMultipleQuery method mapDevices.

private void mapDevices(Map<Guid, List<GraphicsDevice>> result, VmDeviceType type, List<Guid> vmsIds) {
    log.debug("Retrieving graphics devices '{}' for '{}' vms", type.getName(), vmsIds.size());
    List<VmDevice> devicesList = vmDeviceDao.getVmDeviceByTypeAndDevice(vmsIds, VmDeviceGeneralType.GRAPHICS, type.getName(), getUserID(), getParameters().isFiltered());
    for (VmDevice device : devicesList) {
        result.computeIfAbsent(device.getVmId(), guid -> new ArrayList<>()).add(new GraphicsDevice(device));
    }
}
Also used : VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) IdsQueryParameters(org.ovirt.engine.core.common.queries.IdsQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) EngineContext(org.ovirt.engine.core.bll.context.EngineContext) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) Inject(javax.inject.Inject) List(java.util.List) Map(java.util.Map) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) ArrayList(java.util.ArrayList)

Example 24 with GraphicsDevice

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

the class ImportUtils method updateGraphicsDevices.

/**
 * Checks whether imported VM/Template has Graphics devices.
 *  - If the VM/Template has Video devices and no Graphics devices, this method
 *    adds compatible graphics device to devices map (This could mean
 *    the exported VM/Template has been created when we didn't have Graphics
 *    devices).
 *  - If the VM/Template has no Video devices, no Graphics devices are added
 *    (we assume headless VM/Template).
 */
public void updateGraphicsDevices(VmBase vmBase, Version clusterVersion) {
    if (vmBase == null || vmBase.getManagedDeviceMap() == null || clusterVersion == null) {
        return;
    }
    if (Version.v4_0.lessOrEquals(clusterVersion)) {
        if (removeVideoDevice(VmDeviceType.VNC, VmDeviceType.CIRRUS, vmBase.getManagedDeviceMap())) {
            vmBase.setDefaultDisplayType(DisplayType.vga);
            VmDeviceCommonUtils.addVideoDevice(vmBase);
        }
    }
    List<VmDevice> videoDevs = getDevicesOfType(VmDeviceGeneralType.VIDEO, vmBase.getManagedDeviceMap());
    boolean hasNoGraphics = getDevicesOfType(VmDeviceGeneralType.GRAPHICS, vmBase.getManagedDeviceMap()).isEmpty();
    if (!videoDevs.isEmpty() && hasNoGraphics) {
        GraphicsDevice compatibleGraphics = getCompatibleGraphics(VmDeviceType.getByName(videoDevs.get(0).getDevice()), clusterVersion, vmBase);
        if (compatibleGraphics != null) {
            vmBase.getManagedDeviceMap().put(compatibleGraphics.getDeviceId(), compatibleGraphics);
        }
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice)

Example 25 with GraphicsDevice

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

the class VmHandler method autoSelectGraphicsDevice.

public void autoSelectGraphicsDevice(Guid srcEntityId, VmStatic parametersStaticData, Cluster cluster, Map<GraphicsType, GraphicsDevice> graphicsDevices, Version compatibilityVersion) {
    if (// if not set by user in params
    graphicsDevices.isEmpty() && cluster != null) {
        // and Cluster is known
        DisplayType defaultDisplayType = parametersStaticData.getDefaultDisplayType();
        int osId = parametersStaticData.getOsId();
        List<GraphicsType> sourceGraphics = vmDeviceUtils.getGraphicsTypesOfEntity(srcEntityId);
        // otherwise choose the first supported graphics device
        if (!vmValidationUtils.isGraphicsAndDisplaySupported(osId, compatibilityVersion, sourceGraphics, defaultDisplayType)) {
            GraphicsType defaultGraphicsType = null;
            List<Pair<GraphicsType, DisplayType>> pairs = osRepository.getGraphicsAndDisplays(osId, compatibilityVersion);
            for (Pair<GraphicsType, DisplayType> pair : pairs) {
                if (pair.getSecond().equals(defaultDisplayType)) {
                    defaultGraphicsType = pair.getFirst();
                    break;
                }
            }
            if (defaultGraphicsType != null) {
                for (GraphicsType graphicsType : GraphicsType.values()) {
                    // reset graphics devices
                    graphicsDevices.put(graphicsType, null);
                }
                VmDeviceType vmDisplayType = defaultGraphicsType.getCorrespondingDeviceType();
                GraphicsDevice defaultGraphicsDevice = new GraphicsDevice(vmDisplayType);
                graphicsDevices.put(defaultGraphicsType, defaultGraphicsDevice);
            }
        }
    }
}
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) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) Pair(org.ovirt.engine.core.common.utils.Pair)

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