use of org.ovirt.engine.core.common.businessentities.GraphicsDevice 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.GraphicsDevice 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.GraphicsDevice in project ovirt-engine by oVirt.
the class BackendInstanceTypeGraphicsConsolesResource method add.
@Override
public Response add(GraphicsConsole console) {
GraphicsDevice device = getMapper(GraphicsConsole.class, GraphicsDevice.class).map(console, null);
device.setVmId(guid);
ActionReturnValue res = doCreateEntity(ActionType.AddGraphicsAndVideoDevices, createAddGraphicsDeviceParams(device));
if (res != null && res.getSucceeded()) {
return BackendGraphicsConsoleHelper.find(console, this::list);
}
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class BackendGraphicsConsoleHelper method remove.
public static Response remove(BackendResource resource, Guid guid, String consoleId) {
List<GraphicsDevice> devices = DisplayHelper.getGraphicsDevicesForEntity(resource, guid, false);
if (devices == null) {
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
org.ovirt.engine.core.common.businessentities.GraphicsType graphicsType = asGraphicsType(consoleId);
return devices.stream().filter(device -> device.getGraphicsType().equals(graphicsType)).findFirst().map(device -> resource.performAction(ActionType.RemoveGraphicsAndVideoDevices, new GraphicsParameters(device))).orElseThrow(() -> new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()));
}
use of org.ovirt.engine.core.common.businessentities.GraphicsDevice in project ovirt-engine by oVirt.
the class AddUnmanagedVmsCommand method extractGraphicsDevices.
private List<GraphicsDevice> extractGraphicsDevices(Guid vmId, Object[] devices) {
List<GraphicsDevice> graphicsDevices = new ArrayList<>();
for (Object o : devices) {
Map device = (Map<String, Object>) o;
String deviceName = (String) device.get(VdsProperties.Device);
if (graphicsDeviceTypes.contains(deviceName)) {
GraphicsDevice graphicsDevice = new GraphicsDevice(VmDeviceType.valueOf(deviceName.toUpperCase()));
graphicsDevice.setVmId(vmId);
graphicsDevice.setDeviceId(Guid.newGuid());
graphicsDevice.setManaged(true);
graphicsDevices.add(graphicsDevice);
}
}
return graphicsDevices;
}
Aggregations