use of org.ovirt.engine.core.common.businessentities.DisplayType in project ovirt-engine by oVirt.
the class NewTemplateVmModelBehavior method initTemplate.
private void initTemplate() {
// Update model state according to VM properties.
buildModel(this.vm.getStaticData(), (source, destination) -> {
updateSelectedCdImage(vm.getStaticData());
updateTimeZone(vm.getTimeZone());
updateConsoleDevice(vm.getId());
getModel().getStorageDomain().setIsChangeable(true);
getModel().getProvisioning().setIsAvailable(false);
// Select display protocol.
DisplayType displayType = vm.getDefaultDisplayType();
if (getModel().getDisplayType().getItems().contains(displayType)) {
getModel().getDisplayType().setSelectedItem(displayType);
}
initPriority(vm.getPriority());
});
}
use of org.ovirt.engine.core.common.businessentities.DisplayType in project ovirt-engine by oVirt.
the class TemplateVmModelBehavior method initTemplate.
private void initTemplate() {
// Update model state according to VM properties.
buildModel(template, (source, destination) -> {
updateTimeZone(template.getTimeZone());
// Storage domain and provisioning are not available for an existing VM.
getModel().getStorageDomain().setIsChangeable(false);
getModel().getProvisioning().setIsAvailable(false);
// Select display protocol.
DisplayType displayType = template.getDefaultDisplayType();
if (getModel().getDisplayType().getItems().contains(displayType)) {
getModel().getDisplayType().setSelectedItem(displayType);
}
updateConsoleDevice(template.getId());
toggleAutoSetVmHostname();
getModel().getVmInitEnabled().setEntity(template.getVmInit() != null);
getModel().getVmInitModel().init(template);
getModel().getTemplateVersionName().setEntity(template.getTemplateVersionName());
getModel().getBootMenuEnabled().setEntity(template.isBootMenuEnabled());
getModel().getSpiceFileTransferEnabled().setEntity(template.isSpiceFileTransferEnabled());
getModel().getSpiceCopyPasteEnabled().setEntity(template.isSpiceCopyPasteEnabled());
getModel().getMigrationMode().setSelectedItem(template.getMigrationSupport());
initPriority(template.getPriority());
getModel().updateResumeBehavior();
});
}
use of org.ovirt.engine.core.common.businessentities.DisplayType 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.DisplayType in project ovirt-engine by oVirt.
the class VmHandler method autoSelectDefaultDisplayType.
/**
* Automatic selection of display type based on its graphics types in parameters.
* This method preserves backward compatibility for REST API - legacy REST API doesn't allow to set display and
* graphics separately.
*/
public void autoSelectDefaultDisplayType(Guid srcEntityId, VmBase parametersStaticData, Cluster cluster, Map<GraphicsType, GraphicsDevice> graphicsDevices) {
if (parametersStaticData.getOsId() == OsRepository.AUTO_SELECT_OS) {
return;
}
List<Pair<GraphicsType, DisplayType>> graphicsAndDisplays = osRepository.getGraphicsAndDisplays(parametersStaticData.getOsId(), CompatibilityVersionUtils.getEffective(parametersStaticData, cluster));
if (parametersStaticData.getDefaultDisplayType() != null && (parametersStaticData.getDefaultDisplayType() == DisplayType.none || isDisplayTypeSupported(parametersStaticData.getDefaultDisplayType(), graphicsAndDisplays))) {
return;
}
DisplayType defaultDisplayType = null;
// map holding display type -> set of supported graphics types for this display type
Map<DisplayType, Set<GraphicsType>> displayGraphicsSupport = new LinkedHashMap<>();
for (Pair<GraphicsType, DisplayType> graphicsAndDisplay : graphicsAndDisplays) {
DisplayType display = graphicsAndDisplay.getSecond();
if (!displayGraphicsSupport.containsKey(display)) {
displayGraphicsSupport.put(display, new HashSet<>());
}
displayGraphicsSupport.get(display).add(graphicsAndDisplay.getFirst());
}
for (Map.Entry<DisplayType, Set<GraphicsType>> entry : displayGraphicsSupport.entrySet()) {
final List<GraphicsType> graphicsTypes = vmDeviceUtils.getGraphicsTypesOfEntity(srcEntityId);
final Set<GraphicsType> resultingVmGraphics = getResultingVmGraphics(graphicsTypes, graphicsDevices);
if (entry.getValue().containsAll(resultingVmGraphics)) {
defaultDisplayType = entry.getKey();
break;
}
}
if (defaultDisplayType == null) {
if (!displayGraphicsSupport.isEmpty()) {
// when not found otherwise, let's take osinfo's record as the default
Map.Entry<DisplayType, Set<GraphicsType>> entry = displayGraphicsSupport.entrySet().iterator().next();
defaultDisplayType = entry.getKey();
} else {
// no osinfo record
defaultDisplayType = DisplayType.qxl;
}
}
parametersStaticData.setDefaultDisplayType(defaultDisplayType);
}
use of org.ovirt.engine.core.common.businessentities.DisplayType in project ovirt-engine by oVirt.
the class LibvirtVmXmlBuilder method overrideDevicesForRunOnce.
private List<VmDevice> overrideDevicesForRunOnce(List<VmDevice> devices) {
if (!vm.isRunOnce()) {
return devices;
}
// video device handling
DisplayType displayType = vm.getDefaultDisplayType();
if (displayType != null) {
// remove existing video device
devices = devices.stream().filter(dev -> dev.getType() != VmDeviceGeneralType.VIDEO).collect(Collectors.toList());
// add new video device
if (displayType != DisplayType.none) {
devices.add(vmInfoBuildUtils.createVideoDeviceByDisplayType(displayType, vm.getId()));
}
}
// graphics device handling
if (displayType == DisplayType.none || (vm.getGraphicsInfos() != null && !vm.getGraphicsInfos().isEmpty())) {
// remove existing graphics devices
devices = devices.stream().filter(dev -> dev.getType() != VmDeviceGeneralType.GRAPHICS).collect(Collectors.toList());
if (displayType != DisplayType.none) {
// add new graphics devices
Map<GraphicsType, GraphicsInfo> infos = vm.getGraphicsInfos();
Map<String, Object> specParamsFromVm = new HashMap<>();
vmInfoBuildUtils.addVmGraphicsOptions(infos, specParamsFromVm, vm);
devices.addAll(vmInfoBuildUtils.createGraphicsDevices(infos, specParamsFromVm, vm.getId()));
}
}
// the user may specify floppy path while there is no device in the database
if (!StringUtils.isEmpty(vm.getFloppyPath()) && devices.stream().noneMatch(dev -> dev.getDevice().equals(VmDeviceType.FLOPPY.getName()))) {
devices.add(vmInfoBuildUtils.createFloppyDevice(vm));
}
return devices;
}
Aggregations