Search in sources :

Example 16 with VdsNetworkInterface

use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface 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 17 with VdsNetworkInterface

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

the class AbstractVdsNetworkInterfacePredicateTest method generateVdsNetworkInterface.

private VdsNetworkInterface generateVdsNetworkInterface(String value) {
    VdsNetworkInterface iface = new VdsNetworkInterface();
    setIfaceProperty(iface, value);
    return iface;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 18 with VdsNetworkInterface

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

the class VdsBrokerObjectsBuilder method addHostVlanDevices.

/**
 * Updates the host interfaces list with vlan devices
 *
 * @param vds
 *            The host to update
 * @param struct
 *            a map contains pairs of vlan device name and vlan data
 */
private static void addHostVlanDevices(VDS vds, Map<String, Object> struct) {
    // vlans
    Map<String, Map<String, Object>> vlans = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NETWORK_VLANS);
    if (vlans != null) {
        for (Entry<String, Map<String, Object>> entry : vlans.entrySet()) {
            VdsNetworkInterface vlan = new Vlan();
            updateCommonInterfaceData(vlan, vds, entry);
            String vlanDeviceName = entry.getKey();
            Map<String, Object> vlanProperties = entry.getValue();
            if (vlanProperties.get(VdsProperties.VLAN_ID) != null && vlanProperties.get(VdsProperties.BASE_INTERFACE) != null) {
                vlan.setVlanId((Integer) vlanProperties.get(VdsProperties.VLAN_ID));
                vlan.setBaseInterface((String) vlanProperties.get(VdsProperties.BASE_INTERFACE));
            } else if (vlanDeviceName.contains(".")) {
                String[] names = vlanDeviceName.split("[.]", -1);
                String vlanId = names[1];
                vlan.setVlanId(Integer.parseInt(vlanId));
                vlan.setBaseInterface(names[0]);
            }
            vds.getInterfaces().add(vlan);
        }
    }
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) Map(java.util.Map) HashMap(java.util.HashMap)

Example 19 with VdsNetworkInterface

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

the class VdsBrokerObjectsBuilder method addHostNetworkInterfaces.

/**
 * Updates the host network interfaces with the collected data from the host
 *
 * @param vds
 *            The host to update its interfaces
 * @param struct
 *            A nested map contains network interfaces data
 */
private static void addHostNetworkInterfaces(VDS vds, Map<String, Object> struct) {
    Map<String, Map<String, Object>> nics = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NETWORK_NICS);
    if (nics != null) {
        for (Entry<String, Map<String, Object>> entry : nics.entrySet()) {
            VdsNetworkInterface nic = new Nic();
            updateCommonInterfaceData(nic, vds, entry);
            Map<String, Object> nicProperties = entry.getValue();
            if (nicProperties != null) {
                nic.setMacAddress((String) nicProperties.get("hwaddr"));
                // if we get "permhwaddr", we are a part of a bond and we use that as the mac address
                String mac = (String) nicProperties.get("permhwaddr");
                if (mac != null) {
                    // TODO remove when the minimal supported vdsm version is >=3.6
                    // in older VDSM version, slave's Mac is in upper case
                    nic.setMacAddress(mac.toLowerCase());
                }
            }
            vds.getInterfaces().add(nic);
        }
    }
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Map(java.util.Map) HashMap(java.util.HashMap)

Example 20 with VdsNetworkInterface

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

the class VdsBrokerObjectsBuilder method findActiveNicName.

private static String findActiveNicName(VDS vds, Map<String, Map<String, Object>> bridges) {
    final String hostIp = NetworkUtils.getHostIp(vds);
    final String activeBridge = findActiveBridge(hostIp, bridges);
    if (activeBridge != null) {
        return activeBridge;
    }
    // by now, if the host is communicating with engine over a valid interface,
    // the interface will have the host's engine IP
    final VdsNetworkInterface activeIface = resolveActiveNic(vds, hostIp);
    String hostActiveNic = (activeIface == null) ? null : activeIface.getName();
    return hostActiveNic;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Aggregations

VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)233 Test (org.junit.Test)68 Network (org.ovirt.engine.core.common.businessentities.network.Network)47 ArrayList (java.util.ArrayList)46 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)35 Guid (org.ovirt.engine.core.compat.Guid)30 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)24 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)23 List (java.util.List)19 HashMap (java.util.HashMap)18 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)18 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)17 NicLabel (org.ovirt.engine.core.common.businessentities.network.NicLabel)16 VDS (org.ovirt.engine.core.common.businessentities.VDS)15 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)14 Nic (org.ovirt.engine.core.common.businessentities.network.Nic)13 Map (java.util.Map)12 HostDevice (org.ovirt.engine.core.common.businessentities.HostDevice)9 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)8 Vlan (org.ovirt.engine.core.common.businessentities.network.Vlan)8