Search in sources :

Example 16 with VmDevice

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

the class DiskValidatorTest method prepareForCheckingIfDiskPluggedToVmsThatAreNotDown.

public List<Pair<VM, VmDevice>> prepareForCheckingIfDiskPluggedToVmsThatAreNotDown() {
    VM vm1 = createVM();
    VM vm2 = createVM();
    VmDevice device1 = createVmDeviceForDisk(vm1, disk);
    VmDevice device2 = createVmDeviceForDisk(vm1, disk);
    List<Pair<VM, VmDevice>> vmsInfo = new LinkedList<>();
    vmsInfo.add(new Pair<>(vm1, device1));
    vmsInfo.add(new Pair<>(vm2, device2));
    return vmsInfo;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VM(org.ovirt.engine.core.common.businessentities.VM) LinkedList(java.util.LinkedList) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 17 with VmDevice

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

the class OvfManagerTest method testVmOvfCreationDefaultGraphicsDeviceFallbackToSupported.

@Test
public void testVmOvfCreationDefaultGraphicsDeviceFallbackToSupported() throws Exception {
    VM vm = createVM();
    vm.setDefaultDisplayType(DisplayType.cirrus);
    vm.setVmOs(EXISTING_OS_ID);
    String xml = manager.exportVm(vm, new FullEntityOvfData(vm), Version.getLast());
    assertNotNull(xml);
    final VM newVm = new VM();
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(newVm);
    manager.importVm(xml, newVm, fullEntityOvfData);
    int graphicsDeviceCount = 0;
    for (VmDevice device : newVm.getManagedVmDeviceMap().values()) {
        if (device.getType() == VmDeviceGeneralType.GRAPHICS) {
            graphicsDeviceCount++;
            assertEquals(device.getDevice(), VmDeviceType.SPICE.getName());
        }
    }
    assertEquals(1, graphicsDeviceCount);
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VM(org.ovirt.engine.core.common.businessentities.VM) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) Test(org.junit.Test)

Example 18 with VmDevice

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

the class VmDevicesMonitoringTest method testIgnoreOutdatedUpdateDevice.

@Test
public void testIgnoreOutdatedUpdateDevice() {
    initDevices();
    initDumpXmls();
    vmDevicesMonitoring.initDevicesStatuses(1L);
    VmDevicesMonitoring.Change change = vmDevicesMonitoring.createChange(3L);
    VmDevice device = getVmDevice(CDROM_DEVICE_ID, VM_ID, VmDeviceGeneralType.DISK, "cdrom", true);
    change.updateDevice(device);
    change.flush();
    initDevices(device);
    change = vmDevicesMonitoring.createChange(2L);
    change.updateDevice(device);
    change.flush();
    verify(resourceManager, never()).runVdsCommand(eq(VDSCommandType.DumpXmls), any());
    verify(vmDeviceDao, never()).updateAllInBatch(any());
    verify(vmDeviceDao, never()).removeAll(any());
    verify(vmDeviceDao, times(1)).saveAll(any());
    verify(vmDynamicDao, never()).updateDevicesHashes(any());
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) Test(org.junit.Test)

Example 19 with VmDevice

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

the class VmInfoBuildUtilsTest method setUp.

@Before
public void setUp() {
    injectorRule.bind(AuditLogDirector.class, auditLogDirector);
    diskImage.setDiskProfileId(Guid.newGuid());
    qos = new StorageQos();
    qos.setId(Guid.newGuid());
    vmDevice = new VmDevice();
    VnicProfile vnicProfile = new VnicProfile();
    vnicProfile.setNetworkFilterId(NETWORK_FILTER_ID);
    when(vnicProfileDao.get(VNIC_PROFILE_ID)).thenReturn(vnicProfile);
    NetworkFilter networkFilter = new NetworkFilter();
    networkFilter.setName(NETWORK_FILTER_NAME);
    when(networkFilterDao.getNetworkFilterById(NETWORK_FILTER_ID)).thenReturn(networkFilter);
    when(vmNicFilterParameterDao.getAllForVmNic(VM_NIC_ID)).thenReturn(createVmNicFilterParameters());
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) Before(org.junit.Before)

Example 20 with VmDevice

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

the class VmInfoBuilderImpl method buildCloudInitVmPayload.

@Override
public void buildCloudInitVmPayload(Map<String, byte[]> cloudInitContent) {
    VmDevice vmDevice = vmInfoBuildUtils.createCloudInitPayloadDevice(cloudInitContent, vm);
    Map<String, Object> struct = vmInfoBuildUtils.buildCdDetails(vmDevice, vm);
    addDevice(struct, vmDevice, "");
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice)

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