Search in sources :

Example 71 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class UpdateRngDeviceTest method mockCommand.

private UpdateRngDeviceCommand mockCommand() {
    final VmStatic vmMock = mock(VmStatic.class);
    when(vmMock.getClusterId()).thenReturn(clusterId);
    when(vmDaoMock.get(vmId)).thenReturn(vmMock);
    when(vmDeviceDaoMock.getVmDeviceByVmIdAndType(vmId, VmDeviceGeneralType.RNG)).thenReturn(Collections.singletonList(new VmDevice()));
    final Cluster cluster = mock(Cluster.class);
    when(cluster.getRequiredRngSources()).thenReturn(Collections.singleton(VmRngDevice.Source.RANDOM));
    when(clusterMock.get(clusterId)).thenReturn(cluster);
    cmd.init();
    return cmd;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 72 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class UpdateVmCommandTest method mockGraphicsDevice.

private void mockGraphicsDevice() {
    VmDevice graphicsDevice = new GraphicsDevice(VmDeviceType.SPICE);
    graphicsDevice.setDeviceId(Guid.Empty);
    graphicsDevice.setVmId(vm.getId());
    mockVmDevice(graphicsDevice);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice)

Example 73 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class UpdateWatchdogCommandTest method testValidate.

@Test
public void testValidate() {
    Guid vmGuid = new Guid("a09f57b1-5739-4352-bf88-a6f834ed46db");
    command.getParameters().setId(vmGuid);
    command.getParameters().setAction(VmWatchdogAction.PAUSE);
    command.getParameters().setModel(vmWatchdogType);
    when(vmDaoMock.get(vmGuid)).thenReturn(new VM());
    when(vmDeviceDaoMock.getVmDeviceByVmIdAndType(vmGuid, VmDeviceGeneralType.WATCHDOG)).thenReturn(Collections.singletonList(new VmDevice()));
    VmWatchdog vmWatchdog = spy(new VmWatchdog());
    when(vmWatchdog.getModel()).thenReturn(vmWatchdogType);
    assertTrue(command.validate());
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) Test(org.junit.Test)

Example 74 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class ImportVmCommandTest method addSoundDeviceToVm.

private void addSoundDeviceToVm(VM vm) {
    Guid deviceId = Guid.newGuid();
    Map<String, Object> specParams = new HashMap<>();
    VmDevice sound = new VmDevice(new VmDeviceId(deviceId, vm.getId()), VmDeviceGeneralType.SOUND, "", null, specParams, true, true, true, null, null, null, null);
    vm.getManagedVmDeviceMap().put(deviceId, sound);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 75 with VmDevice

use of org.ovirt.engine.core.common.businessentities.VmDevice in project ovirt-engine by oVirt.

the class ImportVmCommandTest method addBalloonToVm.

void addBalloonToVm(VM vm) {
    Guid deviceId = Guid.newGuid();
    Map<String, Object> specParams = new HashMap<>();
    specParams.put(VdsProperties.Model, VdsProperties.Virtio);
    VmDevice balloon = new VmDevice(new VmDeviceId(deviceId, vm.getId()), VmDeviceGeneralType.BALLOON, VmDeviceType.MEMBALLOON.toString(), null, specParams, true, true, true, null, null, null, null);
    vm.getManagedVmDeviceMap().put(deviceId, balloon);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

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