use of org.ovirt.engine.core.common.action.gluster.GlusterHookParameters in project ovirt-engine by oVirt.
the class ClusterGlusterHookListModel method enableHook.
private void enableHook() {
if (getEntity() == null || getSelectedItems() == null || getSelectedItems().size() == 0) {
return;
}
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (GlusterHookEntity hook : getSelectedItems()) {
list.add(new GlusterHookParameters(hook.getId()));
}
Frontend.getInstance().runMultipleAction(ActionType.EnableGlusterHook, list, null, null);
}
use of org.ovirt.engine.core.common.action.gluster.GlusterHookParameters in project ovirt-engine by oVirt.
the class ClusterGlusterHookListModel method onResolveConflicts.
/*
* If there are multiple types of conflicts found for a hook and the user choose to resolve them. The conflicts will
* be resolved in the following order 1)Content Conflict, 2)Status Conflict, 3)Missing Conflict
*
* If any conflict resolution is failed the next one will not be executed
*/
private void onResolveConflicts() {
final GlusterHookResolveConflictsModel resolveConflictsModel = (GlusterHookResolveConflictsModel) getWindow();
if (resolveConflictsModel == null) {
return;
}
if (!resolveConflictsModel.isAnyResolveActionSelected()) {
resolveConflictsModel.setMessage(ConstantsManager.getInstance().getConstants().noResolveActionSelectedGlusterHook());
return;
}
resolveConflictsModel.startProgress();
GlusterHookEntity hookEntity = resolveConflictsModel.getGlusterHookEntity();
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
if (resolveConflictsModel.getResolveContentConflict().getEntity()) {
actionTypes.add(ActionType.UpdateGlusterHook);
GlusterServerHook serverHook = resolveConflictsModel.getServerHooksList().getSelectedItem();
Guid serverId = (serverHook == null) ? null : serverHook.getServerId();
parameters.add(new GlusterHookManageParameters(hookEntity.getId(), serverId));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveContentConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveContentConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
if (resolveConflictsModel.getResolveStatusConflict().getEntity()) {
boolean isEnable = resolveConflictsModel.getResolveStatusConflictEnable().getEntity();
actionTypes.add(isEnable ? ActionType.EnableGlusterHook : ActionType.DisableGlusterHook);
parameters.add(new GlusterHookParameters(hookEntity.getId()));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveStatusConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveStatusConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
if (resolveConflictsModel.getResolveMissingConflict().getEntity()) {
boolean isAdd = resolveConflictsModel.getResolveMissingConflictCopy().getEntity();
actionTypes.add(isAdd ? ActionType.AddGlusterHook : ActionType.RemoveGlusterHook);
parameters.add(new GlusterHookManageParameters(hookEntity.getId()));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveMissingConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveMissingConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
IFrontendActionAsyncCallback onFinishCallback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.stopProgress();
cancel();
syncSearch();
}
};
IFrontendActionAsyncCallback failureCallback = result -> resolveConflictsModel.stopProgress();
// Replacing the last callback with onFinishCallback, as we just want to close the dialog and execute the search
if (callbacks.size() > 0) {
callbacks.remove(callbacks.size() - 1);
callbacks.add(onFinishCallback);
Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, failureCallback, null);
}
}
use of org.ovirt.engine.core.common.action.gluster.GlusterHookParameters in project ovirt-engine by oVirt.
the class ClusterGlusterHookListModel method onDisableHook.
private void onDisableHook() {
if (getConfirmWindow() == null) {
return;
}
ConfirmationModel model = (ConfirmationModel) getConfirmWindow();
if (model.getProgress() != null) {
return;
}
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (Object item : getSelectedItems()) {
GlusterHookEntity hook = (GlusterHookEntity) item;
list.add(new GlusterHookParameters(hook.getId()));
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.DisableGlusterHook, list, result -> {
ConfirmationModel localModel = (ConfirmationModel) result.getState();
localModel.stopProgress();
cancelConfirmation();
}, model);
}
Aggregations