use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostMonitoring method fetchHostInterfaces.
private void fetchHostInterfaces() {
List<VdsNetworkInterface> nics;
if (vds.getInterfaces().isEmpty()) {
nics = getDbFacade().getInterfaceDao().getAllInterfacesForVds(vds.getId());
vds.getInterfaces().addAll(nics);
} else {
nics = vds.getInterfaces();
}
// cache previous state of interfaces for comparison with those reported by host
oldInterfaceStatus.clear();
for (VdsNetworkInterface nic : nics) {
oldInterfaceStatus.put(nic.getName(), nic.getStatistics().getStatus());
}
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class NetworkMonitoringHelper method determineProblematicNics.
/**
* Determine which of the given NICs is problematic - a problematic NIC is considered to be a NIC which it's state
* is down and it is the underlying interface of a required network.
*
* @param interfaces
* The NICs to check.
* @param clusterNetworks
* The cluster's networks.
* @return A pair of a list of the names of the NICs which are problematic, and a list of the names of the networks
* which are required by these NICs.
*/
public static Map<String, Set<String>> determineProblematicNics(List<VdsNetworkInterface> interfaces, List<Network> clusterNetworks) {
Map<String, Set<String>> brokenNicsToNetworks = new HashMap<>();
Map<String, Network> networksByName = NetworkUtils.networksByName(clusterNetworks);
for (VdsNetworkInterface iface : interfaces) {
if (isRequiredInterfaceDown(networksByName, interfaces, iface)) {
String baseNicName = NetworkCommonUtils.stripVlan(iface);
Set<String> networks = brokenNicsToNetworks.get(baseNicName);
if (networks == null) {
networks = new HashSet<>();
brokenNicsToNetworks.put(baseNicName, networks);
}
networks.add(iface.getNetworkName());
}
}
return brokenNicsToNetworks;
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testInterfaceInHostWhenInDifferentHost.
@Test
public void testInterfaceInHostWhenInDifferentHost() throws Exception {
VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
vdsNetworkInterface.setVdsId(Guid.newGuid());
Guid hostId = Guid.newGuid();
final EngineMessage engineMessage = EngineMessage.NIC_NOT_EXISTS_ON_HOST;
Matcher<ValidationResult> matcher = failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, hostId.toString()));
assertThat(new HostInterfaceValidator(vdsNetworkInterface).interfaceInHost(hostId), matcher);
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testInterfaceAlreadyLabeledWithWhenInterfaceIsLabeledBySameLabel.
@Test
public void testInterfaceAlreadyLabeledWithWhenInterfaceIsLabeledBySameLabel() throws Exception {
String labelA = "labelA";
VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
vdsNetworkInterface.setLabels(Collections.singleton(labelA));
Matcher<ValidationResult> matcher = failsWith(EngineMessage.INTERFACE_ALREADY_LABELED, ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_LABELED_NIC, vdsNetworkInterface.getName()), ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_NIC_LABEL, labelA));
assertThat(new HostInterfaceValidator(vdsNetworkInterface).interfaceAlreadyLabeledWith(labelA), matcher);
}
use of org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface in project ovirt-engine by oVirt.
the class HostInterfaceValidatorTest method testInterfaceAlreadyLabeledWithWhenLabelsIsNull.
@Test
public void testInterfaceAlreadyLabeledWithWhenLabelsIsNull() throws Exception {
VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
vdsNetworkInterface.setLabels(null);
assertThat(new HostInterfaceValidator(vdsNetworkInterface).interfaceAlreadyLabeledWith("labelA"), isValid());
}
Aggregations