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());
}
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());
}
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());
}
}
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);
}
}
}
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();
}
Aggregations