Search in sources :

Example 11 with VmDevice

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();
    });
}
Also used : UsbPolicy(org.ovirt.engine.core.common.businessentities.UsbPolicy) QueryType(org.ovirt.engine.core.common.queries.QueryType) AsyncDataProvider.getInstance(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider.getInstance) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) HashSet(java.util.HashSet) HwOnlyVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.HwOnlyVmBaseToUnitBuilder) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Collection(java.util.Collection) List(java.util.List) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice)

Example 12 with VmDevice

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());
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) Test(org.junit.Test)

Example 13 with VmDevice

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;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 14 with VmDevice

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;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 15 with VmDevice

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));
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VM(org.ovirt.engine.core.common.businessentities.VM) Pair(org.ovirt.engine.core.common.utils.Pair)

Aggregations

VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)170 HashMap (java.util.HashMap)59 Guid (org.ovirt.engine.core.compat.Guid)53 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)48 ArrayList (java.util.ArrayList)34 Map (java.util.Map)33 VM (org.ovirt.engine.core.common.businessentities.VM)29 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)28 List (java.util.List)26 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)21 VmDeviceGeneralType (org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType)21 VmDeviceType (org.ovirt.engine.core.common.utils.VmDeviceType)20 Collections (java.util.Collections)19 Test (org.junit.Test)19 Collectors (java.util.stream.Collectors)18 Arrays (java.util.Arrays)17 Optional (java.util.Optional)17 StringUtils (org.apache.commons.lang.StringUtils)17 HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)17 Inject (javax.inject.Inject)16