Search in sources :

Example 11 with Nic

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

the class UnmanagedNetworkValidatorTest method testValidateAttachements.

@Test
public void testValidateAttachements() {
    String unmanagedNicName = "eth0";
    NetworkAttachment attachement1 = new NetworkAttachment();
    attachement1.setNetworkName("network1");
    attachement1.setNicName(unmanagedNicName);
    NetworkAttachment attachement2 = new NetworkAttachment();
    attachement2.setNetworkName("any2");
    attachement2.setNicName("eth1");
    List<NetworkAttachment> attachementList = Arrays.asList(attachement1, attachement2);
    Nic unmgmtNic = createNicWithNetworkImplementationDetails(unmanagedNicName, false);
    List<VdsNetworkInterface> existingInterfaces = Collections.singletonList(unmgmtNic);
    Set<String> nicsWithUnmanagedNetworks = validator.filterNicsWithUnmanagedNetworks(existingInterfaces, Collections.emptySet());
    assertEquals(1, nicsWithUnmanagedNetworks.size());
    String filteredNicName = nicsWithUnmanagedNetworks.iterator().next();
    assertEquals(unmanagedNicName, filteredNicName);
    ValidationResult result = validator.validateAttachements(filteredNicName, attachementList);
    assertThat(result, failsWith(EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_ATTACHEMENT_ON_UNMANAGED_NETWORK, ReplacementUtils.createSetVariableString(NETWORK, "network1"), ReplacementUtils.createSetVariableString(NIC, "eth0")));
    result = validator.validateAttachements("eth7", attachementList);
    assertTrue(result.isValid());
}
Also used : Nic(org.ovirt.engine.core.common.businessentities.network.Nic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 12 with Nic

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

the class GetTlvsByHostNicIdQueryTest method createNic.

private VdsNetworkInterface createNic(ExpectedError expectedError, Guid vdsId) {
    switch(expectedError) {
        case NIC_ID_NIC:
            VdsNetworkInterface vdsIface = new VdsNetworkInterface();
            vdsIface.setVdsId(vdsId);
            return vdsIface;
        case NIC_ID_NETWORK_INTERFACE:
            return null;
        default:
            Nic nic = new Nic();
            nic.setName(NIC_NAME);
            nic.setVdsId(vdsId);
            return nic;
    }
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Nic(org.ovirt.engine.core.common.businessentities.network.Nic)

Example 13 with Nic

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

the class NetworkUtilsTest method createNic.

private VdsNetworkInterface createNic(String ifaceName) {
    VdsNetworkInterface iface = new Nic();
    iface.setName(ifaceName);
    return iface;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Nic(org.ovirt.engine.core.common.businessentities.network.Nic)

Aggregations

Nic (org.ovirt.engine.core.common.businessentities.network.Nic)13 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)9 Test (org.junit.Test)4 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)4 List (java.util.List)3 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)2 Vlan (org.ovirt.engine.core.common.businessentities.network.Vlan)2 Map (java.util.Map)1 Collectors.joining (java.util.stream.Collectors.joining)1 StringUtils (org.apache.commons.lang.StringUtils)1 Bonding (org.ovirt.engine.api.model.Bonding)1 BootProtocol (org.ovirt.engine.api.model.BootProtocol)1 HostNic (org.ovirt.engine.api.model.HostNic)1 HostNicVirtualFunctionsConfiguration (org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration)1 Ip (org.ovirt.engine.api.model.Ip)1 IpVersion (org.ovirt.engine.api.model.IpVersion)1 Mac (org.ovirt.engine.api.model.Mac)1