Search in sources :

Example 51 with NetworkCluster

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

the class NetworkUtilsTest method isRoleNetworkNoRoles.

@Test
public void isRoleNetworkNoRoles() {
    NetworkCluster networkCluster = createNetworkCluster(false, false, false);
    assertFalse(NetworkUtils.isRoleNetwork(networkCluster));
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) Test(org.junit.Test)

Example 52 with NetworkCluster

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

the class NetworkUtilsTest method isRoleNetworkAllRoles.

@Test
public void isRoleNetworkAllRoles() {
    NetworkCluster networkCluster = createNetworkCluster(true, true, true);
    assertTrue(NetworkUtils.isRoleNetwork(networkCluster));
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) Test(org.junit.Test)

Example 53 with NetworkCluster

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

the class NetworkUtilsTest method createNetworkCluster.

private NetworkCluster createNetworkCluster(boolean display, boolean migration, boolean gluster) {
    NetworkCluster networkCluster = new NetworkCluster();
    networkCluster.setDisplay(display);
    networkCluster.setMigration(migration);
    networkCluster.setGluster(gluster);
    return networkCluster;
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 54 with NetworkCluster

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

the class NetworkClustersToSetupNetworksParametersTransformerImpl method getUpdatedNetworksByHost.

/**
 * @param updates NetworkCluster instances related to updated networks
 * @return Mapping HostId to list of updated networks, which relates to NetworkCluster from parameter.
 */
private Map<Guid, List<Network>> getUpdatedNetworksByHost(Collection<NetworkCluster> updates) {
    Map<Guid, List<Network>> result = new HashMap<>();
    Map<Guid, List<NetworkCluster>> updatesByClusterId = updates.stream().collect(Collectors.groupingBy(NetworkCluster::getClusterId));
    Set<Guid> idsOfUpdatedNetworks = updates.stream().map(NetworkCluster::getNetworkId).collect(Collectors.toSet());
    for (Guid clusterId : updatesByClusterId.keySet()) {
        Map<String, Network> clusterNetworksByName = networkDao.getAllForCluster(clusterId).stream().filter(network -> idsOfUpdatedNetworks.contains(network.getId())).collect(Collectors.toMap(Network::getName, Function.identity()));
        List<VdsNetworkInterface> interfacesOfCluster = interfaceDao.getAllInterfacesByClusterId(clusterId);
        for (VdsNetworkInterface iface : interfacesOfCluster) {
            if (!clusterNetworksByName.containsKey(iface.getNetworkName())) {
                continue;
            }
            Network network = clusterNetworksByName.get(iface.getNetworkName());
            Guid vdsId = iface.getVdsId();
            VdsNetworkInterface.NetworkImplementationDetails networkImplementationDetails = networkImplementationDetailsUtils.calculateNetworkImplementationDetails(iface, network);
            boolean networkShouldBeSynced = networkImplementationDetails != null && !networkImplementationDetails.isInSync();
            if (networkShouldBeSynced) {
                if (!result.containsKey(vdsId)) {
                    result.put(vdsId, new ArrayList<>());
                }
                result.get(vdsId).add(network);
            }
        }
    }
    return result;
}
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) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArrayList(java.util.ArrayList) CollectionUtils.nullToEmptyList(org.ovirt.engine.core.utils.CollectionUtils.nullToEmptyList) List(java.util.List)

Example 55 with NetworkCluster

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

the class ManageNetworkClustersCommand method checkDetachmentsPermissions.

private boolean checkDetachmentsPermissions() {
    for (NetworkCluster detachment : getParameters().getDetachments()) {
        final List<PermissionSubject> permissionCheckSubjects = detachPermissionFinder.findPermissionCheckSubjects(detachment.getNetworkId(), DetachNetworkToCluster);
        for (PermissionSubject permissionSubject : permissionCheckSubjects) {
            final ArrayList<String> messages = new ArrayList<>();
            final boolean isUserAllowed = checkSinglePermission(permissionSubject, messages);
            if (!isUserAllowed) {
                getReturnValue().getValidationMessages().addAll(messages);
                return false;
            }
        }
    }
    return true;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Aggregations

NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)62 Test (org.junit.Test)19 Network (org.ovirt.engine.core.common.businessentities.network.Network)17 ArrayList (java.util.ArrayList)15 NetworkClusterId (org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)7 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 ManageNetworkClustersParameters (org.ovirt.engine.core.common.action.ManageNetworkClustersParameters)5 List (java.util.List)4 Map (java.util.Map)4 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)4 Guid (org.ovirt.engine.core.compat.Guid)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2