Search in sources :

Example 16 with GraphicsDevice

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

the class BackendVmGraphicsConsolesResource method add.

@Override
public Response add(GraphicsConsole console) {
    GraphicsDevice device = getMapper(GraphicsConsole.class, GraphicsDevice.class).map(console, null);
    device.setVmId(guid);
    ActionReturnValue res = doCreateEntity(ActionType.AddGraphicsAndVideoDevices, createAddGraphicsDeviceParams(device));
    if (res != null && res.getSucceeded()) {
        return BackendGraphicsConsoleHelper.find(console, this::list);
    }
    throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
Also used : GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) WebApplicationException(javax.ws.rs.WebApplicationException) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GraphicsConsole(org.ovirt.engine.api.model.GraphicsConsole)

Example 17 with GraphicsDevice

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

the class BackendTemplateGraphicsConsolesResource method add.

@Override
public Response add(GraphicsConsole console) {
    GraphicsDevice device = getMapper(GraphicsConsole.class, GraphicsDevice.class).map(console, null);
    device.setVmId(guid);
    ActionReturnValue res = doCreateEntity(ActionType.AddGraphicsAndVideoDevices, createAddGraphicsDeviceParams(device));
    if (res != null && res.getSucceeded()) {
        return BackendGraphicsConsoleHelper.find(console, this::list);
    }
    throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
Also used : GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) WebApplicationException(javax.ws.rs.WebApplicationException) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GraphicsConsole(org.ovirt.engine.api.model.GraphicsConsole)

Example 18 with GraphicsDevice

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

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

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

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