Search in sources :

Example 61 with VdsNetworkInterface

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

the class HostSetupNetworksCommand method checkForOutOfSyncNetworks.

private ValidationResult checkForOutOfSyncNetworks() {
    for (NetworkAttachment networkAttachment : getParameters().getNetworkAttachments()) {
        boolean newNetworkAttachment = networkAttachment.getId() == null;
        if (newNetworkAttachment) {
            // attachment to be yet created cannot be out of sync.
            continue;
        }
        boolean doNotCheckForOutOfSync = networkAttachment.isOverrideConfiguration();
        if (doNotCheckForOutOfSync) {
            continue;
        }
        Map<Guid, NetworkAttachment> existingNetworkAttachmentMap = Entities.businessEntitiesById(getExistingAttachments());
        NetworkAttachment existingNetworkAttachment = existingNetworkAttachmentMap.get(networkAttachment.getId());
        VdsNetworkInterface nic = NetworkUtils.hostInterfacesByNetworkName(getExistingNics()).get(existingNetworkAttachment.getNetworkName());
        NetworkImplementationDetails networkImplementationDetails = nic.getNetworkImplementationDetails();
        boolean networkIsNotInSync = networkImplementationDetails != null && !networkImplementationDetails.isInSync();
        if (networkIsNotInSync) {
            return new ValidationResult(EngineMessage.NETWORKS_NOT_IN_SYNC, ReplacementUtils.createSetVariableString("NETWORK_NOT_IN_SYNC", existingNetworkAttachment.getNetworkName()));
        }
    }
    return ValidationResult.VALID;
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 62 with VdsNetworkInterface

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

the class HostSetupNetworksCommand method calculateNetworksToConfigure.

private List<HostNetwork> calculateNetworksToConfigure() {
    List<HostNetwork> networksToConfigure = new ArrayList<>(getParameters().getNetworkAttachments().size());
    BusinessEntityMap<VdsNetworkInterface> nics = getExistingNicsBusinessEntityMap();
    for (NetworkAttachment attachment : getAttachmentsWithMissingUpdatedDefaultRoute()) {
        Network network = existingNetworkRelatedToAttachment(attachment);
        NetworkCluster networkCluster = network.getCluster();
        HostNetwork networkToConfigure = new HostNetwork(network, attachment);
        networkToConfigure.setBonding(isBonding(attachment, nics));
        boolean isDefaultRoute = defaultRouteSupported() && networkCluster.isDefaultRoute();
        if (isDefaultRoute) {
            DnsResolverConfiguration dnsResolverConfiguration = getDnsConfigurationFromNetworkOrItsAttachment(attachment, network);
            if (dnsResolverConfiguration != null) {
                networkToConfigure.setNameServers(dnsResolverConfiguration.getNameServers());
            }
        }
        // TODO: YZ - should default route be set separately for IPv4 and IPv6
        networkToConfigure.setDefaultRoute(isDefaultRoute);
        if (NetworkUtils.qosConfiguredOnInterface(attachment, network)) {
            networkToConfigure.setQosConfiguredOnInterface(true);
            HostNetworkQos hostNetworkQos = effectiveHostNetworkQos.getQos(attachment, network);
            networkToConfigure.setQos(hostNetworkQos);
        }
        networksToConfigure.add(networkToConfigure);
    }
    return networksToConfigure;
}
Also used : EffectiveHostNetworkQos(org.ovirt.engine.core.vdsbroker.EffectiveHostNetworkQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) HostNetwork(org.ovirt.engine.core.common.vdscommands.HostNetwork) FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) HostNetwork(org.ovirt.engine.core.common.vdscommands.HostNetwork) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 63 with VdsNetworkInterface

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

the class HostSetupNetworksCommand method updateAddedModifiedLabelsOnNics.

private void updateAddedModifiedLabelsOnNics(Map<String, VdsNetworkInterface> nicsToConfigureByName) {
    Map<String, VdsNetworkInterface> labelToExistingNic = getLabelToNic(nicsToConfigureByName.values());
    for (NicLabel nicLabel : getParameters().getLabels()) {
        VdsNetworkInterface currentLabelNic = labelToExistingNic.get(nicLabel.getLabel());
        VdsNetworkInterface newLabelNic = nicsToConfigureByName.get(nicLabel.getNicName());
        moveLabel(nicLabel.getLabel(), currentLabelNic, newLabelNic);
    }
}
Also used : VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel)

Example 64 with VdsNetworkInterface

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

the class GetNetworkAttachmentsByHostIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    Guid hostId = getParameters().getId();
    List<NetworkAttachment> networkAttachments = networkAttachmentDao.getAllForHost(hostId);
    List<VdsNetworkInterface> allInterfacesForHost = interfaceDao.getAllInterfacesForVds(hostId);
    VDS vds = hostDao.get(hostId);
    Guid clusterId = vds.getClusterId();
    BusinessEntityMap<Network> networkMap = new BusinessEntityMap<>(networkDao.getAllForCluster(clusterId));
    reportedConfigurationsFiller.fillReportedConfigurations(allInterfacesForHost, networkMap, networkAttachments, vds.getDynamicData().getReportedDnsResolverConfiguration(), clusterId);
    completeNicNames(networkAttachments, allInterfacesForHost);
    completeNetworkNames(networkAttachments, networkMap);
    getQueryReturnValue().setReturnValue(networkAttachments);
}
Also used : BusinessEntityMap(org.ovirt.engine.core.common.businessentities.BusinessEntityMap) VDS(org.ovirt.engine.core.common.businessentities.VDS) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 65 with VdsNetworkInterface

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

the class HostNicsUtil method findHostNics.

private List<VdsNetworkInterface> findHostNics(Guid hostId, Function<Guid, Guid> hostClusterIdFinder, Guid userID, boolean isFiltered) {
    final List<VdsNetworkInterface> vdsInterfaces = interfaceDao.getAllInterfacesForVds(hostId, userID, isFiltered);
    // 1. here we return all interfaces (eth0, eth1, eth2) - the first
    // condition
    // 2. we also return bonds that connected to network and has interfaces
    // - the second condition
    // i.e.
    // we have:
    // Network | Interface
    // -------------------
    // red-> |->eth0
    // |->eth1
    // | |->eth2
    // blue-> |->bond0->|->eth3
    // |->bond1
    // 
    // we return: eth0, eth1, eth2, eth3, bond0
    // we don't return bond1 because he is not connected to network and has
    // no child interfaces
    List<VdsNetworkInterface> interfaces = new ArrayList<>(vdsInterfaces.size());
    if (!vdsInterfaces.isEmpty()) {
        final Guid clusterId = hostClusterIdFinder.apply(hostId);
        Map<String, Network> networks = Entities.entitiesByName(networkDao.getAllForCluster(clusterId));
        for (final VdsNetworkInterface nic : vdsInterfaces) {
            if (!nic.isBond() || nicDoesHaveSlaves(vdsInterfaces, nic)) {
                interfaces.add(nic);
                Network network = networks.get(nic.getNetworkName());
                NetworkImplementationDetails networkImplementationDetails = networkImplementationDetailsUtils.calculateNetworkImplementationDetails(nic, network);
                nic.setNetworkImplementationDetails(networkImplementationDetails);
            }
        }
    }
    return interfaces;
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid) NetworkImplementationDetails(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface.NetworkImplementationDetails)

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