Search in sources :

Example 1 with VdsNetworkInterface

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

Example 2 with VdsNetworkInterface

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;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 3 with VdsNetworkInterface

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

Example 4 with VdsNetworkInterface

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

Example 5 with VdsNetworkInterface

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

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