Search in sources :

Example 1 with ManageNetworksParametersBuilder

use of org.ovirt.engine.core.bll.network.ManageNetworksParametersBuilder in project ovirt-engine by oVirt.

the class NetworkClustersToSetupNetworksParametersTransformerImpl method createSetupNetworksParameters.

private List<PersistentHostSetupNetworksParameters> createSetupNetworksParameters(Map<Guid, List<Network>> attachNetworksByHost, Map<Guid, Map<String, VdsNetworkInterface>> labelsToNicsByHost, Map<Guid, List<Network>> detachNetworksByHost, Map<Guid, List<Network>> updates) {
    final List<PersistentHostSetupNetworksParameters> parameters = new ArrayList<>(attachNetworksByHost.size());
    final ManageNetworksParametersBuilder builder = manageNetworksParametersBuilderFactory.create(commandContext, interfaceDao, vdsStaticDao, networkClusterDao, networkAttachmentDao);
    Set<Guid> hostIds = Stream.of(attachNetworksByHost, detachNetworksByHost, updates).flatMap(e -> e.keySet().stream()).collect(Collectors.toSet());
    for (Guid hostId : hostIds) {
        final Map<String, VdsNetworkInterface> nicsByLabel = labelsToNicsByHost.get(hostId);
        parameters.add(builder.buildParameters(hostId, nullToEmptyList(attachNetworksByHost.get(hostId)), nullToEmptyList(detachNetworksByHost.get(hostId)), nicsByLabel == null ? Collections.emptyMap() : nicsByLabel, nullToEmptyList(updates.get(hostId))));
    }
    return parameters;
}
Also used : ManageNetworksParametersBuilderFactory(org.ovirt.engine.core.bll.network.ManageNetworksParametersBuilderFactory) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) NetworkImplementationDetailsUtils(org.ovirt.engine.core.vdsbroker.NetworkImplementationDetailsUtils) Function(java.util.function.Function) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) NetworkAttachmentDao(org.ovirt.engine.core.dao.network.NetworkAttachmentDao) ArrayList(java.util.ArrayList) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) Map(java.util.Map) Network(org.ovirt.engine.core.common.businessentities.network.Network) ManageNetworksParametersBuilder(org.ovirt.engine.core.bll.network.ManageNetworksParametersBuilder) PersistentHostSetupNetworksParameters(org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters) CollectionUtils.nullToEmptyList(org.ovirt.engine.core.utils.CollectionUtils.nullToEmptyList) Collection(java.util.Collection) Set(java.util.Set) NetworkDao(org.ovirt.engine.core.dao.network.NetworkDao) Collectors(java.util.stream.Collectors) VdsStaticDao(org.ovirt.engine.core.dao.VdsStaticDao) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) InterfaceDao(org.ovirt.engine.core.dao.network.InterfaceDao) Collections(java.util.Collections) NetworkClusterDao(org.ovirt.engine.core.dao.network.NetworkClusterDao) PersistentHostSetupNetworksParameters(org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters) ManageNetworksParametersBuilder(org.ovirt.engine.core.bll.network.ManageNetworksParametersBuilder) ArrayList(java.util.ArrayList) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 ManageNetworksParametersBuilder (org.ovirt.engine.core.bll.network.ManageNetworksParametersBuilder)1 ManageNetworksParametersBuilderFactory (org.ovirt.engine.core.bll.network.ManageNetworksParametersBuilderFactory)1 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)1 Network (org.ovirt.engine.core.common.businessentities.network.Network)1 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)1 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)1 Guid (org.ovirt.engine.core.compat.Guid)1 VdsStaticDao (org.ovirt.engine.core.dao.VdsStaticDao)1