use of org.ovirt.engine.core.common.action.ManageNetworkClustersParameters in project ovirt-engine by oVirt.
the class AddNetworkCommand method attachToClusters.
private void attachToClusters(List<NetworkCluster> networkAttachments, Guid networkId) {
networkAttachments.forEach(networkCluster -> networkCluster.setNetworkId(networkId));
runInternalAction(ActionType.ManageNetworkClusters, new ManageNetworkClustersParameters(networkAttachments), getContext().clone().withoutLock());
}
use of org.ovirt.engine.core.common.action.ManageNetworkClustersParameters 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.action.ManageNetworkClustersParameters in project ovirt-engine by oVirt.
the class NetworkHelper method attachNetworkToClusters.
public ActionReturnValue attachNetworkToClusters(Guid networkId, Collection<Guid> clusterIds) {
List<NetworkCluster> networkAttachments = createNetworkClusters(clusterIds);
networkAttachments.forEach(networkAttachment -> networkAttachment.setNetworkId(networkId));
return backend.runInternalAction(ActionType.ManageNetworkClusters, new ManageNetworkClustersParameters(networkAttachments));
}
use of org.ovirt.engine.core.common.action.ManageNetworkClustersParameters in project ovirt-engine by oVirt.
the class PropagateNetworksToClusterHostsCommand method mapParametersByClusterId.
private Map<Guid, ManageNetworkClustersParameters> mapParametersByClusterId() {
ManageNetworkClustersParameters parameters = getParameters();
Map<Guid, List<NetworkCluster>> attachmentByClusterId = groupByClusterId(parameters.getAttachments());
Map<Guid, List<NetworkCluster>> detachmentByClusterId = groupByClusterId(parameters.getDetachments());
Map<Guid, List<NetworkCluster>> updatesByClusterId = groupByClusterId(parameters.getUpdates());
Set<Guid> clusterIds = Stream.of(attachmentByClusterId, detachmentByClusterId, updatesByClusterId).flatMap(e -> e.keySet().stream()).collect(Collectors.toSet());
return clusterIds.stream().collect(Collectors.toMap(Function.identity(), clusterId -> new ManageNetworkClustersParameters(nullToEmptyList(attachmentByClusterId.get(clusterId)), nullToEmptyList(detachmentByClusterId.get(clusterId)), nullToEmptyList(updatesByClusterId.get(clusterId)))));
}
Aggregations