use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class InstanceTypeManager method updateDefaultDisplayRelatedFields.
protected void updateDefaultDisplayRelatedFields(final VmBase vmBase) {
// Update display protocol selected item
final Collection<DisplayType> displayTypes = model.getDisplayType().getItems();
if (displayTypes == null || displayTypes.isEmpty()) {
return;
}
// graphics
Frontend.getInstance().runQuery(QueryType.GetGraphicsDevices, new IdQueryParameters(vmBase.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
deactivate();
List<GraphicsDevice> graphicsDevices = returnValue.getReturnValue();
model.getIsHeadlessModeEnabled().setEntity(vmBase.getDefaultDisplayType() == DisplayType.none);
// select display protocol
// first by default
DisplayType displayProtocol = displayTypes.iterator().next();
if (displayTypes.contains(vmBase.getDefaultDisplayType())) {
// if display types contain DT of a vm, pick this one
displayProtocol = vmBase.getDefaultDisplayType();
}
maybeSetSelectedItem(model.getDisplayType(), displayProtocol);
Set<GraphicsType> graphicsTypes = new HashSet<>();
for (GraphicsDevice graphicsDevice : graphicsDevices) {
graphicsTypes.add(graphicsDevice.getGraphicsType());
}
UnitVmModel.GraphicsTypes selected = UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsTypes);
if (selected != null && getModel().getGraphicsType().getItems().contains(selected)) {
maybeSetSelectedItem(getModel().getGraphicsType(), selected);
}
maybeSetSelectedItem(model.getNumOfMonitors(), vmBase.getNumOfMonitors());
maybeSetSelectedItem(model.getUsbPolicy(), vmBase.getUsbPolicy());
maybeSetEntity(model.getIsSmartcardEnabled(), vmBase.isSmartcardEnabled());
maybeSetSingleQxlPci(vmBase);
activate();
}));
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class VmDeviceCommonUtils method addGraphicsDevice.
public static void addGraphicsDevice(VmBase vmBase, VmDeviceType vmDeviceType) {
GraphicsDevice graphicsDevice = new GraphicsDevice(vmDeviceType);
graphicsDevice.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId()));
vmBase.getManagedDeviceMap().put(graphicsDevice.getDeviceId(), graphicsDevice);
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class GetGraphicsDevicesMultipleQuery method mapDevices.
private void mapDevices(Map<Guid, List<GraphicsDevice>> result, VmDeviceType type, List<Guid> vmsIds) {
log.debug("Retrieving graphics devices '{}' for '{}' vms", type.getName(), vmsIds.size());
List<VmDevice> devicesList = vmDeviceDao.getVmDeviceByTypeAndDevice(vmsIds, VmDeviceGeneralType.GRAPHICS, type.getName(), getUserID(), getParameters().isFiltered());
for (VmDevice device : devicesList) {
result.computeIfAbsent(device.getVmId(), guid -> new ArrayList<>()).add(new GraphicsDevice(device));
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class ImportUtils method updateGraphicsDevices.
/**
* Checks whether imported VM/Template has Graphics devices.
* - If the VM/Template has Video devices and no Graphics devices, this method
* adds compatible graphics device to devices map (This could mean
* the exported VM/Template has been created when we didn't have Graphics
* devices).
* - If the VM/Template has no Video devices, no Graphics devices are added
* (we assume headless VM/Template).
*/
public void updateGraphicsDevices(VmBase vmBase, Version clusterVersion) {
if (vmBase == null || vmBase.getManagedDeviceMap() == null || clusterVersion == null) {
return;
}
if (Version.v4_0.lessOrEquals(clusterVersion)) {
if (removeVideoDevice(VmDeviceType.VNC, VmDeviceType.CIRRUS, vmBase.getManagedDeviceMap())) {
vmBase.setDefaultDisplayType(DisplayType.vga);
VmDeviceCommonUtils.addVideoDevice(vmBase);
}
}
List<VmDevice> videoDevs = getDevicesOfType(VmDeviceGeneralType.VIDEO, vmBase.getManagedDeviceMap());
boolean hasNoGraphics = getDevicesOfType(VmDeviceGeneralType.GRAPHICS, vmBase.getManagedDeviceMap()).isEmpty();
if (!videoDevs.isEmpty() && hasNoGraphics) {
GraphicsDevice compatibleGraphics = getCompatibleGraphics(VmDeviceType.getByName(videoDevs.get(0).getDevice()), clusterVersion, vmBase);
if (compatibleGraphics != null) {
vmBase.getManagedDeviceMap().put(compatibleGraphics.getDeviceId(), compatibleGraphics);
}
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class VmHandler method autoSelectGraphicsDevice.
public void autoSelectGraphicsDevice(Guid srcEntityId, VmStatic parametersStaticData, Cluster cluster, Map<GraphicsType, GraphicsDevice> graphicsDevices, Version compatibilityVersion) {
if (// if not set by user in params
graphicsDevices.isEmpty() && cluster != null) {
// and Cluster is known
DisplayType defaultDisplayType = parametersStaticData.getDefaultDisplayType();
int osId = parametersStaticData.getOsId();
List<GraphicsType> sourceGraphics = vmDeviceUtils.getGraphicsTypesOfEntity(srcEntityId);
// otherwise choose the first supported graphics device
if (!vmValidationUtils.isGraphicsAndDisplaySupported(osId, compatibilityVersion, sourceGraphics, defaultDisplayType)) {
GraphicsType defaultGraphicsType = null;
List<Pair<GraphicsType, DisplayType>> pairs = osRepository.getGraphicsAndDisplays(osId, compatibilityVersion);
for (Pair<GraphicsType, DisplayType> pair : pairs) {
if (pair.getSecond().equals(defaultDisplayType)) {
defaultGraphicsType = pair.getFirst();
break;
}
}
if (defaultGraphicsType != null) {
for (GraphicsType graphicsType : GraphicsType.values()) {
// reset graphics devices
graphicsDevices.put(graphicsType, null);
}
VmDeviceType vmDisplayType = defaultGraphicsType.getCorrespondingDeviceType();
GraphicsDevice defaultGraphicsDevice = new GraphicsDevice(vmDisplayType);
graphicsDevices.put(defaultGraphicsType, defaultGraphicsDevice);
}
}
}
}
Aggregations