Search in sources :

Example 11 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testInterfaceIsValidSlaveWhenInterfaceIsBond.

@Test
public void testInterfaceIsValidSlaveWhenInterfaceIsBond() throws Exception {
    VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
    vdsNetworkInterface.setBonded(true);
    Matcher<ValidationResult> matcher = failsWith(EngineMessage.NETWORK_INTERFACE_BOND_OR_VLAN_CANNOT_BE_SLAVE, ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_NIC_NAME, vdsNetworkInterface.getName()));
    assertThat(new HostInterfaceValidator(vdsNetworkInterface).interfaceIsValidSlave(), matcher);
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 12 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testLabeledNetworkAttachedToThisInterface.

@Test
public void testLabeledNetworkAttachedToThisInterface() throws Exception {
    String networkName = "networkA";
    Network network = new Network();
    network.setName(networkName);
    VdsNetworkInterface nicToWhichLabeledNetworkShouldBeAttached = createVdsNetworkInterfaceWithName("nicA");
    nicToWhichLabeledNetworkShouldBeAttached.setNetworkName(networkName);
    List<VdsNetworkInterface> hostInterfaces = Arrays.asList(nicToWhichLabeledNetworkShouldBeAttached, createVdsNetworkInterfaceWithName("nicB"));
    HostInterfaceValidator validator = new HostInterfaceValidator(nicToWhichLabeledNetworkShouldBeAttached);
    List<Network> clusterNetworksWithLabel = Collections.singletonList(network);
    assertThat(validator.networksAreAttachedToThisInterface(hostInterfaces, clusterNetworksWithLabel), isValid());
}
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 13 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testInterfaceInHostWhenInSameHost.

@Test
public void testInterfaceInHostWhenInSameHost() throws Exception {
    VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName();
    Guid vdsId = Guid.newGuid();
    vdsNetworkInterface.setVdsId(vdsId);
    assertThat(new HostInterfaceValidator(vdsNetworkInterface).interfaceInHost(vdsId), isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 14 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testAnotherInterfaceAlreadyLabeledWithThisLabelDoNotCompareWithSelf.

@Test
public void testAnotherInterfaceAlreadyLabeledWithThisLabelDoNotCompareWithSelf() throws Exception {
    // identity of nics is compared based on names.
    String sameName = "sameName";
    VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName(sameName);
    VdsNetworkInterface preexistingVdsNetworkInterface = createVdsNetworkInterfaceWithName(sameName);
    // set same label
    String label = "label";
    vdsNetworkInterface.setLabels(Collections.singleton(label));
    preexistingVdsNetworkInterface.setLabels(Collections.singleton(label));
    HostInterfaceValidator validator = new HostInterfaceValidator(vdsNetworkInterface);
    List<VdsNetworkInterface> preexistingInterfaces = Collections.singletonList(preexistingVdsNetworkInterface);
    assertThat(validator.anotherInterfaceAlreadyLabeledWithThisLabel(label, preexistingInterfaces), isValid());
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 15 with VdsNetworkInterface

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

the class HostInterfaceValidatorTest method testAnotherInterfaceAlreadyLabeledWithThisLabel.

@Test
public void testAnotherInterfaceAlreadyLabeledWithThisLabel() throws Exception {
    // identity of nics is compared based on names.
    VdsNetworkInterface vdsNetworkInterface = createVdsNetworkInterfaceWithName("name");
    VdsNetworkInterface preexistingVdsNetworkInterface = createVdsNetworkInterfaceWithName("differentName");
    // set same label
    String label = "label";
    vdsNetworkInterface.setLabels(Collections.singleton(label));
    preexistingVdsNetworkInterface.setLabels(Collections.singleton(label));
    HostInterfaceValidator validator = new HostInterfaceValidator(vdsNetworkInterface);
    List<VdsNetworkInterface> preexistingInterfaces = Collections.singletonList(preexistingVdsNetworkInterface);
    assertThat("different nics cannot have same label set.", validator.anotherInterfaceAlreadyLabeledWithThisLabel(label, preexistingInterfaces), failsWith(EngineMessage.OTHER_INTERFACE_ALREADY_LABELED, ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_LABELED_NIC, preexistingVdsNetworkInterface.getName()), ReplacementUtils.createSetVariableString(HostInterfaceValidator.VAR_NIC_LABEL, label)));
}
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