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;
}
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();
}
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;
}
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;
}
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));
}
Aggregations