Search in sources :

Example 1 with GlusterHookManageParameters

use of org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters 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);
    }
}
Also used : GlusterHookManageParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters) GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) GlusterHookStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus) Guid(org.ovirt.engine.core.compat.Guid) GlusterHookContentType(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) GlusterHookParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookParameters) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) GlusterClusterParameters(org.ovirt.engine.core.common.action.gluster.GlusterClusterParameters) GlusterHookParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) GlusterHookManageParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters) GlusterHookEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) GlusterServerHook(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook)

Example 2 with GlusterHookManageParameters

use of org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters in project ovirt-engine by oVirt.

the class BackendGlusterHookResource method copy.

private Response copy(Action action) {
    GlusterHookManageParameters params = new GlusterHookManageParameters(guid);
    if (action.isSetHost()) {
        validateParameters(action.getHost(), "id|name");
        Guid hostId = getHostId(action);
        params.setSourceServerId(hostId);
    }
    return doAction(ActionType.UpdateGlusterHook, params, action);
}
Also used : GlusterHookManageParameters(org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

GlusterHookManageParameters (org.ovirt.engine.core.common.action.gluster.GlusterHookManageParameters)2 Guid (org.ovirt.engine.core.compat.Guid)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 GlusterClusterParameters (org.ovirt.engine.core.common.action.gluster.GlusterClusterParameters)1 GlusterHookParameters (org.ovirt.engine.core.common.action.gluster.GlusterHookParameters)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 GlusterHookContentType (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookContentType)1 GlusterHookEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity)1 GlusterHookStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterHookStatus)1 GlusterServerHook (org.ovirt.engine.core.common.businessentities.gluster.GlusterServerHook)1 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)1 Frontend (org.ovirt.engine.ui.frontend.Frontend)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)1 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)1 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1