Search in sources :

Example 21 with GraphicsType

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

the class OvfReader method addDefaultGraphicsDevice.

private void addDefaultGraphicsDevice() {
    VmDevice device = VmDeviceCommonUtils.findVmDeviceByGeneralType(vmBase.getManagedDeviceMap(), VmDeviceGeneralType.GRAPHICS);
    if (device != null) {
        return;
    }
    List<Pair<GraphicsType, DisplayType>> graphicsAndDisplays = osRepository.getGraphicsAndDisplays(vmBase.getOsId(), new Version(getVersion()));
    GraphicsType graphicsType = vmBase.getDefaultDisplayType() == DisplayType.cirrus ? GraphicsType.VNC : GraphicsType.SPICE;
    GraphicsType supportedGraphicsType = null;
    for (Pair<GraphicsType, DisplayType> pair : graphicsAndDisplays) {
        if (pair.getSecond() == vmBase.getDefaultDisplayType()) {
            if (pair.getFirst() == graphicsType) {
                supportedGraphicsType = graphicsType;
                break;
            }
            if (supportedGraphicsType == null) {
                supportedGraphicsType = pair.getFirst();
            }
        }
    }
    if (supportedGraphicsType != null) {
        device = new GraphicsDevice(supportedGraphicsType.getCorrespondingDeviceType());
        device.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId()));
        addManagedVmDevice(device);
    } else {
        log.warn("Cannot find any graphics type for display type {} supported by OS {} in compatibility version {}", vmBase.getDefaultDisplayType().name(), osRepository.getOsName(vmBase.getOsId()), getVersion());
    }
}
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) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) Version(org.ovirt.engine.core.compat.Version) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 22 with GraphicsType

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

the class VdsBrokerObjectsBuilder method updateGraphicsInfo.

/**
 * Updates graphics runtime information according displayInfo VDSM structure if it exists.
 *
 * @param vm - VmDynamic to update
 * @param struct - data from VDSM
 * @return true if displayInfo exists, false otherwise
 */
private static boolean updateGraphicsInfo(VmDynamic vm, Map<String, Object> struct) {
    Object displayInfo = struct.get(VdsProperties.displayInfo);
    if (displayInfo == null) {
        return false;
    }
    for (Object info : (Object[]) displayInfo) {
        Map<String, String> infoMap = (Map<String, String>) info;
        GraphicsType graphicsType = GraphicsType.fromString(infoMap.get(VdsProperties.type));
        GraphicsInfo graphicsInfo = new GraphicsInfo();
        graphicsInfo.setIp(infoMap.get(VdsProperties.ipAddress)).setPort(parseIntegerOrNull(infoMap.get(VdsProperties.port))).setTlsPort(parseIntegerOrNull(infoMap.get(VdsProperties.tlsPort)));
        if (graphicsInfo.getPort() != null || graphicsInfo.getTlsPort() != null) {
            vm.getGraphicsInfos().put(graphicsType, graphicsInfo);
        }
    }
    return true;
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) Map(java.util.Map) HashMap(java.util.HashMap)

Example 23 with GraphicsType

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

the class VdsBrokerObjectsBuilder method addGraphicsDeviceFromExternalProvider.

/**
 *  libvirt video: "vga", "cirrus", "vmvga", "xen", "vbox", "qxl"
 *  ovirt video: "vga", "cirrus", "qxl"
 *  libvirt grahics: sdl, vnc, spice, rdp or desktop
 *  ovirt graphics: cirrus, spice, vnc
 *  try to add the displaytype and graphics if ovirt support the channels
 */
private static void addGraphicsDeviceFromExternalProvider(VmStatic vmStatic, Map<String, Object> struct) {
    Object graphicsName = struct.get(VdsProperties.GRAPHICS_DEVICE);
    Object videoName = struct.get(VdsProperties.VIDEO_DEVICE);
    if (graphicsName == null || videoName == null) {
        return;
    }
    try {
        vmStatic.setDefaultDisplayType(DisplayType.valueOf(videoName.toString()));
    } catch (IllegalArgumentException ex) {
        log.error("Illegal video name '{}'.", videoName.toString());
        return;
    }
    GraphicsType graphicsType = GraphicsType.fromString(graphicsName.toString());
    if (graphicsType == null) {
        log.error("Illegal graphics name '{}'.", graphicsName.toString());
        return;
    }
    VmDeviceCommonUtils.addGraphicsDevice(vmStatic, graphicsType.getCorrespondingDeviceType());
    VmDeviceCommonUtils.addVideoDevice(vmStatic);
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType)

Example 24 with GraphicsType

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

the class UnitToGraphicsDeviceParamsBuilder method build.

@Override
protected void build(UnitVmModel source, HasGraphicsDevices destination) {
    if (source.getDisplayType().getSelectedItem() == null || source.getGraphicsType().getSelectedItem() == null) {
        return;
    }
    for (GraphicsType graphicsType : GraphicsType.values()) {
        // reset
        destination.getGraphicsDevices().put(graphicsType, null);
        // if not headless VM then set the selected graphic devices
        if (!source.getIsHeadlessModeEnabled().getEntity() && source.getGraphicsType().getSelectedItem().getBackingGraphicsTypes().contains(graphicsType)) {
            GraphicsDevice d = new GraphicsDevice(graphicsType.getCorrespondingDeviceType());
            destination.getGraphicsDevices().put(d.getGraphicsType(), d);
        }
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice)

Example 25 with GraphicsType

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

the class ExistingNonClusterModelBehavior method initialize.

@Override
public void initialize() {
    super.initialize();
    updateNumOfSockets();
    getModel().getUsbPolicy().setItems(Arrays.asList(UsbPolicy.values()));
    getModel().getIsSoundcardEnabled().setIsChangeable(true);
    Frontend.getInstance().runQuery(QueryType.GetGraphicsDevices, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
        List<GraphicsDevice> graphicsDevices = returnValue.getReturnValue();
        Set<GraphicsType> graphicsTypesCollection = new HashSet<>();
        for (GraphicsDevice graphicsDevice : graphicsDevices) {
            graphicsTypesCollection.add(graphicsDevice.getGraphicsType());
        }
        initDisplayTypes(entity.getDefaultDisplayType(), UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsTypesCollection));
        doBuild();
    }));
    initSoundCard(entity.getId());
    updateConsoleDevice(entity.getId());
    initPriority(entity.getPriority());
    Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
    getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), entity.getId());
    getInstance().getWatchdogByVmId(new AsyncQuery<QueryReturnValue>(returnValue -> {
        @SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
        for (VmWatchdog watchdog : watchdogs) {
            getModel().getWatchdogAction().setSelectedItem(watchdog.getAction());
            getModel().getWatchdogModel().setSelectedItem(watchdog.getModel());
        }
    }), entity.getId());
    Frontend.getInstance().runQuery(QueryType.GetRngDevice, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
        List<VmDevice> rngDevices = returnValue.getReturnValue();
        getModel().getIsRngEnabled().setEntity(!rngDevices.isEmpty());
        if (!rngDevices.isEmpty()) {
            VmRngDevice rngDevice = new VmRngDevice(rngDevices.get(0));
            getModel().setRngDevice(rngDevice);
        }
    }));
    getModel().getEmulatedMachine().setSelectedItem(entity.getCustomEmulatedMachine());
    getModel().getCustomCpu().setSelectedItem(entity.getCustomCpuName());
    getModel().getMigrationMode().setSelectedItem(entity.getMigrationSupport());
    getModel().getCpuSharesAmount().setEntity(entity.getCpuShares());
    getModel().getIsHighlyAvailable().setEntity(entity.isAutoStartup());
    updateCpuSharesSelection();
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) QueryType(org.ovirt.engine.core.common.queries.QueryType) AsyncDataProvider.getInstance(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider.getInstance) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashSet(java.util.HashSet) HwOnlyVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.HwOnlyVmBaseToUnitBuilder) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Set(java.util.Set) HashSet(java.util.HashSet) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) Collection(java.util.Collection) List(java.util.List) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

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