use of org.ovirt.engine.core.common.businessentities.GraphicsType 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.GraphicsType in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method updateGraphicsInfo.
/**
* Updates graphics runtime information according displayInfo VDSM structure if it exists.
*
* @param vm - VmDynamic to update
* @param struct - data from VDSM
* @return true if displayInfo exists, false otherwise
*/
private static boolean updateGraphicsInfo(VmDynamic vm, Map<String, Object> struct) {
Object displayInfo = struct.get(VdsProperties.displayInfo);
if (displayInfo == null) {
return false;
}
for (Object info : (Object[]) displayInfo) {
Map<String, String> infoMap = (Map<String, String>) info;
GraphicsType graphicsType = GraphicsType.fromString(infoMap.get(VdsProperties.type));
GraphicsInfo graphicsInfo = new GraphicsInfo();
graphicsInfo.setIp(infoMap.get(VdsProperties.ipAddress)).setPort(parseIntegerOrNull(infoMap.get(VdsProperties.port))).setTlsPort(parseIntegerOrNull(infoMap.get(VdsProperties.tlsPort)));
if (graphicsInfo.getPort() != null || graphicsInfo.getTlsPort() != null) {
vm.getGraphicsInfos().put(graphicsType, graphicsInfo);
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method addGraphicsDeviceFromExternalProvider.
/**
* libvirt video: "vga", "cirrus", "vmvga", "xen", "vbox", "qxl"
* ovirt video: "vga", "cirrus", "qxl"
* libvirt grahics: sdl, vnc, spice, rdp or desktop
* ovirt graphics: cirrus, spice, vnc
* try to add the displaytype and graphics if ovirt support the channels
*/
private static void addGraphicsDeviceFromExternalProvider(VmStatic vmStatic, Map<String, Object> struct) {
Object graphicsName = struct.get(VdsProperties.GRAPHICS_DEVICE);
Object videoName = struct.get(VdsProperties.VIDEO_DEVICE);
if (graphicsName == null || videoName == null) {
return;
}
try {
vmStatic.setDefaultDisplayType(DisplayType.valueOf(videoName.toString()));
} catch (IllegalArgumentException ex) {
log.error("Illegal video name '{}'.", videoName.toString());
return;
}
GraphicsType graphicsType = GraphicsType.fromString(graphicsName.toString());
if (graphicsType == null) {
log.error("Illegal graphics name '{}'.", graphicsName.toString());
return;
}
VmDeviceCommonUtils.addGraphicsDevice(vmStatic, graphicsType.getCorrespondingDeviceType());
VmDeviceCommonUtils.addVideoDevice(vmStatic);
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType 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.GraphicsType 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