use of org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics in project ovirt-engine by oVirt.
the class OvfManagerTest method initInterfaces.
private static void initInterfaces(VM vm) {
List<VmNetworkInterface> ifaces = new ArrayList<>();
RandomUtils rnd = RandomUtils.instance();
for (int i = 0; i < rnd.nextInt(2, 10); i++) {
VmNetworkInterface vmInterface = new VmNetworkInterface();
vmInterface.setStatistics(new VmNetworkStatistics());
vmInterface.setId(Guid.newGuid());
vmInterface.setVmId(vm.getId());
vmInterface.setName(generateRandomName());
vmInterface.setVnicProfileName(generateRandomName());
vmInterface.setNetworkName(generateRandomName());
vmInterface.setLinked(rnd.nextBoolean());
vmInterface.setSpeed(rnd.nextInt(1000));
vmInterface.setType(rnd.nextInt(10));
vmInterface.setMacAddress(rnd.nextMacAddress());
ifaces.add(vmInterface);
}
vm.setInterfaces(ifaces);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics in project ovirt-engine by oVirt.
the class VmNetworkStatisticsDaoTest method testUpdateAll.
@Test
public void testUpdateAll() throws Exception {
VmNetworkStatistics existingStats = dao.get(FixturesTool.VM_NETWORK_INTERFACE);
VmNetworkStatistics existingStats2 = dao.get(new Guid("e2817b12-f873-4046-b0da-0098293c0000"));
existingStats.setReceiveDropRate(10.0);
existingStats2.setStatus(InterfaceStatus.DOWN);
dao.updateAll(Arrays.asList(existingStats, existingStats2));
assertEquals(existingStats.getReceiveDropRate(), dao.get(existingStats.getId()).getReceiveDropRate());
assertEquals(existingStats2.getStatus(), dao.get(existingStats2.getId()).getStatus());
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics in project ovirt-engine by oVirt.
the class VmNetworkStatisticsDaoTest method testSave.
/**
* Ensures that saving an interface for a VM works as expected.
*/
@Test
public void testSave() {
dao.save(newVmStatistics);
VmNetworkStatistics savedStatistics = dao.get(NEW_INTERFACE_ID);
assertNotNull(savedStatistics);
assertEquals(newVmStatistics.getStatus(), savedStatistics.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics in project ovirt-engine by oVirt.
the class ResourceManager method storeVm.
private void storeVm(VM vm) {
vmDynamicDao.update(vm.getDynamicData());
getVmManager(vm.getId()).update(vm.getStatisticsData());
List<VmNetworkInterface> interfaces = vm.getInterfaces();
if (interfaces != null) {
for (VmNetworkInterface ifc : interfaces) {
VmNetworkStatistics stats = ifc.getStatistics();
vmNetworkStatisticsDao.update(stats);
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics in project ovirt-engine by oVirt.
the class BackendVmNicResourceTest method setUpStatisticalExpectations.
protected VmNetworkInterface setUpStatisticalExpectations() throws Exception {
VmNetworkStatistics stats = mock(VmNetworkStatistics.class);
VmNetworkInterface entity = mock(VmNetworkInterface.class);
when(entity.getStatistics()).thenReturn(stats);
when(entity.getSpeed()).thenReturn(50);
when(entity.getId()).thenReturn(NIC_ID);
when(stats.getReceiveRate()).thenReturn(10D);
when(stats.getTransmitRate()).thenReturn(20D);
when(stats.getReceiveDropRate()).thenReturn(30D);
when(stats.getTransmitDropRate()).thenReturn(40D);
when(stats.getReceivedBytes()).thenReturn(50L);
when(stats.getTransmittedBytes()).thenReturn(60L);
List<VmNetworkInterface> ifaces = new ArrayList<>();
ifaces.add(entity);
setUpEntityQueryExpectations(QueryType.GetVmInterfacesByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { VM_ID }, ifaces);
return entity;
}
Aggregations