use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class UpdateVmTemplateInterfaceCommand method executeCommand.
@Override
protected void executeCommand() {
vmNicDao.update(getParameters().getInterface());
VmDevice vmDevice = vmDeviceDao.get(new VmDeviceId(getParameters().getInterface().getId(), getParameters().getVmTemplateId()));
vmDevice.setPlugged(getParameters().getInterface().isPlugged());
vmDevice.setDevice(getParameters().getInterface().isPassthrough() ? VmDeviceType.HOST_DEVICE.getName() : VmDeviceType.BRIDGE.getName());
vmDeviceDao.update(vmDevice);
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class VmDeviceUtils method getVmDevicesForNextRun.
/**
* Returns a map (device ID to VmDevice) of devices that are relevant for next run.
*
* The list of devices is built by examining properties that are annotated with EditableDeviceOnVmStatusField
* annotation.
*
* @param vm the relevant VM
* @param objectWithEditableDeviceFields object that contains properties which are annotated with
* EditableDeviceOnVmStatusField (e.g. parameters file)
* @param vmVideoDeviceTypeforNextRun VM video device type for next run
* @return a map of device ID to VmDevice
*/
public Map<Guid, VmDevice> getVmDevicesForNextRun(VM vm, Object objectWithEditableDeviceFields, DisplayType vmVideoDeviceTypeforNextRun) {
setVmDevices(vm.getStaticData());
Map<Guid, VmDevice> vmManagedDeviceMap = vm.getManagedVmDeviceMap();
List<VmDeviceUpdate> fieldList = vmHandler.getVmDevicesFieldsToUpdateOnNextRun(vm.getId(), vm.getStatus(), objectWithEditableDeviceFields);
// Add the enabled devices and remove the disabled ones
for (VmDeviceUpdate update : fieldList) {
if (update.isEnable()) {
VmDevice device;
if (update.getDevice() == null) {
device = new VmDevice(new VmDeviceId(Guid.newGuid(), vm.getId()), update.getGeneralType(), update.getType().getName(), "", Collections.emptyMap(), true, true, update.isReadOnly(), "", null, null, null);
} else {
device = update.getDevice();
if (device.getVmId() == null) {
device.setVmId(vm.getId());
}
if (device.getDeviceId() == null) {
if (device.getType() == VmDeviceGeneralType.RNG) {
// only one RNG device is allowed per VM
VmDevice rng = VmDeviceCommonUtils.findVmDeviceByType(vmManagedDeviceMap, update.getType());
device.setDeviceId(rng != null ? rng.getDeviceId() : Guid.newGuid());
} else {
device.setDeviceId(Guid.newGuid());
}
}
}
vmManagedDeviceMap.put(device.getDeviceId(), device);
} else {
VmDevice device;
if (update.getType() != VmDeviceType.UNKNOWN) {
device = VmDeviceCommonUtils.findVmDeviceByType(vmManagedDeviceMap, update.getType());
} else {
device = VmDeviceCommonUtils.findVmDeviceByGeneralType(vmManagedDeviceMap, update.getGeneralType());
}
if (device != null) {
vmManagedDeviceMap.remove(device.getDeviceId());
}
}
}
// as all other devices will be done
if (vmVideoDeviceTypeforNextRun == DisplayType.none) {
vmManagedDeviceMap = vmManagedDeviceMap.entrySet().stream().filter(entry -> !entry.getValue().getType().equals(VmDeviceGeneralType.VIDEO)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
} else if (vm.getDefaultDisplayType() == DisplayType.none) {
VmDevice videoDevice = new VmDevice(new VmDeviceId(Guid.newGuid(), vm.getId()), VmDeviceGeneralType.VIDEO, vmVideoDeviceTypeforNextRun.toString(), "", Collections.emptyMap(), true, true, false, "", null, null, null);
vmManagedDeviceMap.put(videoDevice.getDeviceId(), videoDevice);
}
return vmManagedDeviceMap;
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class VmDeviceUtils method enableNormalUsb.
private void enableNormalUsb(VmBase vmBase, ChipsetType chipset) {
final UsbControllerModel controllerModel = getUsbControllerModel(vmBase, chipset);
if (controllerModel == null) {
return;
}
addManagedDevice(new VmDeviceId(Guid.newGuid(), vmBase.getId()), VmDeviceGeneralType.CONTROLLER, VmDeviceType.USB, createUsbControllerSpecParams(controllerModel.libvirtName, 0), true, false);
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class VmValidator method populateDisksWithVmData.
private void populateDisksWithVmData(Collection<? extends Disk> disks, Guid vmId) {
for (Disk disk : disks) {
DiskVmElement dve = getDiskVmElementDao().get(new VmDeviceId(disk.getId(), vmId));
disk.setDiskVmElements(Collections.singletonList(dve));
}
}
use of org.ovirt.engine.core.common.businessentities.VmDeviceId in project ovirt-engine by oVirt.
the class NewDiskModel method initialize.
@Override
public void initialize() {
super.initialize();
setDiskVmElement(new DiskVmElement(new VmDeviceId(null, getIsFloating() ? null : getVm().getId())));
if (!getIsFloating()) {
if (getIsBootable().getIsChangable()) {
getIsBootable().setEntity(true);
}
updateSuggestedDiskAliasFromServer();
getIsPlugged().setIsAvailable(true);
} else {
// Read only disk can be created only in the scope of VM.
getIsReadOnly().setIsAvailable(false);
getIsPlugged().setEntity(false);
getIsBootable().setIsAvailable(false);
getDiskInterface().setIsAvailable(false);
getPassDiscard().setIsAvailable(false);
// set using scsi reservation to be invisible
getIsUsingScsiReservation().setIsAvailable(false);
getIsUsingScsiReservation().setEntity(false);
}
getSizeExtend().setIsAvailable(false);
}
Aggregations