use of org.ovirt.engine.core.common.businessentities.GraphicsType in project ovirt-engine by oVirt.
the class DisplayHelper method setGraphicsToParams.
/**
* Set data about graphics from (REST) Template to parameters.
*
* @param display - display that contains graphics data
* @param params - parameters to be updated with graphics data
*/
public static void setGraphicsToParams(Display display, HasGraphicsDevices params) {
if (display != null && display.isSetType()) {
DisplayType newDisplayType = display.getType();
if (newDisplayType != null) {
for (GraphicsType graphicsType : GraphicsType.values()) {
// reset graphics devices
params.getGraphicsDevices().put(graphicsType, null);
}
GraphicsType newGraphicsType = DisplayMapper.map(newDisplayType, null);
params.getGraphicsDevices().put(newGraphicsType, new GraphicsDevice(newGraphicsType.getCorrespondingDeviceType()));
}
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method updateGraphicsInfoFromConf.
/**
* Updates graphics runtime information according to vm.conf vdsm structure. It's used with legacy VDSMs that have
* no notion about graphics device.
* @param vm - VmDynamic to update
* @param struct - data from VDSM
*/
private static void updateGraphicsInfoFromConf(VmDynamic vm, Map<String, Object> struct) {
GraphicsType vmGraphicsType = parseGraphicsType(struct);
if (vmGraphicsType == null) {
log.debug("graphics data missing in XML.");
return;
}
GraphicsInfo graphicsInfo = new GraphicsInfo();
if (struct.containsKey(VdsProperties.display_port)) {
try {
graphicsInfo.setPort(Integer.parseInt(struct.get(VdsProperties.display_port).toString()));
} catch (NumberFormatException e) {
log.error("vm display_port value illegal : {0}", struct.get(VdsProperties.display_port));
}
} else if (struct.containsKey(VdsProperties.display)) {
try {
graphicsInfo.setPort(VNC_START_PORT + Integer.parseInt(struct.get(VdsProperties.display).toString()));
} catch (NumberFormatException e) {
log.error("vm display value illegal : {0}", struct.get(VdsProperties.display));
}
}
if (struct.containsKey(VdsProperties.display_secure_port)) {
try {
graphicsInfo.setTlsPort(Integer.parseInt(struct.get(VdsProperties.display_secure_port).toString()));
} catch (NumberFormatException e) {
log.error("vm display_secure_port value illegal : {0}", struct.get(VdsProperties.display_secure_port));
}
}
if (struct.containsKey(VdsProperties.displayIp)) {
graphicsInfo.setIp((String) struct.get(VdsProperties.displayIp));
}
vm.getGraphicsInfos().put(vmGraphicsType, graphicsInfo);
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType in project ovirt-engine by oVirt.
the class UpdateVmTemplateCommand method updateGraphicsDevice.
private void updateGraphicsDevice() {
for (GraphicsType type : getParameters().getGraphicsDevices().keySet()) {
GraphicsDevice vmGraphicsDevice = getGraphicsDevOfType(type);
if (vmGraphicsDevice == null) {
if (getParameters().getGraphicsDevices().get(type) != null) {
getParameters().getGraphicsDevices().get(type).setVmId(getVmTemplateId());
GraphicsParameters parameters = new GraphicsParameters(getParameters().getGraphicsDevices().get(type));
parameters.setVm(false);
backend.runInternalAction(ActionType.AddGraphicsDevice, parameters);
}
} else {
if (getParameters().getGraphicsDevices().get(type) == null) {
GraphicsParameters parameters = new GraphicsParameters(vmGraphicsDevice);
parameters.setVm(false);
backend.runInternalAction(ActionType.RemoveGraphicsDevice, parameters);
} else {
getParameters().getGraphicsDevices().get(type).setVmId(getVmTemplateId());
GraphicsParameters parameters = new GraphicsParameters(getParameters().getGraphicsDevices().get(type));
parameters.setVm(false);
backend.runInternalAction(ActionType.UpdateGraphicsDevice, parameters);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType in project ovirt-engine by oVirt.
the class ProcessDownVmCommand method createUpdateVmParameters.
private VmManagementParametersBase createUpdateVmParameters() {
// clear non updateable fields got from config
getVm().setExportDate(null);
getVm().setOvfVersion(null);
VmManagementParametersBase updateVmParams = new VmManagementParametersBase(getVm());
updateVmParams.setUpdateWatchdog(true);
updateVmParams.setSoundDeviceEnabled(false);
updateVmParams.setBalloonEnabled(false);
updateVmParams.setVirtioScsiEnabled(false);
updateVmParams.setClearPayload(true);
updateVmParams.setUpdateRngDevice(true);
for (GraphicsType graphicsType : GraphicsType.values()) {
updateVmParams.getGraphicsDevices().put(graphicsType, null);
}
for (VmDevice device : getVm().getManagedVmDeviceMap().values()) {
switch(device.getType()) {
case WATCHDOG:
updateVmParams.setWatchdog(new VmWatchdog(device));
break;
case SOUND:
updateVmParams.setSoundDeviceEnabled(true);
break;
case BALLOON:
updateVmParams.setBalloonEnabled(true);
break;
case CONTROLLER:
if (VmDeviceType.VIRTIOSCSI.getName().equals(device.getDevice())) {
updateVmParams.setVirtioScsiEnabled(true);
}
break;
case DISK:
if (VmPayload.isPayload(device.getSpecParams())) {
updateVmParams.setVmPayload(new VmPayload(device));
}
break;
case CONSOLE:
updateVmParams.setConsoleEnabled(true);
break;
case RNG:
updateVmParams.setRngDevice(new VmRngDevice(device));
break;
case GRAPHICS:
updateVmParams.getGraphicsDevices().put(GraphicsType.fromString(device.getDevice()), new GraphicsDevice(device));
break;
default:
}
}
// clear these fields as these are non updatable
getVm().getManagedVmDeviceMap().clear();
getVm().getUnmanagedDeviceList().clear();
return updateVmParams;
}
use of org.ovirt.engine.core.common.businessentities.GraphicsType 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();
}
}
Aggregations