Search in sources :

Example 21 with ActionType

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

the class AttachDiskModel method store.

@Override
public void store(IFrontendActionAsyncCallback callback) {
    if (getProgress() != null || !validate()) {
        return;
    }
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> paramerterList = new ArrayList<>();
    ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
    IFrontendActionAsyncCallback onFinishCallback = callback != null ? callback : result -> {
        NewDiskModel diskModel = (NewDiskModel) result.getState();
        diskModel.stopProgress();
        diskModel.cancel();
    };
    List<EntityModel<DiskModel>> disksToAttach = getSelectedDisks();
    for (int i = 0; i < disksToAttach.size(); i++) {
        DiskModel disk = disksToAttach.get(i).getEntity();
        /*
            IDE disks can be activated only when the VM is down.
            Other disks can be hot plugged.
             */
        boolean activate = false;
        if (getIsPlugged().getEntity()) {
            activate = disk.getDiskInterface().getSelectedItem() == DiskInterface.IDE ? getVm().getStatus() == VMStatus.Down : true;
        }
        DiskVmElement dve = new DiskVmElement(disk.getDisk().getId(), getVm().getId());
        dve.setBoot(disk.getIsBootable().getEntity());
        dve.setDiskInterface(disk.getDiskInterface().getSelectedItem());
        dve.setReadOnly(disk.isReadOnly());
        AttachDetachVmDiskParameters parameters = new AttachDetachVmDiskParameters(dve, activate);
        actionTypes.add(ActionType.AttachDiskToVm);
        paramerterList.add(parameters);
        callbacks.add(i == disksToAttach.size() - 1 ? onFinishCallback : null);
    }
    startProgress();
    Frontend.getInstance().runMultipleActions(actionTypes, paramerterList, callbacks, null, this);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) AttachDetachVmDiskParameters(org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 22 with ActionType

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

the class UserListModel method onAdd.

public void onAdd(final boolean closeWindow) {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (model.getSelectedItems() == null) {
        cancel();
        return;
    }
    List<EntityModel<DbUser>> selectedItems = new ArrayList<>();
    for (EntityModel<DbUser> dbUserEntity : model.getItems()) {
        if (dbUserEntity.getIsSelected()) {
            selectedItems.add(dbUserEntity);
        }
    }
    List<ActionType> actionsList = new ArrayList<>(selectedItems.size());
    List<ActionParametersBase> parametersList = new ArrayList<>(selectedItems.size());
    ActionParametersBase parameters = null;
    for (EntityModel<DbUser> item : selectedItems) {
        if (item.getEntity().isGroup()) {
            actionsList.add(ActionType.AddGroup);
            DbGroup grp = new DbGroup();
            grp.setExternalId(item.getEntity().getExternalId());
            grp.setName(item.getEntity().getFirstName());
            grp.setNamespace(item.getEntity().getNamespace());
            grp.setId(item.getEntity().getId());
            grp.setDomain(item.getEntity().getDomain());
            parameters = new AddGroupParameters(grp);
        } else {
            actionsList.add(ActionType.AddUser);
            parameters = new AddUserParameters(item.getEntity());
        }
        parametersList.add(parameters);
    }
    model.startProgress();
    IFrontendActionAsyncCallback lastCallback = result -> {
        AdElementListModel localModel = (AdElementListModel) result.getState();
        localModel.stopProgress();
        // Refresh user list.
        syncSearch();
        if (closeWindow) {
            cancel();
        }
    };
    Collection<EntityModel<DbUser>> currentItems = model.getItems();
    List<IFrontendActionAsyncCallback> callbacksList = new ArrayList<>(selectedItems.size());
    for (EntityModel<DbUser> user : selectedItems) {
        callbacksList.add(nopCallback);
        currentItems.remove(user);
    }
    callbacksList.remove(callbacksList.size() - 1);
    callbacksList.add(lastCallback);
    // Refresh display
    model.setItems(null);
    model.setItems(currentItems);
    Frontend.getInstance().runMultipleActions(actionsList, parametersList, callbacksList, lastCallback, model);
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) QueryType(org.ovirt.engine.core.common.queries.QueryType) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Guid(org.ovirt.engine.core.compat.Guid) AdSearchType(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel.AdSearchType) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) 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) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) UserOrGroup(org.ovirt.engine.core.searchbackend.VdcUserConditionFieldAutoCompleter.UserOrGroup) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) IdParameters(org.ovirt.engine.core.common.action.IdParameters) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) ActionType(org.ovirt.engine.core.common.action.ActionType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 23 with ActionType

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

the class DataCenterGuideModel method saveNewNfsStorage.

public void saveNewNfsStorage() {
    StorageModel model = (StorageModel) getWindow();
    NfsStorageModel nfsModel = (NfsStorageModel) model.getCurrentStorageItem();
    VDS host = model.getHost().getSelectedItem();
    hostId = host.getId();
    // Create storage connection.
    StorageServerConnections tempVar = new StorageServerConnections();
    tempVar.setConnection(path);
    tempVar.setStorageType(nfsModel.getType());
    connection = tempVar;
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    actionTypes.add(ActionType.AddStorageServerConnection);
    actionTypes.add(ActionType.AddNFSStorageDomain);
    actionTypes.add(ActionType.DisconnectStorageServerConnection);
    parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
    StorageDomainManagementParameter tempVar2 = new StorageDomainManagementParameter(storageDomain);
    tempVar2.setVdsId(host.getId());
    parameters.add(tempVar2);
    parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
    IFrontendActionAsyncCallback callback1 = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        ActionReturnValue actionReturnValue = result.getReturnValue();
        dataCenterGuideModel.storageDomain.setStorage((String) actionReturnValue.getActionReturnValue());
    };
    IFrontendActionAsyncCallback callback2 = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        ActionReturnValue actionReturnValue = result.getReturnValue();
        dataCenterGuideModel.storageId = actionReturnValue.getActionReturnValue();
    };
    IFrontendActionAsyncCallback callback3 = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        StorageModel storageModel = (StorageModel) dataCenterGuideModel.getWindow();
        // Attach storage to data center as neccessary.
        StoragePool dataCenter = storageModel.getDataCenter().getSelectedItem();
        if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
            dataCenterGuideModel.attachStorageToDataCenter(dataCenterGuideModel.storageId, dataCenter.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, callback3 })), failureCallback, this);
}
Also used : 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) NfsStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.NfsStorageModel)

Example 24 with ActionType

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

the class DataCenterGuideModel method saveNewLocalStorage.

public void saveNewLocalStorage() {
    StorageModel model = (StorageModel) getWindow();
    LocalStorageModel localModel = (LocalStorageModel) model.getCurrentStorageItem();
    VDS host = model.getHost().getSelectedItem();
    hostId = host.getId();
    // Create storage connection.
    StorageServerConnections tempVar = new StorageServerConnections();
    tempVar.setConnection(path);
    tempVar.setStorageType(localModel.getType());
    connection = tempVar;
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    actionTypes.add(ActionType.AddStorageServerConnection);
    actionTypes.add(ActionType.AddLocalStorageDomain);
    parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
    StorageDomainManagementParameter tempVar2 = new StorageDomainManagementParameter(storageDomain);
    tempVar2.setVdsId(host.getId());
    parameters.add(tempVar2);
    IFrontendActionAsyncCallback callback1 = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        dataCenterGuideModel.removeConnection = true;
        ActionReturnValue actionReturnValue = result.getReturnValue();
        dataCenterGuideModel.storageDomain.setStorage((String) actionReturnValue.getActionReturnValue());
    };
    IFrontendActionAsyncCallback callback2 = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        dataCenterGuideModel.removeConnection = false;
        dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
    };
    IFrontendActionAsyncCallback failureCallback = result -> {
        DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
        if (dataCenterGuideModel.removeConnection) {
            dataCenterGuideModel.cleanConnection(dataCenterGuideModel.connection, dataCenterGuideModel.hostId);
            dataCenterGuideModel.removeConnection = false;
        }
        dataCenterGuideModel.onFinish(dataCenterGuideModel.context, false, dataCenterGuideModel.storageModel);
    };
    Frontend.getInstance().runMultipleActions(actionTypes, parameters, new ArrayList<>(Arrays.asList(new IFrontendActionAsyncCallback[] { callback1, callback2 })), failureCallback, this);
}
Also used : 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) 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) LocalStorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.LocalStorageModel)

Example 25 with ActionType

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

the class VolumeGeoRepListModel method updateConfig.

private void updateConfig() {
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    List<IFrontendActionAsyncCallback> callbacks;
    final GlusterVolumeGeoReplicationSessionConfigModel geoRepConfigModel = (GlusterVolumeGeoReplicationSessionConfigModel) getWindow();
    LinkedHashMap<String, String> oldConfigs = geoRepConfigModel.getConfigs();
    geoRepConfigModel.startProgress();
    for (EntityModel<Pair<Boolean, GlusterGeoRepSessionConfiguration>> newConfigEntity : geoRepConfigModel.getConfigsModel().getItems()) {
        Pair<Boolean, GlusterGeoRepSessionConfiguration> newConfigPair = newConfigEntity.getEntity();
        GlusterGeoRepSessionConfiguration newConfig = newConfigPair.getSecond();
        boolean isOldConfigNull = oldConfigs.get(newConfig.getKey()) == null;
        boolean isNewConfigNull = newConfig.getValue() == null;
        if (!isNewConfigNull && !newConfig.getValue().isEmpty() && (isOldConfigNull || !newConfig.getValue().equals(oldConfigs.get(newConfig.getKey())))) {
            actionTypes.add(ActionType.SetGeoRepConfig);
            parameters.add(geoRepConfigModel.formGeoRepConfigParameters(newConfig));
        }
        if (newConfigPair.getFirst()) {
            actionTypes.add(ActionType.ResetDefaultGeoRepConfig);
            parameters.add(geoRepConfigModel.formGeoRepConfigParameters(newConfig));
        }
    }
    int numberOfConfigUpdates = parameters.size();
    if (numberOfConfigUpdates == 0) {
        geoRepConfigModel.stopProgress();
        closeWindow();
        return;
    }
    callbacks = new ArrayList<>(Collections.nCopies(numberOfConfigUpdates, (IFrontendActionAsyncCallback) null));
    callbacks.set(numberOfConfigUpdates - 1, result -> {
        geoRepConfigModel.stopProgress();
        closeWindow();
    });
    // Failure call back. Update the config list just to reflect any new changes and default error msg
    // dialog is thrown.
    Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, result -> fetchConfigForSession(geoRepConfigModel.getGeoRepSession()), this);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Pair(org.ovirt.engine.core.common.utils.Pair)

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