Search in sources :

Example 46 with Network

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

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

Example 48 with Network

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

the class HostNetworkTopologyPersisterImpl method findNetworksOnInterfaces.

private Collection<Network> findNetworksOnInterfaces(Collection<VdsNetworkInterface> ifaces, Map<String, Network> clusterNetworksByName) {
    final Collection<Network> networks = new ArrayList<>();
    for (VdsNetworkInterface iface : ifaces) {
        final String interfaceNetworkName = iface.getNetworkName();
        if (clusterNetworksByName.containsKey(interfaceNetworkName)) {
            final Network network = clusterNetworksByName.get(interfaceNetworkName);
            networks.add(network);
        }
    }
    return networks;
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

Example 49 with Network

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

the class HostNetworkTopologyPersisterImpl method logChangedDisplayNetwork.

private void logChangedDisplayNetwork(VDS host, Collection<Network> engineHostNetworks, Collection<VdsNetworkInterface> engineInterfaces) {
    if (isVmRunningOnHost(host.getId())) {
        final Network engineDisplayNetwork = findDisplayNetwork(host.getClusterId(), engineHostNetworks);
        if (engineDisplayNetwork == null) {
            return;
        }
        final IsNetworkOnInterfacePredicate isNetworkOnInterfacePredicate = new IsNetworkOnInterfacePredicate(engineDisplayNetwork.getName());
        final VdsNetworkInterface vdsmDisplayInterface = host.getInterfaces().stream().filter(isNetworkOnInterfacePredicate).findFirst().orElse(null);
        final VdsNetworkInterface engineDisplayInterface = engineInterfaces.stream().filter(isNetworkOnInterfacePredicate).findFirst().orElse(null);
        final DisplayInterfaceEqualityPredicate displayIneterfaceEqualityPredicate = new DisplayInterfaceEqualityPredicate(engineDisplayInterface);
        if (// the display interface is't on host anymore
        vdsmDisplayInterface == null || !displayIneterfaceEqualityPredicate.test(vdsmDisplayInterface)) {
            final AuditLogable loggable = createAuditLogForHost(host);
            auditLogDirector.log(loggable, AuditLogType.NETWORK_UPDATE_DISPLAY_FOR_HOST_WITH_ACTIVE_VM);
        }
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) Network(org.ovirt.engine.core.common.businessentities.network.Network) DisplayInterfaceEqualityPredicate(org.ovirt.engine.core.vdsbroker.vdsbroker.predicates.DisplayInterfaceEqualityPredicate) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) IsNetworkOnInterfacePredicate(org.ovirt.engine.core.vdsbroker.vdsbroker.predicates.IsNetworkOnInterfacePredicate)

Example 50 with Network

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

the class HostNetworkTopologyPersisterImpl method getVmNetworksImplementedAsBridgeless.

private String getVmNetworksImplementedAsBridgeless(VDS host, List<Network> clusterNetworks) {
    Map<String, VdsNetworkInterface> interfacesByNetworkName = NetworkUtils.hostInterfacesByNetworkName(host.getInterfaces());
    List<String> networkNames = new ArrayList<>();
    for (Network net : clusterNetworks) {
        if (net.isVmNetwork() && interfacesByNetworkName.containsKey(net.getName()) && !interfacesByNetworkName.get(net.getName()).isBridged()) {
            networkNames.add(net.getName());
        }
    }
    return StringUtils.join(networkNames, ",");
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

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