Search in sources :

Example 1 with VmNetworkStatistics

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);
}
Also used : RandomUtils(org.ovirt.engine.core.utils.RandomUtils) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) ArrayList(java.util.ArrayList)

Example 2 with VmNetworkStatistics

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());
}
Also used : VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 3 with VmNetworkStatistics

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());
}
Also used : VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) Test(org.junit.Test)

Example 4 with VmNetworkStatistics

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

Example 5 with VmNetworkStatistics

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;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) ArrayList(java.util.ArrayList)

Aggregations

VmNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics)10 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)1 VnicProfileHelper (org.ovirt.engine.core.bll.network.vm.VnicProfileHelper)1 VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)1 Guid (org.ovirt.engine.core.compat.Guid)1 RandomUtils (org.ovirt.engine.core.utils.RandomUtils)1