Search in sources :

Example 6 with GraphicsType

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

the class DisplayHelper method setGraphicsToParams.

/**
 * Set data about graphics from (REST) Template to parameters.
 *
 * @param display - display that contains graphics data
 * @param params  - parameters to be updated with graphics data
 */
public static void setGraphicsToParams(Display display, HasGraphicsDevices params) {
    if (display != null && display.isSetType()) {
        DisplayType newDisplayType = display.getType();
        if (newDisplayType != null) {
            for (GraphicsType graphicsType : GraphicsType.values()) {
                // reset graphics devices
                params.getGraphicsDevices().put(graphicsType, null);
            }
            GraphicsType newGraphicsType = DisplayMapper.map(newDisplayType, null);
            params.getGraphicsDevices().put(newGraphicsType, new GraphicsDevice(newGraphicsType.getCorrespondingDeviceType()));
        }
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) DisplayType(org.ovirt.engine.api.model.DisplayType)

Example 7 with GraphicsType

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

the class VdsBrokerObjectsBuilder method updateGraphicsInfoFromConf.

/**
 * Updates graphics runtime information according to vm.conf vdsm structure. It's used with legacy VDSMs that have
 * no notion about graphics device.
 * @param vm - VmDynamic to update
 * @param struct - data from VDSM
 */
private static void updateGraphicsInfoFromConf(VmDynamic vm, Map<String, Object> struct) {
    GraphicsType vmGraphicsType = parseGraphicsType(struct);
    if (vmGraphicsType == null) {
        log.debug("graphics data missing in XML.");
        return;
    }
    GraphicsInfo graphicsInfo = new GraphicsInfo();
    if (struct.containsKey(VdsProperties.display_port)) {
        try {
            graphicsInfo.setPort(Integer.parseInt(struct.get(VdsProperties.display_port).toString()));
        } catch (NumberFormatException e) {
            log.error("vm display_port value illegal : {0}", struct.get(VdsProperties.display_port));
        }
    } else if (struct.containsKey(VdsProperties.display)) {
        try {
            graphicsInfo.setPort(VNC_START_PORT + Integer.parseInt(struct.get(VdsProperties.display).toString()));
        } catch (NumberFormatException e) {
            log.error("vm display value illegal : {0}", struct.get(VdsProperties.display));
        }
    }
    if (struct.containsKey(VdsProperties.display_secure_port)) {
        try {
            graphicsInfo.setTlsPort(Integer.parseInt(struct.get(VdsProperties.display_secure_port).toString()));
        } catch (NumberFormatException e) {
            log.error("vm display_secure_port value illegal : {0}", struct.get(VdsProperties.display_secure_port));
        }
    }
    if (struct.containsKey(VdsProperties.displayIp)) {
        graphicsInfo.setIp((String) struct.get(VdsProperties.displayIp));
    }
    vm.getGraphicsInfos().put(vmGraphicsType, graphicsInfo);
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo)

Example 8 with GraphicsType

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

the class UpdateVmTemplateCommand method updateGraphicsDevice.

private void updateGraphicsDevice() {
    for (GraphicsType type : getParameters().getGraphicsDevices().keySet()) {
        GraphicsDevice vmGraphicsDevice = getGraphicsDevOfType(type);
        if (vmGraphicsDevice == null) {
            if (getParameters().getGraphicsDevices().get(type) != null) {
                getParameters().getGraphicsDevices().get(type).setVmId(getVmTemplateId());
                GraphicsParameters parameters = new GraphicsParameters(getParameters().getGraphicsDevices().get(type));
                parameters.setVm(false);
                backend.runInternalAction(ActionType.AddGraphicsDevice, parameters);
            }
        } else {
            if (getParameters().getGraphicsDevices().get(type) == null) {
                GraphicsParameters parameters = new GraphicsParameters(vmGraphicsDevice);
                parameters.setVm(false);
                backend.runInternalAction(ActionType.RemoveGraphicsDevice, parameters);
            } else {
                getParameters().getGraphicsDevices().get(type).setVmId(getVmTemplateId());
                GraphicsParameters parameters = new GraphicsParameters(getParameters().getGraphicsDevices().get(type));
                parameters.setVm(false);
                backend.runInternalAction(ActionType.UpdateGraphicsDevice, parameters);
            }
        }
    }
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters)

Example 9 with GraphicsType

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

the class ProcessDownVmCommand method createUpdateVmParameters.

private VmManagementParametersBase createUpdateVmParameters() {
    // clear non updateable fields got from config
    getVm().setExportDate(null);
    getVm().setOvfVersion(null);
    VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getVm());
    updateVmParams.setUpdateWatchdog(true);
    updateVmParams.setSoundDeviceEnabled(false);
    updateVmParams.setBalloonEnabled(false);
    updateVmParams.setVirtioScsiEnabled(false);
    updateVmParams.setClearPayload(true);
    updateVmParams.setUpdateRngDevice(true);
    for (GraphicsType graphicsType : GraphicsType.values()) {
        updateVmParams.getGraphicsDevices().put(graphicsType, null);
    }
    for (VmDevice device : getVm().getManagedVmDeviceMap().values()) {
        switch(device.getType()) {
            case WATCHDOG:
                updateVmParams.setWatchdog(new VmWatchdog(device));
                break;
            case SOUND:
                updateVmParams.setSoundDeviceEnabled(true);
                break;
            case BALLOON:
                updateVmParams.setBalloonEnabled(true);
                break;
            case CONTROLLER:
                if (VmDeviceType.VIRTIOSCSI.getName().equals(device.getDevice())) {
                    updateVmParams.setVirtioScsiEnabled(true);
                }
                break;
            case DISK:
                if (VmPayload.isPayload(device.getSpecParams())) {
                    updateVmParams.setVmPayload(new VmPayload(device));
                }
                break;
            case CONSOLE:
                updateVmParams.setConsoleEnabled(true);
                break;
            case RNG:
                updateVmParams.setRngDevice(new VmRngDevice(device));
                break;
            case GRAPHICS:
                updateVmParams.getGraphicsDevices().put(GraphicsType.fromString(device.getDevice()), new GraphicsDevice(device));
                break;
            default:
        }
    }
    // clear these fields as these are non updatable
    getVm().getManagedVmDeviceMap().clear();
    getVm().getUnmanagedDeviceList().clear();
    return updateVmParams;
}
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) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 10 with GraphicsType

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

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