use of org.ovirt.engine.core.common.businessentities.VmDevice 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.VmDevice in project ovirt-engine by oVirt.
the class RemoveGraphicsAndVideoDevicesCommand method executeCommand.
@Override
protected void executeCommand() {
VmDevice graphicsDev = getParameters().getDev();
vmDeviceDao.remove(graphicsDev.getId());
if (noGraphicsDevicesLeft()) {
vmDeviceUtils.removeVideoDevices(getVmBaseId());
// Since getParameters().isVm() isn't set by REST api, try to set VM and if failed then try to set Template
if (!setVmToHeadlessMode()) {
setTemplateToHeadlessMode();
}
}
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class RemoveGraphicsDeviceCommand method executeCommand.
@Override
protected void executeCommand() {
VmDevice graphicsDev = getParameters().getDev();
vmDeviceDao.remove(graphicsDev.getId());
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class ActivateDeactivateVmNicCommand method searchForDuplicatesWithExistingVmDevices.
private boolean searchForDuplicatesWithExistingVmDevices(VmDevice vmDeviceToHotplug) {
String deviceAddress = vmDeviceToHotplug.getAddress();
if (StringUtils.isEmpty(deviceAddress)) {
return false;
}
Map<String, String> addressMapToHotplug = StringMapUtils.string2Map(deviceAddress);
List<VmDevice> allVmDevices = vmDeviceDao.getVmDeviceByVmId(getVm().getId());
for (VmDevice vmDevice : allVmDevices) {
if (!vmDeviceToHotplug.getId().equals(vmDevice.getId())) {
Map<String, String> deviceAddressMap = StringMapUtils.string2Map(vmDevice.getAddress());
boolean duplicatedAddress = deviceAddressMap.equals(addressMapToHotplug);
boolean ambiguousInterfaceState = StringUtils.isEmpty(vmDevice.getAddress()) && vmDevice.isPlugged() && VmDeviceGeneralType.INTERFACE.equals(vmDevice.getType());
if (duplicatedAddress || ambiguousInterfaceState) {
return true;
}
}
}
return false;
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class AddVmInterfaceCommand method addInterfaceDeviceToDb.
private void addInterfaceDeviceToDb() {
VmDevice vmDevice = getVmDeviceUtils().addInterface(getParameters().getVmId(), getInterface().getId(), getInterface().isPlugged(), getInterface().isPassthrough());
getCompensationContext().snapshotNewEntity(vmDevice);
}
Aggregations