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;
}
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;
}
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);
}
}
}
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);
}
}
}
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;
}
Aggregations