Search in sources :

Example 6 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testInterfaceIsBondWhenInterfaceIsNotBonded.

@Test
public void testInterfaceIsBondWhenInterfaceIsNotBonded() throws Exception {
    VdsNetworkInterface iface = createVdsNetworkInterfaceWithName();
    iface.setBonded(false);
    final EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_IS_NOT_BOND;
    Matcher<ValidationResult> matcher = failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, iface.getName()));
    assertThat(new HostInterfaceValidator(iface).interfaceIsBondOrNull(), matcher);
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Test(org.junit.Test)

Example 7 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testLabeledNetworkAttachedToThisInterfaceWhenNetworkIsAssignedToWrongInterface.

@Test
public void testLabeledNetworkAttachedToThisInterfaceWhenNetworkIsAssignedToWrongInterface() throws Exception {
    String networkName = "networkA";
    Network network = new Network();
    network.setName(networkName);
    VdsNetworkInterface nicToWhichLabeledNetworkShouldBeAttached = createVdsNetworkInterfaceWithName("nicA");
    VdsNetworkInterface nicImproperlyAssignedToNetwork = createVdsNetworkInterfaceWithName("nicB");
    nicImproperlyAssignedToNetwork.setNetworkName(networkName);
    List<VdsNetworkInterface> hostInterfaces = Arrays.asList(nicToWhichLabeledNetworkShouldBeAttached, nicImproperlyAssignedToNetwork);
    HostInterfaceValidator validator = new HostInterfaceValidator(nicToWhichLabeledNetworkShouldBeAttached);
    assertThat(validator.networksAreAttachedToThisInterface(hostInterfaces, Collections.singletonList(network)), failsWith(EngineMessage.LABELED_NETWORK_ATTACHED_TO_WRONG_INTERFACE, ReplacementUtils.replaceWith(HostInterfaceValidator.VAR_ASSIGNED_NETWORKS, Collections.singletonList(networkName))));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 8 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testInterfaceAlreadyLabeledWithWhenInterfaceIsNotLabeled.

@Test
public void testInterfaceAlreadyLabeledWithWhenInterfaceIsNotLabeled() throws Exception {
    VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
    vdsNetworkInterface.setLabels(new HashSet<>());
    assertThat(new HostInterfaceValidator(vdsNetworkInterface).interfaceAlreadyLabeledWith("labelA"), isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 9 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testInterfaceIsBondWhenInterfaceIsBonded.

@Test
public void testInterfaceIsBondWhenInterfaceIsBonded() throws Exception {
    VdsNetworkInterface iface = createVdsNetworkInterfaceWithName();
    iface.setBonded(true);
    assertThat(new HostInterfaceValidator(iface).interfaceIsBondOrNull(), isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 10 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testValidBond.

@Test
public void testValidBond() throws Exception {
    VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
    vdsNetworkInterface.setBonded(false);
    HostInterfaceValidator validator = new HostInterfaceValidator(vdsNetworkInterface);
    assertThat(validator.validBond(Collections.emptyList()), 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