Search in sources :

Example 41 with NetworkAttachment

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

the class PersistentHostSetupNetworksParametersFactoryTest method createNetworkAttachment.

private NetworkAttachment createNetworkAttachment(Network network, HostNetworkQos hostNetworkQos) {
    NetworkAttachment networkAttachment = new NetworkAttachment();
    networkAttachment.setId(Guid.newGuid());
    networkAttachment.setHostNetworkQos(AnonymousHostNetworkQos.fromHostNetworkQos(hostNetworkQos));
    networkAttachment.setNetworkId(network.getId());
    return networkAttachment;
}
Also used : NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 42 with NetworkAttachment

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

the class NetworkMtuValidator method getNetworksOnNics.

Map<String, List<Network>> getNetworksOnNics(Collection<NetworkAttachment> attachmentsToConfigure) {
    Map<String, List<Network>> nicsToNetworks = new HashMap<>();
    for (NetworkAttachment attachment : attachmentsToConfigure) {
        String nicName = attachment.getNicName();
        if (!nicsToNetworks.containsKey(nicName)) {
            nicsToNetworks.put(nicName, new ArrayList<>());
        }
        Network networkToConfigure = networkBusinessEntityMap.get(attachment.getNetworkId());
        nicsToNetworks.get(nicName).add(networkToConfigure);
    }
    return nicsToNetworks;
}
Also used : HashMap(java.util.HashMap) Network(org.ovirt.engine.core.common.businessentities.network.Network) List(java.util.List) ArrayList(java.util.ArrayList) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 43 with NetworkAttachment

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

the class NicLabelsCompleter method completeNetworkAttachmentsByLabels.

private void completeNetworkAttachmentsByLabels() {
    for (NicLabel nicLabel : params.getLabels()) {
        List<Network> labelNetworks = labelToNetworks.get(nicLabel.getLabel());
        if (labelNetworks == null) {
            continue;
        }
        for (Network network : labelNetworks) {
            NetworkAttachment newOrModifiedNetworkAttachment = attachmentsByNetworkId.get(network.getId());
            NetworkAttachment existingNetworkAttachment = existingNetworkAttachmentsByNetworkId.get(network.getId());
            boolean existingAttachmentRemoved = existingNetworkAttachment == null ? false : params.getRemovedNetworkAttachments().contains(existingNetworkAttachment.getId());
            boolean noNewOrModifiedNetworkAttachment = newOrModifiedNetworkAttachment == null;
            NetworkAttachment attachmentToConfigure = noNewOrModifiedNetworkAttachment && !existingAttachmentRemoved ? existingNetworkAttachment : newOrModifiedNetworkAttachment;
            if (attachmentToConfigure == null) {
                params.getNetworkAttachments().add(createNetworkAttachment(nicLabel.getNicId(), nicLabel.getNicName(), network.getId(), network.getName()));
            } else if (!Objects.equals(attachmentToConfigure.getNicName(), nicLabel.getNicName()) && noNewOrModifiedNetworkAttachment) {
                NetworkAttachment updatedNetworkAttachment = new NetworkAttachment(existingNetworkAttachment);
                updatedNetworkAttachment.setNicId(nicLabel.getNicId());
                updatedNetworkAttachment.setNicName(nicLabel.getNicName());
                params.getNetworkAttachments().add(updatedNetworkAttachment);
            }
        }
    }
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) NicLabel(org.ovirt.engine.core.common.businessentities.network.NicLabel) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 44 with NetworkAttachment

use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment 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 45 with NetworkAttachment

use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment 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)

Aggregations

NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)167 Test (org.junit.Test)79 Network (org.ovirt.engine.core.common.businessentities.network.Network)62 Guid (org.ovirt.engine.core.compat.Guid)37 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)36 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)35 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)20 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)18 HashMap (java.util.HashMap)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)15 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)14 ArrayList (java.util.ArrayList)10 IpConfiguration (org.ovirt.engine.core.common.businessentities.network.IpConfiguration)10 ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)9 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)8 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)7 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)7 AnonymousHostNetworkQos (org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos)6 HostSetupNetworksParameters (org.ovirt.engine.core.common.action.HostSetupNetworksParameters)5 BusinessEntityMap (org.ovirt.engine.core.common.businessentities.BusinessEntityMap)5