Search in sources :

Example 1 with VdsNetworkStatistics

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

the class BackendHostNicResourceTest method setUpStatisticalExpectations.

protected VdsNetworkInterface setUpStatisticalExpectations() throws Exception {
    VdsNetworkStatistics stats = mock(VdsNetworkStatistics.class);
    VdsNetworkInterface entity = mock(VdsNetworkInterface.class);
    when(entity.getSpeed()).thenReturn(SPEED);
    when(entity.getStatistics()).thenReturn(stats);
    when(entity.getId()).thenReturn(NIC_ID);
    when(stats.getReceiveRate()).thenReturn(RECEIVE_RATE);
    when(stats.getTransmitRate()).thenReturn(TRANSMIT_RATE);
    when(stats.getReceiveDropRate()).thenReturn(RECEIVE_DROP_RATE);
    when(stats.getTransmitDropRate()).thenReturn(TRANSMIT_DROP_RATE);
    when(stats.getReceivedBytes()).thenReturn(RECEIVED_BYTES);
    when(stats.getTransmittedBytes()).thenReturn(TRANSMITTED_BYTES);
    List<VdsNetworkInterface> ifaces = new ArrayList<>();
    ifaces.add(entity);
    setUpEntityQueryExpectations(QueryType.GetVdsInterfacesByVdsId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { PARENT_GUID }, ifaces);
    return entity;
}
Also used : VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 2 with VdsNetworkStatistics

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

the class BackendHostNicsResourceTest method setUpStatistics.

public static VdsNetworkInterface setUpStatistics(VdsNetworkInterface entity, Guid id) {
    VdsNetworkStatistics statistics = new VdsNetworkStatistics();
    statistics.setId(null);
    statistics.setReceiveDropRate(1D);
    statistics.setReceiveRate(2D);
    statistics.setTransmitDropRate(3D);
    statistics.setTransmitRate(4D);
    statistics.setReceivedBytes(5L);
    statistics.setTransmittedBytes(6L);
    statistics.setVdsId(id);
    statistics.setStatus(null);
    entity.setStatistics(statistics);
    return entity;
}
Also used : VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics)

Example 3 with VdsNetworkStatistics

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

the class VdsBrokerObjectsBuilder method updateCommonInterfaceData.

/**
 * Updates a given interface (be it physical, bond or VLAN) by data as collected from the host.
 *
 * @param iface
 *            The interface to update
 * @param host
 *            The host to which the interface belongs.
 * @param ifaceEntry
 *            A pair whose key is the interface's name, and whose value it a map of the interface properties.
 */
private static void updateCommonInterfaceData(VdsNetworkInterface iface, VDS host, Entry<String, Map<String, Object>> ifaceEntry) {
    iface.setName(ifaceEntry.getKey());
    iface.setId(Guid.newGuid());
    iface.setVdsId(host.getId());
    VdsNetworkStatistics iStats = new VdsNetworkStatistics();
    iStats.setId(iface.getId());
    iStats.setVdsId(host.getId());
    iface.setStatistics(iStats);
    Map<String, Object> nicProperties = ifaceEntry.getValue();
    if (nicProperties != null) {
        Object speed = nicProperties.get("speed");
        if (speed != null) {
            iface.setSpeed((Integer) speed);
        }
        iface.setIpv4Address(extractAddress(nicProperties));
        iface.setIpv4Subnet(extractSubnet(nicProperties));
        final String ipv6Address = getIpv6Address(nicProperties);
        iface.setIpv6Address(extractIpv6Address(ipv6Address));
        iface.setIpv6Prefix(extractIpv6Prefix(ipv6Address));
        final Integer mtu = assignIntValue(nicProperties, VdsProperties.MTU);
        if (mtu != null) {
            iface.setMtu(mtu);
        }
        addBootProtocol(nicProperties, iface);
        addAdAggregatorId(nicProperties, iface);
    }
}
Also used : VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics)

Example 4 with VdsNetworkStatistics

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

the class InterfaceDaoImplTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    statsTest = new HostNetworkStatisticsDaoTest();
    dao = dbFacade.getInterfaceDao();
    existingVdsInterface = dao.get(FixturesTool.VDS_NETWORK_INTERFACE);
    newQos = new HostNetworkQos();
    newQos.setOutAverageLinkshare(30);
    newQos.setOutAverageUpperlimit(30);
    newQos.setOutAverageRealtime(30);
    newVdsInterface = new VdsNetworkInterface();
    newVdsInterface.setStatistics(new VdsNetworkStatistics());
    newVdsInterface.setId(Guid.newGuid());
    newVdsInterface.setName("eth77");
    newVdsInterface.setNetworkName("enginet");
    newVdsInterface.setSpeed(1000);
    newVdsInterface.setType(3);
    newVdsInterface.setMacAddress("01:C0:81:21:71:17");
    newVdsInterface.setIpv4BootProtocol(Ipv4BootProtocol.STATIC_IP);
    newVdsInterface.setIpv4Address("192.168.122.177");
    newVdsInterface.setIpv4Subnet("255.255.255.0");
    newVdsInterface.setIpv4Gateway("192.168.122.1");
    newVdsInterface.setIpv6BootProtocol(Ipv6BootProtocol.AUTOCONF);
    newVdsInterface.setIpv6Address("ipv6 address");
    newVdsInterface.setIpv6Prefix(666);
    newVdsInterface.setIpv6Gateway("ipv6 gateway");
    newVdsInterface.setMtu(1500);
    newVdsInterface.setQos(newQos);
    newVdsStatistics = newVdsInterface.getStatistics();
}
Also used : HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 5 with VdsNetworkStatistics

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

the class InterfaceDaoImplTest method testMasshUpdateStatisticsForVds.

@Test
public void testMasshUpdateStatisticsForVds() throws Exception {
    List<VdsNetworkInterface> interfaces = dao.getAllInterfacesForVds(VDS_ID);
    List<VdsNetworkStatistics> statistics = new ArrayList<>(interfaces.size());
    for (VdsNetworkInterface iface : interfaces) {
        VdsNetworkStatistics stats = iface.getStatistics();
        stats.setReceiveDropRate(RandomUtils.instance().nextInt() * 1.0);
        stats.setStatus(RandomUtils.instance().nextEnum(InterfaceStatus.class));
        statistics.add(stats);
    }
    dao.massUpdateStatisticsForVds(statistics);
    List<VdsNetworkInterface> after = dao.getAllInterfacesForVds(VDS_ID);
    for (VdsNetworkInterface iface : after) {
        boolean found = false;
        for (VdsNetworkStatistics stats : statistics) {
            if (iface.getId().equals(stats.getId())) {
                found = true;
                assertEquals(stats.getReceiveDropRate(), iface.getStatistics().getReceiveDropRate());
                assertEquals(stats.getStatus(), iface.getStatistics().getStatus());
            }
        }
        assertTrue(found);
    }
}
Also used : InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Aggregations

VdsNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics)6 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)4 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)1 Test (org.junit.Test)1 VdsStatistics (org.ovirt.engine.core.common.businessentities.VdsStatistics)1 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)1 InterfaceStatus (org.ovirt.engine.core.common.businessentities.network.InterfaceStatus)1