use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class NetworkDeviceHelperImplTest method isVlanDeviceNonNetworkFree.
@Test
public void isVlanDeviceNonNetworkFree() {
freeVfCommon(0, 0, 0, 0, 1, 0);
HostDevice hostDevice = getSingleMockedNonFreeDevice();
assertFalse(networkDeviceHelper.isDeviceNetworkFree(hostDevice));
}
use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class NetworkDeviceHelperImplTest method createHostDevice.
private HostDevice createHostDevice(Guid vmId) {
HostDevice hostDevice = new HostDevice();
hostDevice.setHostId(HOST_ID);
hostDevice.setVmId(vmId);
return hostDevice;
}
use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class NetworkDeviceHelperImplTest method removeVmIdFromVfsCommonTest.
private void removeVmIdFromVfsCommonTest(int numOfVfWithVmId, int numOfOtherDeviceWithVmId) {
List<HostDevice> allDevices = new ArrayList<>();
List<HostDevice> otherDeviceWithVmId = new ArrayList<>();
Guid vmId = Guid.newGuid();
List<HostDevice> vfs = mockVfsOnNetDevice(numOfVfWithVmId, vmId);
allDevices.addAll(vfs);
for (int i = 0; i <= numOfOtherDeviceWithVmId; ++i) {
HostDevice hostDevice = createHostDevice(vmId);
otherDeviceWithVmId.add(hostDevice);
}
allDevices.addAll(otherDeviceWithVmId);
mockHostDevices(allDevices);
for (HostDevice vf : vfs) {
assertEquals(vmId, vf.getVmId());
}
networkDeviceHelper.removeVmIdFromVfs(vmId);
for (HostDevice vf : vfs) {
vf.setVmId(null);
}
if (numOfVfWithVmId == 0) {
verify(hostDeviceDao, never()).setVmIdOnHostDevice(any(), any());
} else {
verify(hostDeviceDao, times(numOfVfWithVmId)).setVmIdOnHostDevice(hostDeviceIdCaptor.capture(), vmIdCaptor.capture());
List<HostDeviceId> capturedDeviceIds = hostDeviceIdCaptor.getAllValues();
List<Guid> capturedVmIds = vmIdCaptor.getAllValues();
for (HostDevice vf : vfs) {
assertTrue(capturedDeviceIds.contains(vf.getId()));
}
for (HostDevice hostDevice : otherDeviceWithVmId) {
assertFalse(capturedDeviceIds.contains(hostDevice.getId()));
}
for (Guid capturedVmId : capturedVmIds) {
assertNull(capturedVmId);
}
}
}
use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class VfSchedulerImplTest method mockVfShareIommuGroup.
private void mockVfShareIommuGroup(HostDevice vf, boolean share) {
vf.setIommuGroup(RandomUtils.instance().nextInt());
List<HostDevice> devices = new ArrayList<>();
devices.add(vf);
if (share) {
HostDevice extraIommuDevice = new HostDevice();
extraIommuDevice.setHostId(vf.getHostId());
extraIommuDevice.setIommuGroup(vf.getIommuGroup());
devices.add(extraIommuDevice);
}
when(hostDeviceDao.getHostDevicesByHostIdAndIommuGroup(vf.getHostId(), vf.getIommuGroup())).thenReturn(devices);
}
use of org.ovirt.engine.core.common.businessentities.HostDevice in project ovirt-engine by oVirt.
the class VfSchedulerImplTest method createVf.
private HostDevice createVf() {
HostDevice hostDevice = new HostDevice();
hostDevice.setHostId(hostId);
hostDevice.setDeviceName(getRandomString());
return hostDevice;
}
Aggregations