Search in sources :

Example 26 with GraphicsType

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

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

the class NonClusterModelBehaviorBase method initDisplayTypes.

protected void initDisplayTypes(DisplayType selected, UnitVmModel.GraphicsTypes selectedGrahicsTypes) {
    getModel().getDisplayType().getSelectedItemChangedEvent().addListener((ev, sender, args) -> enableSinglePCI(getModel().getDisplayType().getSelectedItem() == DisplayType.qxl));
    List<Pair<GraphicsType, DisplayType>> allGraphicsAndDisplays = new ArrayList<>();
    for (GraphicsType graphicsType : GraphicsType.values()) {
        for (DisplayType displayType : DisplayType.values()) {
            if (displayType != DisplayType.none) {
                allGraphicsAndDisplays.add(new Pair<>(graphicsType, displayType));
            }
        }
    }
    getModel().initDisplayModels(allGraphicsAndDisplays);
    initGraphicsModel(selectedGrahicsTypes);
    if (getModel().getDisplayType().getItems().contains(selected)) {
        getModel().getDisplayType().setSelectedItem(selected);
    }
    if (selected == DisplayType.none) {
        getModel().getDisplayType().setSelectedItem(DisplayType.qxl);
        getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.SPICE);
        getModel().getIsHeadlessModeEnabled().setEntity(true);
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) ArrayList(java.util.ArrayList) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 28 with GraphicsType

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

Example 29 with GraphicsType

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

the class CloneVmCommand method setGraphicsDevices.

private void setGraphicsDevices(List<VmDevice> devices) {
    for (GraphicsType graphicsType : GraphicsType.values()) {
        // prevent copying from the template
        getParameters().getGraphicsDevices().put(graphicsType, null);
    }
    for (VmDevice device : devices) {
        if (device.getType() == VmDeviceGeneralType.GRAPHICS) {
            GraphicsDevice graphicsDevice = new GraphicsDevice(device);
            getParameters().getGraphicsDevices().put(graphicsDevice.getGraphicsType(), graphicsDevice);
        }
    }
}
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)

Example 30 with GraphicsType

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

the class RunVmValidator method getVmActiveGraphics.

private Set<GraphicsType> getVmActiveGraphics() {
    if (!vm.getGraphicsInfos().isEmpty()) {
        // graphics overriden in runonce
        return vm.getGraphicsInfos().keySet();
    } else {
        List<VmDevice> graphicDevices = DbFacade.getInstance().getVmDeviceDao().getVmDeviceByVmIdAndType(vm.getId(), VmDeviceGeneralType.GRAPHICS);
        Set<GraphicsType> graphicsTypes = new HashSet<>();
        for (VmDevice graphicDevice : graphicDevices) {
            GraphicsType type = GraphicsType.fromString(graphicDevice.getDevice());
            graphicsTypes.add(type);
        }
        return graphicsTypes;
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) HashSet(java.util.HashSet)

Aggregations

GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)31 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)13 GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)12 HashSet (java.util.HashSet)8 DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)8 ArrayList (java.util.ArrayList)7 Map (java.util.Map)6 GraphicsInfo (org.ovirt.engine.core.common.businessentities.GraphicsInfo)6 Guid (org.ovirt.engine.core.compat.Guid)6 HashMap (java.util.HashMap)5 List (java.util.List)5 Set (java.util.Set)5 VM (org.ovirt.engine.core.common.businessentities.VM)5 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)5 VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)5 Collection (java.util.Collection)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)4