Search in sources :

Example 31 with VdsNetworkInterface

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

the class HostInterfaceListModel method classifyNics.

private void classifyNics(List<Bond> nonEmptyBonds, List<Nic> independentNics, Map<String, List<Nic>> bondToNics, Map<String, List<Vlan>> nicToVlans) {
    for (VdsNetworkInterface nic : getOriginalItems()) {
        if (nic instanceof Bond) {
            nonEmptyBonds.add((Bond) nic);
        } else if (nic instanceof Nic) {
            if (nic.getBondName() == null) {
                independentNics.add((Nic) nic);
            } else {
                if (bondToNics.containsKey(nic.getBondName())) {
                    bondToNics.get(nic.getBondName()).add((Nic) nic);
                } else {
                    List<Nic> nicList = new ArrayList<>();
                    nicList.add((Nic) nic);
                    bondToNics.put(nic.getBondName(), nicList);
                }
            }
        } else if (nic instanceof Vlan) {
            String nameWithoutVlan = nic.getBaseInterface();
            if (nicToVlans.containsKey(nameWithoutVlan)) {
                nicToVlans.get(nameWithoutVlan).add((Vlan) nic);
            } else {
                List<Vlan> vlanList = new ArrayList<>();
                vlanList.add((Vlan) nic);
                nicToVlans.put(nameWithoutVlan, vlanList);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) ArrayList(java.util.ArrayList) List(java.util.List) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 32 with VdsNetworkInterface

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

the class NetworkHostListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    final NetworkHostFilter filter = getViewFilterType();
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
        if (filter.equals(getViewFilterType())) {
            final Iterable returnList = returnValue.getReturnValue();
            if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
                final List<PairQueryable<VdsNetworkInterface, VDS>> items = new ArrayList<>();
                for (Object obj : returnList) {
                    items.add(new PairQueryable<VdsNetworkInterface, VDS>(null, (VDS) obj));
                }
                setItems(items);
            } else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
                initAttachedInterfaces((Collection<PairQueryable<VdsNetworkInterface, VDS>>) returnList);
            }
        }
    });
    IdQueryParameters params = new IdQueryParameters(getEntity().getId());
    params.setRefresh(getIsQueryFirstTime());
    if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
        Frontend.getInstance().runQuery(QueryType.GetVdsWithoutNetwork, params, asyncQuery);
    } else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
        Frontend.getInstance().runQuery(QueryType.GetVdsAndNetworkInterfacesByNetworkId, params, asyncQuery);
    }
    setIsQueryFirstTime(false);
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Collection(java.util.Collection)

Example 33 with VdsNetworkInterface

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

the class LogicalNetworkModelParametersHelper method createAttachmentWhenAttachingTo.

private NetworkAttachment createAttachmentWhenAttachingTo(VdsNetworkInterface targetNic) {
    NetworkAttachment networkAttachment = new NetworkAttachment(targetNic, networkModel.getNetwork(), NetworkCommonUtils.createDefaultIpConfiguration());
    NetworkParameters netParams = networkModel.getSetupModel().getNetworkToLastDetachParams().get(networkModel.getName());
    if (netParams != null) {
        applyOnAttachmentParamsFrom(netParams, networkAttachment);
    } else {
        VdsNetworkInterface nicToTakeParamsFrom = null;
        if (networkModel.hasVlan()) {
            nicToTakeParamsFrom = getPotentialVlanDevice(targetNic);
        } else {
            nicToTakeParamsFrom = targetNic;
        }
        boolean newlyCreatedBond = nicToTakeParamsFrom != null && nicToTakeParamsFrom.getId() == null;
        if (nicToTakeParamsFrom != null && !newlyCreatedBond) {
            InterfacePropertiesAccessor.FromNic interfacePropertiesAccessor = new InterfacePropertiesAccessor.FromNic(nicToTakeParamsFrom, null);
            applyOnAttachmentParamsFrom(interfacePropertiesAccessor, networkAttachment);
        }
        fixBootProtocolOfMgmtNetworkIfNeeded(networkAttachment);
    }
    return networkAttachment;
}
Also used : InterfacePropertiesAccessor(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor) NetworkParameters(org.ovirt.engine.ui.uicommonweb.models.hosts.NetworkParameters) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 34 with VdsNetworkInterface

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

the class HostNetworkTopologyPersisterImpl method skipManagementNetworkCheck.

private void skipManagementNetworkCheck(List<VdsNetworkInterface> ifaces, List<Network> clusterNetworks, Guid clusterId) {
    final Network managementNetwork = managementNetworkUtil.getManagementNetwork(clusterId);
    final String managementNetworkName = managementNetwork.getName();
    for (VdsNetworkInterface iface : ifaces) {
        if (managementNetworkName.equals(iface.getNetworkName())) {
            return;
        }
    }
    for (Iterator<Network> iterator = clusterNetworks.iterator(); iterator.hasNext(); ) {
        Network network = iterator.next();
        if (managementNetworkName.equals(network.getName())) {
            iterator.remove();
            break;
        }
    }
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 35 with VdsNetworkInterface

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

the class HostNetworkTopologyPersisterImpl method persistAndEnforceNetworkCompliance.

@Override
public NonOperationalReason persistAndEnforceNetworkCompliance(VDS host, boolean skipManagementNetwork, UserConfiguredNetworkData userConfiguredData) {
    return TransactionSupport.executeInScope(TransactionScopeOption.Required, () -> {
        List<VdsNetworkInterface> dbIfaces = interfaceDao.getAllInterfacesForVds(host.getId());
        List<Network> clusterNetworks = networkDao.getAllForCluster(host.getClusterId());
        persistTopology(host, dbIfaces, clusterNetworks, userConfiguredData);
        NonOperationalReason nonOperationalReason = enforceNetworkCompliance(host, skipManagementNetwork, clusterNetworks);
        auditNetworkCompliance(host, dbIfaces, clusterNetworks);
        return nonOperationalReason;
    });
}
Also used : NonOperationalReason(org.ovirt.engine.core.common.businessentities.NonOperationalReason) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

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