use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class AddUnmanagedVmsCommand method importHostedEngineVm.
// Visible for testing
protected void importHostedEngineVm(Map<String, Object> vmStruct) {
VM vm = VdsBrokerObjectsBuilder.buildVmsDataFromExternalProvider(vmStruct);
if (vm != null) {
vm.setImages(VdsBrokerObjectsBuilder.buildDiskImagesFromDevices(vmStruct, vm.getId()));
vm.setInterfaces(VdsBrokerObjectsBuilder.buildVmNetworkInterfacesFromDevices(vmStruct));
for (DiskImage diskImage : vm.getImages()) {
vm.getDiskMap().put(diskImage.getId(), diskImage);
}
vm.setClusterId(getClusterId());
vm.setRunOnVds(getVdsId());
List<GraphicsDevice> graphicsDevices = extractGraphicsDevices(vm.getId(), (Object[]) vmStruct.get(VdsProperties.Devices));
if (graphicsDevices.size() == 1 && VmDeviceType.valueOf(graphicsDevices.get(0).getDevice().toUpperCase()) == VmDeviceType.VNC) {
vm.setDefaultDisplayType(DisplayType.vga);
} else {
vm.setDefaultDisplayType(DisplayType.qxl);
}
// HE VM does not support that feature, disable it
vm.setSingleQxlPci(false);
for (GraphicsDevice graphicsDevice : graphicsDevices) {
vm.getManagedVmDeviceMap().put(graphicsDevice.getDeviceId(), graphicsDevice);
}
VmDevice consoleDevice = VdsBrokerObjectsBuilder.buildConsoleDevice(vmStruct, vm.getId());
if (consoleDevice != null) {
vm.getManagedVmDeviceMap().put(consoleDevice.getDeviceId(), consoleDevice);
}
importHostedEngineVm(vm);
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class GetGraphicsDevicesQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
List<GraphicsDevice> result = new LinkedList<>();
// we must use getVmDeviceByVmIdTypeAndDevice since it supports user filtering
List<VmDevice> spiceDevs = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(getParameters().getId(), VmDeviceGeneralType.GRAPHICS, VmDeviceType.SPICE.getName(), getUserID(), getParameters().isFiltered());
if (spiceDevs != null && !spiceDevs.isEmpty()) {
result.add(new GraphicsDevice(spiceDevs.get(0)));
}
List<VmDevice> vncDevs = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(getParameters().getId(), VmDeviceGeneralType.GRAPHICS, VmDeviceType.VNC.getName(), getUserID(), getParameters().isFiltered());
if (vncDevs != null && !vncDevs.isEmpty()) {
result.add(new GraphicsDevice(vncDevs.get(0)));
}
setReturnValue(result);
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice 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();
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice 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;
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class UpdateVmCommandTest method mockGraphicsDevice.
private void mockGraphicsDevice() {
VmDevice graphicsDevice = new GraphicsDevice(VmDeviceType.SPICE);
graphicsDevice.setDeviceId(Guid.Empty);
graphicsDevice.setVmId(vm.getId());
mockVmDevice(graphicsDevice);
}
Aggregations