use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class ExistingNonClusterModelBehavior method doBuild.
public void doBuild() {
buildModel(entity, (source, destination) -> {
Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(entity.getId()), new AsyncQuery<>((QueryReturnValue returnValue) -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), entity.getId());
getInstance().getWatchdogByVmId(new AsyncQuery<QueryReturnValue>(returnValue -> {
@SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
for (VmWatchdog watchdog : watchdogs) {
getModel().getWatchdogAction().setSelectedItem(watchdog.getAction());
getModel().getWatchdogModel().setSelectedItem(watchdog.getModel());
}
}), entity.getId());
Frontend.getInstance().runQuery(QueryType.GetRngDevice, new IdQueryParameters(entity.getId()), new AsyncQuery<QueryReturnValue>(returnValue -> {
List<VmDevice> rngDevices = returnValue.getReturnValue();
getModel().getIsRngEnabled().setEntity(!rngDevices.isEmpty());
if (!rngDevices.isEmpty()) {
VmRngDevice rngDevice = new VmRngDevice(rngDevices.get(0));
getModel().setRngDevice(rngDevice);
}
}));
getModel().getEmulatedMachine().setSelectedItem(entity.getCustomEmulatedMachine());
getModel().getCustomCpu().setSelectedItem(entity.getCustomCpuName());
getModel().getMigrationMode().setSelectedItem(entity.getMigrationSupport());
postBuild();
});
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class GetWatchdogQueryTest method executeQueryCommandWithWatchdog.
@Test
public void executeQueryCommandWithWatchdog() {
Map<String, Object> watchdogSpecParams = new HashMap<>();
watchdogSpecParams.put("model", "i6300esb");
watchdogSpecParams.put("action", "reset");
VmDevice vmDevice = new VmDevice(new VmDeviceId(new Guid("6f86b8a4-e721-4149-b2df-056eb621b16a"), TEST_VM_ID), VmDeviceGeneralType.WATCHDOG, VmDeviceType.WATCHDOG.getName(), "", watchdogSpecParams, true, true, true, "", null, null, null);
when(vmDeviceDao.getVmDeviceByVmIdAndType(TEST_VM_ID, VmDeviceGeneralType.WATCHDOG)).thenReturn(Collections.singletonList(vmDevice));
getQuery().executeQueryCommand();
List<VmWatchdog> result = getQuery().getQueryReturnValue().getReturnValue();
assertNotNull(result);
assertFalse(result.isEmpty());
VmWatchdog watchdog = result.get(0);
assertEquals("reset", watchdog.getAction().name().toLowerCase());
assertEquals("i6300esb", watchdog.getModel().name().toLowerCase());
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class DiskImagesValidatorTest method createVmDeviceForDisk.
private VmDevice createVmDeviceForDisk(DiskImage disk) {
VmDevice device = new VmDevice();
device.setId(new VmDeviceId(null, disk.getId()));
return device;
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class DiskValidatorTest method createVmDeviceForDisk.
private VmDevice createVmDeviceForDisk(VM vm, Disk disk) {
VmDevice device = new VmDevice();
device.setId(new VmDeviceId(vm.getId(), disk.getId()));
device.setSnapshotId(null);
device.setPlugged(true);
return device;
}
use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.
the class DiskValidatorTest method testDiskAttachedToAnyNonDownVMWithProblems.
private void testDiskAttachedToAnyNonDownVMWithProblems(boolean checkOnlyPlugged, String expectedNames) {
VM vmPausedPlugged = createVM();
vmPausedPlugged.setName("vmPausedPlugged");
vmPausedPlugged.setStatus(VMStatus.Paused);
VmDevice device1 = new VmDevice();
device1.setPlugged(true);
Pair<VM, VmDevice> pair1 = new Pair<>(vmPausedPlugged, device1);
VM vmDownPlugged = createVM();
vmDownPlugged.setName("vmDownPlugged");
VmDevice device2 = new VmDevice();
device2.setPlugged(true);
Pair<VM, VmDevice> pair2 = new Pair<>(vmDownPlugged, device2);
VM vmRunningUnplugged = createVM();
vmRunningUnplugged.setName("vmRunningUnplugged");
vmRunningUnplugged.setStatus(VMStatus.Up);
VmDevice device3 = new VmDevice();
device3.setPlugged(false);
Pair<VM, VmDevice> pair3 = new Pair<>(vmRunningUnplugged, device3);
VM anotherPausedPlugged = createVM();
anotherPausedPlugged.setName("anotherPausedPlugged");
anotherPausedPlugged.setStatus(VMStatus.Paused);
VmDevice device4 = new VmDevice();
device4.setPlugged(true);
Pair<VM, VmDevice> pair4 = new Pair<>(anotherPausedPlugged, device4);
VM runningSnapshotPlugged = createVM();
runningSnapshotPlugged.setName("runningSnapshotPlugged");
runningSnapshotPlugged.setStatus(VMStatus.Up);
VmDevice device5 = new VmDevice();
device5.setPlugged(true);
device5.setSnapshotId(Guid.newGuid());
Pair<VM, VmDevice> pair5 = new Pair<>(runningSnapshotPlugged, device5);
List<Pair<VM, VmDevice>> vmList = Arrays.asList(pair1, pair2, pair3, pair4, pair5);
when(vmDao.getVmsWithPlugInfo(any())).thenReturn(vmList);
String[] expectedReplacements = { ReplacementUtils.createSetVariableString(DiskValidator.DISK_NAME_VARIABLE, disk.getDiskAlias()), ReplacementUtils.createSetVariableString(DiskValidator.VM_LIST, expectedNames) };
assertThat(validator.isDiskPluggedToAnyNonDownVm(checkOnlyPlugged), failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_PLUGGED_TO_NON_DOWN_VMS, expectedReplacements));
}
Aggregations