Search in sources :

Example 1 with DisplayType

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

the class NewTemplateVmModelBehavior method initTemplate.

private void initTemplate() {
    // Update model state according to VM properties.
    buildModel(this.vm.getStaticData(), (source, destination) -> {
        updateSelectedCdImage(vm.getStaticData());
        updateTimeZone(vm.getTimeZone());
        updateConsoleDevice(vm.getId());
        getModel().getStorageDomain().setIsChangeable(true);
        getModel().getProvisioning().setIsAvailable(false);
        // Select display protocol.
        DisplayType displayType = vm.getDefaultDisplayType();
        if (getModel().getDisplayType().getItems().contains(displayType)) {
            getModel().getDisplayType().setSelectedItem(displayType);
        }
        initPriority(vm.getPriority());
    });
}
Also used : DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType)

Example 2 with DisplayType

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

the class TemplateVmModelBehavior method initTemplate.

private void initTemplate() {
    // Update model state according to VM properties.
    buildModel(template, (source, destination) -> {
        updateTimeZone(template.getTimeZone());
        // Storage domain and provisioning are not available for an existing VM.
        getModel().getStorageDomain().setIsChangeable(false);
        getModel().getProvisioning().setIsAvailable(false);
        // Select display protocol.
        DisplayType displayType = template.getDefaultDisplayType();
        if (getModel().getDisplayType().getItems().contains(displayType)) {
            getModel().getDisplayType().setSelectedItem(displayType);
        }
        updateConsoleDevice(template.getId());
        toggleAutoSetVmHostname();
        getModel().getVmInitEnabled().setEntity(template.getVmInit() != null);
        getModel().getVmInitModel().init(template);
        getModel().getTemplateVersionName().setEntity(template.getTemplateVersionName());
        getModel().getBootMenuEnabled().setEntity(template.isBootMenuEnabled());
        getModel().getSpiceFileTransferEnabled().setEntity(template.isSpiceFileTransferEnabled());
        getModel().getSpiceCopyPasteEnabled().setEntity(template.isSpiceCopyPasteEnabled());
        getModel().getMigrationMode().setSelectedItem(template.getMigrationSupport());
        initPriority(template.getPriority());
        getModel().updateResumeBehavior();
    });
}
Also used : DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType)

Example 3 with DisplayType

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

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

the class VmHandler method autoSelectDefaultDisplayType.

/**
 * Automatic selection of display type based on its graphics types in parameters.
 * This method preserves backward compatibility for REST API - legacy REST API doesn't allow to set display and
 * graphics separately.
 */
public void autoSelectDefaultDisplayType(Guid srcEntityId, VmBase parametersStaticData, Cluster cluster, Map<GraphicsType, GraphicsDevice> graphicsDevices) {
    if (parametersStaticData.getOsId() == OsRepository.AUTO_SELECT_OS) {
        return;
    }
    List<Pair<GraphicsType, DisplayType>> graphicsAndDisplays = osRepository.getGraphicsAndDisplays(parametersStaticData.getOsId(), CompatibilityVersionUtils.getEffective(parametersStaticData, cluster));
    if (parametersStaticData.getDefaultDisplayType() != null && (parametersStaticData.getDefaultDisplayType() == DisplayType.none || isDisplayTypeSupported(parametersStaticData.getDefaultDisplayType(), graphicsAndDisplays))) {
        return;
    }
    DisplayType defaultDisplayType = null;
    // map holding display type -> set of supported graphics types for this display type
    Map<DisplayType, Set<GraphicsType>> displayGraphicsSupport = new LinkedHashMap<>();
    for (Pair<GraphicsType, DisplayType> graphicsAndDisplay : graphicsAndDisplays) {
        DisplayType display = graphicsAndDisplay.getSecond();
        if (!displayGraphicsSupport.containsKey(display)) {
            displayGraphicsSupport.put(display, new HashSet<>());
        }
        displayGraphicsSupport.get(display).add(graphicsAndDisplay.getFirst());
    }
    for (Map.Entry<DisplayType, Set<GraphicsType>> entry : displayGraphicsSupport.entrySet()) {
        final List<GraphicsType> graphicsTypes = vmDeviceUtils.getGraphicsTypesOfEntity(srcEntityId);
        final Set<GraphicsType> resultingVmGraphics = getResultingVmGraphics(graphicsTypes, graphicsDevices);
        if (entry.getValue().containsAll(resultingVmGraphics)) {
            defaultDisplayType = entry.getKey();
            break;
        }
    }
    if (defaultDisplayType == null) {
        if (!displayGraphicsSupport.isEmpty()) {
            // when not found otherwise, let's take osinfo's record as the default
            Map.Entry<DisplayType, Set<GraphicsType>> entry = displayGraphicsSupport.entrySet().iterator().next();
            defaultDisplayType = entry.getKey();
        } else {
            // no osinfo record
            defaultDisplayType = DisplayType.qxl;
        }
    }
    parametersStaticData.setDefaultDisplayType(defaultDisplayType);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) LinkedHashMap(java.util.LinkedHashMap) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 5 with DisplayType

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

the class LibvirtVmXmlBuilder method overrideDevicesForRunOnce.

private List<VmDevice> overrideDevicesForRunOnce(List<VmDevice> devices) {
    if (!vm.isRunOnce()) {
        return devices;
    }
    // video device handling
    DisplayType displayType = vm.getDefaultDisplayType();
    if (displayType != null) {
        // remove existing video device
        devices = devices.stream().filter(dev -> dev.getType() != VmDeviceGeneralType.VIDEO).collect(Collectors.toList());
        // add new video device
        if (displayType != DisplayType.none) {
            devices.add(vmInfoBuildUtils.createVideoDeviceByDisplayType(displayType, vm.getId()));
        }
    }
    // graphics device handling
    if (displayType == DisplayType.none || (vm.getGraphicsInfos() != null && !vm.getGraphicsInfos().isEmpty())) {
        // remove existing graphics devices
        devices = devices.stream().filter(dev -> dev.getType() != VmDeviceGeneralType.GRAPHICS).collect(Collectors.toList());
        if (displayType != DisplayType.none) {
            // add new graphics devices
            Map<GraphicsType, GraphicsInfo> infos = vm.getGraphicsInfos();
            Map<String, Object> specParamsFromVm = new HashMap<>();
            vmInfoBuildUtils.addVmGraphicsOptions(infos, specParamsFromVm, vm);
            devices.addAll(vmInfoBuildUtils.createGraphicsDevices(infos, specParamsFromVm, vm.getId()));
        }
    }
    // the user may specify floppy path while there is no device in the database
    if (!StringUtils.isEmpty(vm.getFloppyPath()) && devices.stream().noneMatch(dev -> dev.getDevice().equals(VmDeviceType.FLOPPY.getName()))) {
        devices.add(vmInfoBuildUtils.createFloppyDevice(vm));
    }
    return devices;
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) VmType(org.ovirt.engine.core.common.businessentities.VmType) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LoggerFactory(org.slf4j.LoggerFactory) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) VmCpuCountHelper(org.ovirt.engine.core.common.utils.VmCpuCountHelper) XmlTextWriter(org.ovirt.engine.core.utils.ovf.xml.XmlTextWriter) HugePageUtils(org.ovirt.engine.core.common.utils.HugePageUtils) ChipsetType(org.ovirt.engine.core.common.businessentities.ChipsetType) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) StringMapUtils(org.ovirt.engine.core.utils.StringMapUtils) VmDeviceCommonUtils.updateVmDevicesBootOrder(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils.updateVmDevicesBootOrder) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics) Version(org.ovirt.engine.core.compat.Version) MemoizingSupplier(org.ovirt.engine.core.utils.MemoizingSupplier) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) Collection(java.util.Collection) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) List(java.util.List) Stream(java.util.stream.Stream) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) Entry(java.util.Map.Entry) Optional(java.util.Optional) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) NumaSettingFactory(org.ovirt.engine.core.vdsbroker.vdsbroker.NumaSettingFactory) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) NetworkUtils(org.ovirt.engine.core.utils.NetworkUtils) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils) HashSet(java.util.HashSet) ArchStrategyFactory(org.ovirt.engine.core.utils.archstrategy.ArchStrategyFactory) VdsProperties(org.ovirt.engine.core.vdsbroker.vdsbroker.VdsProperties) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Network(org.ovirt.engine.core.common.businessentities.network.Network) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) Pair(org.ovirt.engine.core.common.utils.Pair) Config(org.ovirt.engine.core.common.config.Config) Logger(org.slf4j.Logger) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmHostDevice(org.ovirt.engine.core.common.businessentities.VmHostDevice) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VM(org.ovirt.engine.core.common.businessentities.VM) NumaTuneMode(org.ovirt.engine.core.common.businessentities.NumaTuneMode) GetControllerIndices(org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices) IoTuneUtils.ioTuneListFrom(org.ovirt.engine.core.vdsbroker.vdsbroker.IoTuneUtils.ioTuneListFrom) Comparator(java.util.Comparator) Collections(java.util.Collections) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) HashMap(java.util.HashMap) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo)

Aggregations

DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)14 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)8 Pair (org.ovirt.engine.core.common.utils.Pair)6 GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 Set (java.util.Set)3 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)3 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)3 VmDeviceType (org.ovirt.engine.core.common.utils.VmDeviceType)3 Version (org.ovirt.engine.core.compat.Version)3 Collection (java.util.Collection)2 List (java.util.List)2 VmDeviceGeneralType (org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 VmInterfaceType (org.ovirt.engine.core.common.businessentities.network.VmInterfaceType)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 VmDeviceCommonUtils (org.ovirt.engine.core.common.utils.VmDeviceCommonUtils)2 Guid (org.ovirt.engine.core.compat.Guid)2