use of org.ovirt.engine.core.common.businessentities.GraphicsType 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.GraphicsType in project ovirt-engine by oVirt.
the class NonClusterModelBehaviorBase method initDisplayTypes.
protected void initDisplayTypes(DisplayType selected, UnitVmModel.GraphicsTypes selectedGrahicsTypes) {
getModel().getDisplayType().getSelectedItemChangedEvent().addListener((ev, sender, args) -> enableSinglePCI(getModel().getDisplayType().getSelectedItem() == DisplayType.qxl));
List<Pair<GraphicsType, DisplayType>> allGraphicsAndDisplays = new ArrayList<>();
for (GraphicsType graphicsType : GraphicsType.values()) {
for (DisplayType displayType : DisplayType.values()) {
if (displayType != DisplayType.none) {
allGraphicsAndDisplays.add(new Pair<>(graphicsType, displayType));
}
}
}
getModel().initDisplayModels(allGraphicsAndDisplays);
initGraphicsModel(selectedGrahicsTypes);
if (getModel().getDisplayType().getItems().contains(selected)) {
getModel().getDisplayType().setSelectedItem(selected);
}
if (selected == DisplayType.none) {
getModel().getDisplayType().setSelectedItem(DisplayType.qxl);
getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.SPICE);
getModel().getIsHeadlessModeEnabled().setEntity(true);
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType 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);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType in project ovirt-engine by oVirt.
the class CloneVmCommand method setGraphicsDevices.
private void setGraphicsDevices(List<VmDevice> devices) {
for (GraphicsType graphicsType : GraphicsType.values()) {
// prevent copying from the template
getParameters().getGraphicsDevices().put(graphicsType, null);
}
for (VmDevice device : devices) {
if (device.getType() == VmDeviceGeneralType.GRAPHICS) {
GraphicsDevice graphicsDevice = new GraphicsDevice(device);
getParameters().getGraphicsDevices().put(graphicsDevice.getGraphicsType(), graphicsDevice);
}
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType in project ovirt-engine by oVirt.
the class RunVmValidator method getVmActiveGraphics.
private Set<GraphicsType> getVmActiveGraphics() {
if (!vm.getGraphicsInfos().isEmpty()) {
// graphics overriden in runonce
return vm.getGraphicsInfos().keySet();
} else {
List<VmDevice> graphicDevices = DbFacade.getInstance().getVmDeviceDao().getVmDeviceByVmIdAndType(vm.getId(), VmDeviceGeneralType.GRAPHICS);
Set<GraphicsType> graphicsTypes = new HashSet<>();
for (VmDevice graphicDevice : graphicDevices) {
GraphicsType type = GraphicsType.fromString(graphicDevice.getDevice());
graphicsTypes.add(type);
}
return graphicsTypes;
}
}
Aggregations