Search in sources :

Example 26 with VdsNetworkInterface

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

the class HostSetupNetworksModel method findPhysicalFunction.

private VdsNetworkInterface findPhysicalFunction(Map<Guid, VdsNetworkInterface> nicsById, Guid nicId) {
    final boolean vf = vfMap.containsKey(nicId);
    final VdsNetworkInterface physicalFunction;
    if (vf) {
        final Guid pfId = vfMap.get(nicId);
        physicalFunction = nicsById.get(pfId);
    } else {
        physicalFunction = null;
    }
    return physicalFunction;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid)

Example 27 with VdsNetworkInterface

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

the class HostSetupNetworksModel method createModelsForUnamangedNetworks.

public void createModelsForUnamangedNetworks(Map<String, Set<LogicalNetworkModel>> nicToNetworks) {
    for (VdsNetworkInterface nic : allExistingNics) {
        if (shouldCreateUnmanagedNetworkModel(nic)) {
            LogicalNetworkModel networkModel = createUnmanagedNetworkModel(nic.getNetworkName(), nic);
            networkModelByName.put(networkModel.getName(), networkModel);
            String baseNicName = NetworkCommonUtils.stripVlan(nic);
            if (!nicToNetworks.containsKey(baseNicName)) {
                nicToNetworks.put(baseNicName, new HashSet<LogicalNetworkModel>());
            }
            nicToNetworks.get(baseNicName).add(networkModel);
        }
    }
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)

Example 28 with VdsNetworkInterface

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

the class HostSetupNetworksModel method createSlaveModels.

private List<NetworkInterfaceModel> createSlaveModels(Map<String, List<VdsNetworkInterface>> bondNameToSlaves, final Map<Guid, VdsNetworkInterface> nicsById, String bondName) {
    List<NetworkInterfaceModel> slavesModels = new ArrayList<>();
    for (VdsNetworkInterface slave : bondNameToSlaves.get(bondName)) {
        NetworkInterfaceModel slaveModel = createSlaveModel(nicsById, slave);
        slavesModels.add(slaveModel);
    }
    return slavesModels;
}
Also used : NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 29 with VdsNetworkInterface

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

the class HostSetupNetworksModel method createRegularNicModels.

private Map<String, NetworkInterfaceModel> createRegularNicModels(Map<String, Set<LogicalNetworkModel>> nicNameToNetworkModels, Map<String, List<VdsNetworkInterface>> bondNameToSlaves, Map<String, List<NetworkLabelModel>> nicNameToLabelModels, final Map<Guid, VdsNetworkInterface> nicsById) {
    Map<String, NetworkInterfaceModel> regularNicModels = new HashMap<>();
    for (VdsNetworkInterface nic : allExistingNics) {
        if (!isPhysicalNic(nic, bondNameToSlaves.keySet(), getAllSlaveNames())) {
            continue;
        }
        final VdsNetworkInterface physicalFunction = findPhysicalFunction(nicsById, nic.getId());
        if (physicalFunction != null && !getShowVf().getEntity()) {
            continue;
        }
        String nicName = nic.getName();
        Collection<LogicalNetworkModel> nicNetworks = nicNameToNetworkModels.get(nicName);
        NetworkInterfaceModel nicModel = new NetworkInterfaceModel(nic, nicNetworks, nicNameToLabelModels.get(nicName), nicToVfsConfig.containsKey(nic.getId()), physicalFunction == null ? null : physicalFunction.getName(), this);
        regularNicModels.put(nicName, nicModel);
    }
    return regularNicModels;
}
Also used : NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) HashMap(java.util.HashMap) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)

Example 30 with VdsNetworkInterface

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

the class HostInterfaceListModel method updateItems.

private void updateItems(Iterable<VdsNetworkInterface> source) {
    ArrayList<HostInterfaceLineModel> items = new ArrayList<>();
    setOriginalItems((ArrayList<VdsNetworkInterface>) source);
    List<Bond> nonEmptyBonds = new ArrayList<>();
    List<Nic> independentNics = new ArrayList<>();
    Map<String, List<Nic>> bondToNics = new HashMap<>();
    Map<String, List<Vlan>> nicToVlans = new HashMap<>();
    sortNics();
    classifyNics(nonEmptyBonds, independentNics, bondToNics, nicToVlans);
    // create all bond models
    for (Bond bond : nonEmptyBonds) {
        HostInterfaceLineModel model = lineModelFromBond(bond);
        items.add(model);
        // add contained interface models - should exist, but check just in case
        if (bondToNics.containsKey(bond.getName())) {
            for (Nic nic : bondToNics.get(bond.getName())) {
                model.getInterfaces().add(hostInterfaceFromNic(nic));
            }
        }
        // add any corresponding VLAN bridge models
        model.getVLans().addAll(gatherVlans(bond, nicToVlans));
    }
    // create all independent NIC models
    for (Nic nic : independentNics) {
        HostInterfaceLineModel model = lineModelFromInterface(nic);
        model.getInterfaces().add(hostInterfaceFromNic(nic));
        items.add(model);
        // add any corresponding VLAN bridge models
        model.getVLans().addAll(gatherVlans(nic, nicToVlans));
    }
    setItems(items);
    updateActionAvailability();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArrayList(java.util.ArrayList) List(java.util.List) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

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