Search in sources :

Example 36 with NetworkCluster

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

the class NetworkClusterListModel method createManageList.

private ClusterNetworkManageModel createManageList() {
    List<ClusterNetworkModel> networkManageModelList = new ArrayList<>();
    Iterable<PairQueryable<Cluster, NetworkCluster>> items = getItems();
    for (PairQueryable<Cluster, NetworkCluster> item : items) {
        Network network = (Network) Cloner.clone(getEntity());
        if (item.getSecond() != null) {
            network.setCluster((NetworkCluster) Cloner.clone(item.getSecond()));
        }
        ClusterNetworkModel networkManageModel = new ClusterNetworkModel(network) {

            @Override
            public String getDisplayedName() {
                return getCluster().getName();
            }
        };
        networkManageModel.setCluster((Cluster) Cloner.clone(item.getFirst()));
        networkManageModelList.add(networkManageModel);
    }
    Collections.sort(networkManageModelList, manageModelComparator);
    ClusterNetworkManageModel listModel = new ClusterNetworkManageModel(this) {

        @Override
        public boolean isMultiCluster() {
            return true;
        }
    };
    listModel.setItems(networkManageModelList);
    return listModel;
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) ClusterNetworkModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterNetworkModel) Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) ClusterNetworkManageModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterNetworkManageModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 37 with NetworkCluster

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

the class ClusterNetworkManageModel method onManage.

private void onManage() {
    Iterable<ClusterNetworkModel> manageList = getItems();
    final List<NetworkCluster> toAttach = new ArrayList<>();
    final List<NetworkCluster> toDetach = new ArrayList<>();
    final List<NetworkCluster> toUpdate = new ArrayList<>();
    for (ClusterNetworkModel manageModel : manageList) {
        NetworkCluster networkCluster = manageModel.getOriginalNetworkCluster();
        boolean wasAttached = networkCluster != null;
        boolean needsAttach = manageModel.isAttached() && !wasAttached;
        boolean needsDetach = !manageModel.isAttached() && wasAttached;
        boolean needsUpdate = false;
        // Attachment wasn't changed- check if needs update
        if (wasAttached && !needsDetach) {
            if ((manageModel.isRequired() != networkCluster.isRequired()) || manageModel.isDisplayNetwork() != networkCluster.isDisplay() || manageModel.isMigrationNetwork() != networkCluster.isMigration() || manageModel.isManagement() != networkCluster.isManagement() || manageModel.isDefaultRouteNetwork() != networkCluster.isDefaultRoute() || manageModel.isGlusterNetwork() != networkCluster.isGluster()) {
                needsUpdate = true;
                copyRoles(manageModel, networkCluster);
            }
        }
        if (needsAttach) {
            toAttach.add(createNetworkCluster(manageModel));
        }
        if (needsDetach) {
            toDetach.add(networkCluster);
        }
        if (needsUpdate) {
            toUpdate.add(networkCluster);
        }
    }
    startProgress();
    needsAnyChange = !(toAttach.isEmpty() && toDetach.isEmpty() && toUpdate.isEmpty());
    if (needsAnyChange) {
        Frontend.getInstance().runAction(ActionType.ManageNetworkClusters, new ManageNetworkClustersParameters(toAttach, toDetach, toUpdate), result -> {
            needsAnyChange = false;
            doFinish();
        });
    }
    doFinish();
}
Also used : ManageNetworkClustersParameters(org.ovirt.engine.core.common.action.ManageNetworkClustersParameters) ArrayList(java.util.ArrayList) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 38 with NetworkCluster

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

the class NetworkClusterHelperTest method createNetworkCluster.

private NetworkCluster createNetworkCluster(Guid clusterId, Guid networkId) {
    NetworkCluster result = new NetworkCluster();
    result.setId(new NetworkClusterId(clusterId, networkId));
    return result;
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)

Example 39 with NetworkCluster

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

the class NetworkClusterValidatorTestBase method createNetworkCluster.

private NetworkCluster createNetworkCluster() {
    NetworkCluster networkCluster = new NetworkCluster();
    networkCluster.setClusterId(TEST_CLUSTER_ID);
    return networkCluster;
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 40 with NetworkCluster

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

the class DefaultRouteUtilImplTest method testIsDefaultRouteWhenNetworkClusterExist.

private void testIsDefaultRouteWhenNetworkClusterExist(boolean isDefaultRoute) {
    NetworkCluster networkCluster = new NetworkCluster();
    networkCluster.setDefaultRoute(isDefaultRoute);
    when(networkClusterDao.get(new NetworkClusterId(clusterId, networkId))).thenReturn(networkCluster);
    assertThat(underTest.isDefaultRouteNetwork(networkId, clusterId), is(isDefaultRoute));
}
Also used : NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) NetworkClusterId(org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)

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