Search in sources :

Example 6 with ActionType

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

the class GWTRPCCommunicationProviderTest method testGetOperationResult_One.

@Test
public void testGetOperationResult_One() {
    VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.ActivateVds, new ActionParametersBase(), null);
    List<VdcOperation<?, ?>> testOperationList = new ArrayList<>();
    testOperationList.add(testOperation1);
    List<VdcOperation<?, ?>> allOperationList = new ArrayList<>();
    allOperationList.add(testOperation1);
    ActionReturnValue testResult1 = new ActionReturnValue();
    List<ActionReturnValue> allResults = new ArrayList<>();
    allResults.add(testResult1);
    List<?> result = testProvider.getOperationResult(testOperationList, allOperationList, allResults);
    // $NON-NLS-1$
    assertEquals("Result should have one results", 1, result.size());
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 7 with ActionType

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

the class OperationProcessorTest method testOnOperationAvailableSingle.

@Test
public void testOnOperationAvailableSingle() {
    ActionParametersBase testParameter = new ActionParametersBase();
    VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddEventSubscription, testParameter, mockCallback1);
    when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation).thenReturn(null);
    testProcessor.processAvailableOperations(mockOperationManager);
    verify(mockProvider).transmitOperationList(operationListCaptor.capture());
    // Test that we inserted the callback from the processor.
    assertFalse(// $NON-NLS-1$
    "The callbacks should not match.", operationListCaptor.getValue().get(0).getCallback().equals(mockCallback1));
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 8 with ActionType

use of org.ovirt.engine.core.common.action.ActionType 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 9 with ActionType

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

the class ClusterListModel method onSaveInternalWithModel.

private void onSaveInternalWithModel(final ClusterModel model) {
    Cluster cluster = buildCluster(model, model.getIsNew() ? new Cluster() : (Cluster) Cloner.clone(getSelectedItem()));
    model.startProgress();
    final Network managementNetwork = model.getManagementNetwork().getSelectedItem();
    final ManagementNetworkOnClusterOperationParameters clusterOperationParameters = new ManagementNetworkOnClusterOperationParameters(cluster, managementNetwork.getId());
    final ActionType actionType = model.getIsNew() ? ActionType.AddCluster : ActionType.UpdateCluster;
    Frontend.getInstance().runAction(actionType, clusterOperationParameters, result -> {
        ClusterListModel<Void> localModel = (ClusterListModel<Void>) result.getState();
        if (model.getIsImportGlusterConfiguration().getEntity()) {
            localModel.postOnSaveInternalWithImport(result.getReturnValue());
        } else {
            localModel.postOnSaveInternal(result.getReturnValue());
        }
    }, this);
}
Also used : ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) ActionType(org.ovirt.engine.core.common.action.ActionType) Network(org.ovirt.engine.core.common.businessentities.network.Network) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 10 with ActionType

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

the class QuotaListModel method onCreateQuotaInternal.

private void onCreateQuotaInternal(boolean isClone) {
    QuotaModel model = (QuotaModel) getWindow();
    if (!model.validate()) {
        return;
    }
    Quota quota = model.getEntity();
    quota.setQuotaName(model.getName().getEntity());
    quota.setDescription(model.getDescription().getEntity());
    quota.setStoragePoolId(model.getDataCenter().getSelectedItem().getId());
    quota.setGraceClusterPercentage(model.getGraceClusterAsInteger());
    quota.setGraceStoragePercentage(model.getGraceStorageAsInteger());
    quota.setThresholdClusterPercentage(model.getThresholdClusterAsInteger());
    quota.setThresholdStoragePercentage(model.getThresholdStorageAsInteger());
    if (model.getGlobalClusterQuota().getEntity()) {
        QuotaCluster quotaCluster;
        for (QuotaCluster iter : model.getQuotaClusters().getItems()) {
            quota.setGlobalQuotaCluster(new QuotaCluster());
            quota.getGlobalQuotaCluster().setMemSizeMB(iter.getMemSizeMB());
            quota.getGlobalQuotaCluster().setVirtualCpu(iter.getVirtualCpu());
            quota.getQuotaClusters().clear();
        }
    } else {
        quota.setGlobalQuotaCluster(null);
        ArrayList<QuotaCluster> quotaClusterList = new ArrayList<>();
        QuotaCluster quotaCluster;
        for (QuotaCluster iter : model.getAllDataCenterClusters().getItems()) {
            quotaCluster = iter;
            if (quotaCluster.getMemSizeMB() != null) {
                quotaClusterList.add(quotaCluster);
            }
        }
        quota.setQuotaClusters(quotaClusterList);
    }
    if (model.getGlobalStorageQuota().getEntity()) {
        QuotaStorage quotaStorage;
        for (QuotaStorage iter : model.getQuotaStorages().getItems()) {
            quota.setGlobalQuotaStorage(new QuotaStorage());
            quota.getGlobalQuotaStorage().setStorageSizeGB(iter.getStorageSizeGB());
            quota.getQuotaStorages().clear();
        }
    } else {
        quota.setGlobalQuotaStorage(null);
        ArrayList<QuotaStorage> quotaStorageList = new ArrayList<>();
        QuotaStorage quotaStorage;
        for (QuotaStorage iter : model.getAllDataCenterStorages().getItems()) {
            quotaStorage = iter;
            if (quotaStorage.getStorageSizeGB() != null) {
                quotaStorageList.add(quotaStorage);
            }
        }
        quota.setQuotaStorages(quotaStorageList);
    }
    Guid guid = quota.getId();
    QuotaCRUDParameters parameters = new QuotaCRUDParameters(quota);
    if (isClone) {
        parameters.setCopyPermissions(model.getCopyPermissions().getEntity());
        parameters.setQuotaId(quota.getId());
        quota.setId(Guid.Empty);
    }
    ActionType actionType = ActionType.AddQuota;
    if (!quota.getId().equals(Guid.Empty)) {
        actionType = ActionType.UpdateQuota;
    }
    Frontend.getInstance().runAction(actionType, parameters, result -> setWindow(null));
    quota.setId(guid);
}
Also used : QuotaCRUDParameters(org.ovirt.engine.core.common.action.QuotaCRUDParameters) QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) ActionType(org.ovirt.engine.core.common.action.ActionType) Quota(org.ovirt.engine.core.common.businessentities.Quota) ArrayList(java.util.ArrayList) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

ActionType (org.ovirt.engine.core.common.action.ActionType)58 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)37 ArrayList (java.util.ArrayList)31 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)24 Test (org.junit.Test)23 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)16 Guid (org.ovirt.engine.core.compat.Guid)15 List (java.util.List)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)11 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)10 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)10 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)9 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)9 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)9 Arrays (java.util.Arrays)7 HashSet (java.util.HashSet)7 Set (java.util.Set)7