Search in sources :

Example 21 with IFrontendActionAsyncCallback

use of org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback in project ovirt-engine by oVirt.

the class FrontendActionTest method testrunMultipleActions_multipleaction_success_first_success_second_failure.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run MultipleActions with multiple actions, first success, and second failure.</li>
 *   <li>Check to make sure the success callback is called for the first action</li>
 *   <li>Check to make sure the failure callback is called for the second action</li>
 * </ol>
 */
@Test
public void testrunMultipleActions_multipleaction_success_first_success_second_failure() {
    List<ActionType> actionTypes = new ArrayList<>();
    actionTypes.add(ActionType.AddDisk);
    actionTypes.add(ActionType.AddBricksToGlusterVolume);
    List<ActionParametersBase> testParameters = new ArrayList<>();
    testParameters.add(new ActionParametersBase());
    testParameters.add(new ActionParametersBase());
    List<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
    callbacks.add(mockActionCallback);
    callbacks.add(mockActionCallback);
    frontend.runMultipleActions(actionTypes, testParameters, callbacks, mockActionFailureCallback, testState);
    verify(mockService).runAction(eq(ActionType.AddDisk), eq(testParameters.get(0)), callbackAction.capture());
    ActionReturnValue returnValue = new ActionReturnValue();
    returnValue.setValid(true);
    returnValue.setSucceeded(true);
    callbackAction.getValue().onSuccess(returnValue);
    verify(mockActionCallback).executed(callbackParam.capture());
    assertEquals(returnValue, callbackParam.getValue().getReturnValue());
    // Second call to runAction
    verify(mockService).runAction(eq(ActionType.AddBricksToGlusterVolume), eq(testParameters.get(0)), callbackAction.capture());
    returnValue = new ActionReturnValue();
    returnValue.setValid(false);
    returnValue.setSucceeded(false);
    callbackAction.getValue().onSuccess(returnValue);
    verify(mockActionFailureCallback).executed(callbackParam.capture());
    assertEquals(returnValue, callbackParam.getValue().getReturnValue());
    verifyAsyncActionStartedAndSucceeded();
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 22 with IFrontendActionAsyncCallback

use of org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback in project ovirt-engine by oVirt.

the class SanStorageModelBase method connectTargets.

private void connectTargets() {
    VDS host = getContainer().getHost().getSelectedItem();
    if (host == null) {
        return;
    }
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
    final SanStorageModelBase sanStorageModel = this;
    IFrontendActionAsyncCallback loginCallback = result -> sanStorageModel.postLogin(result.getReturnValue(), sanStorageModel);
    for (int i = 0; i < targetsToConnect.size(); i++) {
        SanTargetModel model = targetsToConnect.get(i);
        StorageServerConnections connection = new StorageServerConnections();
        connection.setStorageType(StorageType.ISCSI);
        // $NON-NLS-1$
        connection.setUserName(getUseUserAuth().getEntity() ? getUserName().getEntity() : "");
        // $NON-NLS-1$
        connection.setPassword(getUseUserAuth().getEntity() ? getPassword().getEntity() : "");
        connection.setIqn(model.getName());
        connection.setConnection(model.getAddress());
        connection.setPort(String.valueOf(model.getPort()));
        connection.setPortal(model.getPortal());
        actionTypes.add(ActionType.ConnectStorageToVds);
        parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
        callbacks.add(loginCallback);
    }
    Object target = getWidgetModel() != null ? getWidgetModel() : getContainer();
    Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, null, target);
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) Event(org.ovirt.engine.ui.uicompat.Event) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) GetDeviceListQueryParameters(org.ovirt.engine.core.common.queries.GetDeviceListQueryParameters) ValueEventArgs(org.ovirt.engine.ui.uicommonweb.models.hosts.ValueEventArgs) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) DiscoverSendTargetsQueryParameters(org.ovirt.engine.core.common.queries.DiscoverSendTargetsQueryParameters) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) EventDefinition(org.ovirt.engine.ui.uicompat.EventDefinition) VDS(org.ovirt.engine.core.common.businessentities.VDS) LunStatus(org.ovirt.engine.core.common.businessentities.storage.LunStatus) ObservableCollection(org.ovirt.engine.ui.uicompat.ObservableCollection) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) ActionType(org.ovirt.engine.core.common.action.ActionType) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)

Example 23 with IFrontendActionAsyncCallback

use of org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback in project ovirt-engine by oVirt.

the class EditDiskModel method store.

@Override
public void store(IFrontendActionAsyncCallback callback) {
    if (getProgress() != null || !validate()) {
        return;
    }
    startProgress();
    VmDiskOperationParameterBase parameters = new VmDiskOperationParameterBase(getDiskVmElement(), getDisk());
    IFrontendActionAsyncCallback onFinished = callback != null ? callback : result -> {
        EditDiskModel diskModel = (EditDiskModel) result.getState();
        diskModel.stopProgress();
        diskModel.cancel();
    };
    Frontend.getInstance().runAction(ActionType.UpdateVmDisk, parameters, onFinished, this);
}
Also used : IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase)

Example 24 with IFrontendActionAsyncCallback

use of org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback in project ovirt-engine by oVirt.

the class DataCenterGuideModel method saveNewPosixStorage.

private void saveNewPosixStorage() {
    StorageModel model = (StorageModel) getWindow();
    PosixStorageModel posixModel = (PosixStorageModel) model.getCurrentStorageItem();
    VDS host = model.getHost().getSelectedItem();
    hostId = host.getId();
    // Create storage connection.
    StorageServerConnections connection = new StorageServerConnections();
    connection.setConnection(path);
    connection.setStorageType(posixModel.getType());
    connection.setVfsType(posixModel.getVfsType().getEntity());
    connection.setMountOptions(posixModel.getMountOptions().getEntity());
    this.connection = connection;
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    actionTypes.add(ActionType.AddStorageServerConnection);
    actionTypes.add(posixModel.getAddStorageDomainVdcAction());
    parameters.add(new StorageServerConnectionParametersBase(this.connection, host.getId(), false));
    StorageDomainManagementParameter parameter = new StorageDomainManagementParameter(storageDomain);
    parameter.setVdsId(host.getId());
    StoragePool dataCenter = model.getDataCenter().getSelectedItem();
    parameter.setStoragePoolId(dataCenter.getId());
    parameters.add(parameter);
    IFrontendActionAsyncCallback callback1 = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        ActionReturnValue actionReturnValue = result.getReturnValue();
        dataCenterGuideModel.storageDomain.setStorage((String) actionReturnValue.getActionReturnValue());
        dataCenterGuideModel.connection.setId((String) actionReturnValue.getActionReturnValue());
    };
    IFrontendActionAsyncCallback callback2 = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        ActionReturnValue actionReturnValue = result.getReturnValue();
        dataCenterGuideModel.storageId = actionReturnValue.getActionReturnValue();
        // Attach storage to data center as necessary.
        StorageModel storageModel = (StorageModel) dataCenterGuideModel.getWindow();
        StoragePool selectedDataCenter = storageModel.getDataCenter().getSelectedItem();
        if (!selectedDataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
            dataCenterGuideModel.attachStorageToDataCenter(dataCenterGuideModel.storageId, selectedDataCenter.getId());
        }
        dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
    };
    IFrontendActionAsyncCallback failureCallback = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        dataCenterGuideModel.cleanConnection(dataCenterGuideModel.connection, dataCenterGuideModel.hostId);
        dataCenterGuideModel.onFinish(dataCenterGuideModel.context, false, dataCenterGuideModel.storageModel);
    };
    Frontend.getInstance().runMultipleActions(actionTypes, parameters, new ArrayList<>(Arrays.asList(new IFrontendActionAsyncCallback[] { callback1, callback2 })), failureCallback, this);
}
Also used : PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) SearchType(org.ovirt.engine.core.common.interfaces.SearchType) Arrays(java.util.Arrays) RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) NewHostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.NewHostModel) GuideModel(org.ovirt.engine.ui.uicommonweb.models.GuideModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) ManagementNetworkOnClusterOperationParameters(org.ovirt.engine.core.common.action.ManagementNetworkOnClusterOperationParameters) PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) NewEditStorageModelBehavior(org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior) AttachStorageDomainToPoolParameters(org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) AddSANStorageDomainParameters(org.ovirt.engine.core.common.action.AddSANStorageDomainParameters) StorageDomainSharedStatus(org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus) Collectors(java.util.stream.Collectors) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) ClusterModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) HostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostModel) ITaskTarget(org.ovirt.engine.ui.uicompat.ITaskTarget) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) TaskContext(org.ovirt.engine.ui.uicompat.TaskContext) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) FrontendMultipleActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult) Task(org.ovirt.engine.ui.uicompat.Task) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) GetDeviceListQueryParameters(org.ovirt.engine.core.common.queries.GetDeviceListQueryParameters) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) ClusterListModel(org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterListModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) StoragePoolStatus(org.ovirt.engine.core.common.businessentities.StoragePoolStatus) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) LunModel(org.ovirt.engine.ui.uicommonweb.models.storage.LunModel) Timer(com.google.gwt.user.client.Timer) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) ActionType(org.ovirt.engine.core.common.action.ActionType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) PosixStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.PosixStorageModel) IStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.IStorageModel) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel) StorageDomainManagementParameter(org.ovirt.engine.core.common.action.StorageDomainManagementParameter) ArrayList(java.util.ArrayList) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)

Aggregations

IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)24 ArrayList (java.util.ArrayList)17 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)16 ActionType (org.ovirt.engine.core.common.action.ActionType)16 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)15 List (java.util.List)10 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)10 Guid (org.ovirt.engine.core.compat.Guid)10 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 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)10 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)10 QueryType (org.ovirt.engine.core.common.queries.QueryType)9 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)9 HashSet (java.util.HashSet)8 Set (java.util.Set)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)8 StorageDomainManagementParameter (org.ovirt.engine.core.common.action.StorageDomainManagementParameter)7