use of org.ovirt.engine.core.common.businessentities.VmBase in project ovirt-engine by oVirt.
the class VmDeviceUtils method addImportedOtherDevices.
/**
* Add other managed and unmanaged devices to imported VM or template.
*
* @param vmDeviceToAdd list of devices to be added to the DB
* @param withMemory true ~ devices are being added to a VM that is imported from snapshot with memory
*/
private void addImportedOtherDevices(VmBase vmBase, List<VmDevice> vmDeviceToAdd, boolean withMemory) {
boolean hasCd = false;
for (VmDevice vmDevice : vmBase.getManagedDeviceMap().values()) {
switch(vmDevice.getType()) {
case DISK:
if (VmDeviceType.CDROM.getName().equals(vmDevice.getDevice())) {
hasCd = true;
} else {
// disks are added separately
continue;
}
break;
case INTERFACE:
// network interfaces are added separately
continue;
case VIDEO:
vmDevice.setSpecParams(getVideoDeviceSpecParams(vmBase));
break;
case HOSTDEV:
// it is currently unsafe to import host devices, due to possibility of invalid dedicatedVmForVds
continue;
}
vmDevice.setManaged(true);
vmDeviceToAdd.add(vmDevice);
}
if (!hasCd) {
// add an empty CD
addCdDevice(vmBase.getId());
}
// add unmanaged devices
final List<VmDevice> unmanagedDevicesToAdd = vmBase.getUnmanagedDeviceList().stream().filter(device -> !VmDeviceCommonUtils.isMemory(device) || withMemory).collect(Collectors.toList());
vmDeviceToAdd.addAll(unmanagedDevicesToAdd);
}
use of org.ovirt.engine.core.common.businessentities.VmBase in project ovirt-engine by oVirt.
the class VmDeviceUtils method updateVmDevices.
/**
* Update the VM devices according to the changes made.
*
* @param params changes made
* @param oldVm previous state of the VM being modified
*/
public void updateVmDevices(VmManagementParametersBase params, VM oldVm, Supplier<Cluster> clusterSupplier) {
VmBase oldVmBase = oldVm.getStaticData();
VmBase newVmBase = params.getVmStaticData();
if (newVmBase == null) {
return;
}
updateCdPath(oldVmBase, newVmBase);
updateVideoDevices(oldVmBase, newVmBase);
updateUsbSlots(oldVmBase, newVmBase, clusterSupplier);
updateMemoryBalloon(newVmBase.getId(), params.isBalloonEnabled());
updateSoundDevice(oldVmBase, newVmBase, oldVm.getCompatibilityVersion(), params.isSoundDeviceEnabled());
updateSmartcardDevice(oldVm, newVmBase);
updateConsoleDevice(newVmBase.getId(), params.isConsoleEnabled());
updateVirtioScsiController(newVmBase, params.isVirtioScsiEnabled());
}
use of org.ovirt.engine.core.common.businessentities.VmBase in project ovirt-engine by oVirt.
the class CpuProfileHelperTest method testDifferentClusters.
@Test
public void testDifferentClusters() {
VmBase vmBase = createVmBase(cpuProfile1.getId());
vmBase.setClusterId(Guid.newGuid());
ValidationResult res = cpuProfileHelper.setAndValidateCpuProfile(vmBase, USER_1_ID);
assertThat(res, failsWith(EngineMessage.ACTION_TYPE_CPU_PROFILE_NOT_MATCH_CLUSTER));
}
use of org.ovirt.engine.core.common.businessentities.VmBase in project ovirt-engine by oVirt.
the class CpuProfileHelperTest method testNoPermission.
@Test
public void testNoPermission() {
VmBase vmBase = createVmBase(cpuProfile2.getId());
ValidationResult res = cpuProfileHelper.setAndValidateCpuProfile(vmBase, USER_1_ID);
assertThat(res, failsWith(EngineMessage.ACTION_TYPE_NO_PERMISSION_TO_ASSIGN_CPU_PROFILE));
}
use of org.ovirt.engine.core.common.businessentities.VmBase in project ovirt-engine by oVirt.
the class CpuProfileHelperTest method createVmBase.
private VmBase createVmBase(Guid cpuProfileId) {
VmBase vmBase = new VmBase();
vmBase.setId(Guid.newGuid());
vmBase.setClusterId(CLUSTER_ID);
vmBase.setCpuProfileId(cpuProfileId);
return vmBase;
}
Aggregations