Search in sources :

Example 81 with Network

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

the class UpdateNetworkCommand method onlyPermittedFieldsChanged.

/**
 * @return <code>true</code> iff only the description or comment field were changed, otherwise <code>false</code>.
 */
private boolean onlyPermittedFieldsChanged() {
    Network oldNetwork = getOldNetwork();
    Network newNetwork = getNetwork();
    if (oldNetwork == null || newNetwork == null) {
        return false;
    }
    return Objects.equals(oldNetwork.getName(), newNetwork.getName()) && Objects.equals(oldNetwork.getDataCenterId(), newNetwork.getDataCenterId()) && Objects.equals(oldNetwork.getId(), newNetwork.getId()) && Objects.equals(oldNetwork.getMtu(), newNetwork.getMtu()) && Objects.equals(oldNetwork.getName(), newNetwork.getName()) && Objects.equals(oldNetwork.getProvidedBy(), newNetwork.getProvidedBy()) && Objects.equals(oldNetwork.getStp(), newNetwork.getStp()) && Objects.equals(oldNetwork.getVlanId(), newNetwork.getVlanId()) && Objects.equals(oldNetwork.isVmNetwork(), newNetwork.isVmNetwork());
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network)

Example 82 with Network

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

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

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

Example 85 with Network

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

the class HostSetupNetworksValidator method validateCustomProperties.

ValidationResult validateCustomProperties(SimpleCustomPropertiesUtil util, Map<String, String> validPropertiesForVm, Map<String, String> validPropertiesForNonVm) {
    for (NetworkAttachment attachment : params.getNetworkAttachments()) {
        Network network = existingNetworkRelatedToAttachment(attachment);
        if (attachment.hasProperties()) {
            List<ValidationError> errors = util.validateProperties(network.isVmNetwork() ? validPropertiesForVm : validPropertiesForNonVm, attachment.getProperties());
            if (!errors.isEmpty()) {
                handleCustomPropertiesError(util, errors);
                EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_NETWORK_CUSTOM_PROPERTIES_BAD_INPUT;
                return new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentStringWithMultipleValues(engineMessage, network.getName()));
            }
        }
    }
    return ValidationResult.VALID;
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) ValidationError(org.ovirt.engine.core.common.utils.customprop.ValidationError) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Aggregations

Network (org.ovirt.engine.core.common.businessentities.network.Network)292 Test (org.junit.Test)105 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)63 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)47 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)46 ArrayList (java.util.ArrayList)44 Guid (org.ovirt.engine.core.compat.Guid)44 ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)39 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)23 List (java.util.List)21 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)21 HashMap (java.util.HashMap)19 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)19 Map (java.util.Map)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 VnicProfile (org.ovirt.engine.core.common.businessentities.network.VnicProfile)13 HashSet (java.util.HashSet)9 Set (java.util.Set)9 BusinessEntityMap (org.ovirt.engine.core.common.businessentities.BusinessEntityMap)9 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)9