Search in sources :

Example 21 with VdsNetworkInterface

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

the class BaseNetworkImplementationDetailsUtilsTest method initMocksForNetworkImplementationDetailsUtils.

private NetworkImplementationDetailsUtils initMocksForNetworkImplementationDetailsUtils(Network network, HostNetworkQos qos, VdsNetworkInterface testIface) {
    final VdsNetworkInterface baseIface = this.calculateBaseNic.getBaseNic(testIface);
    Guid baseIfaceId = baseIface.getId();
    Guid networkId = network == null ? null : network.getId();
    if (baseIfaceId != null && networkId != null) {
        when(networkAttachmentDaoMock.getNetworkAttachmentByNicIdAndNetworkId(eq(baseIfaceId), eq(networkId))).thenReturn(createNetworkAttachment(qos, baseIface));
    }
    return this.networkImplementationDetailsUtils;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid)

Example 22 with VdsNetworkInterface

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

the class BaseNetworkImplementationDetailsUtilsTest method createBaseInterface.

protected VdsNetworkInterface createBaseInterface(HostNetworkQos qos, String networkName) {
    VdsNetworkInterface baseInterface = new VdsNetworkInterface();
    baseInterface.setId(Guid.newGuid());
    baseInterface.setNetworkName(networkName);
    baseInterface.setName("eth");
    baseInterface.setQos(qos);
    baseInterface.setVdsId(VDS_ID);
    return baseInterface;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 23 with VdsNetworkInterface

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

the class CalculateBaseNicTest method testGetBaseNicUsingCacheNotHavingRequiredRecord.

@Test
public void testGetBaseNicUsingCacheNotHavingRequiredRecord() throws Exception {
    when(interfaceDao.get(baseNic.getVdsId(), baseNic.getName())).thenReturn(baseNic);
    Map<String, VdsNetworkInterface> cachedExistingInterfaces = Collections.singletonMap("unrelatedNicName", new VdsNetworkInterface());
    assertThat(calculateBaseNic.getBaseNic(vlanNic, cachedExistingInterfaces), is(baseNic));
    verify(interfaceDao).get(eq(baseNic.getVdsId()), eq(baseNic.getName()));
    verifyNoMoreInteractions(interfaceDao);
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Test(org.junit.Test)

Example 24 with VdsNetworkInterface

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

the class CalculateBaseNicTest method createVlanNic.

private VdsNetworkInterface createVlanNic(VdsNetworkInterface baseNic) {
    VdsNetworkInterface vlanNic = createNic("vlanNic");
    vlanNic.setBaseInterface(baseNic.getName());
    vlanNic.setVlanId(100);
    vlanNic.setVdsId(baseNic.getVdsId());
    return vlanNic;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 25 with VdsNetworkInterface

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

the class HostSetupNetworksModel method getBondNameToSlaves.

private Map<String, List<VdsNetworkInterface>> getBondNameToSlaves() {
    final Map<String, VdsNetworkInterface> nicMap = Entities.entitiesByName(allExistingNics);
    Map<String, List<VdsNetworkInterface>> bondToSlaves = new HashMap<>();
    for (CreateOrUpdateBond createOrUpdateBond : hostSetupNetworksParametersData.getBonds()) {
        String bondName = createOrUpdateBond.getName();
        // $NON-NLS-1$
        assert !bondToSlaves.containsKey(bondName) : "the same bond shouldn't exist twice in the parameters";
        bondToSlaves.put(bondName, new ArrayList<VdsNetworkInterface>());
        Set<String> slavesNames = createOrUpdateBond.getSlaves();
        for (String slaveName : slavesNames) {
            bondToSlaves.get(bondName).add(nicMap.get(slaveName));
        }
    }
    return bondToSlaves;
}
Also used : HashMap(java.util.HashMap) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) List(java.util.List) ArrayList(java.util.ArrayList)

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