Search in sources :

Example 56 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class VolumeBrickListModel method onReplaceConfirmation.

private void onReplaceConfirmation() {
    cancelConfirmation();
    ReplaceBrickModel replaceBrickModel = (ReplaceBrickModel) getWindow();
    GlusterVolumeEntity volumeEntity = getEntity();
    GlusterBrickEntity existingBrick = getSelectedItem();
    if (replaceBrickModel == null || volumeEntity == null || existingBrick == null) {
        return;
    }
    if (!replaceBrickModel.validate()) {
        return;
    }
    VDS server = replaceBrickModel.getServers().getSelectedItem();
    if (server == null) {
        return;
    }
    GlusterBrickEntity newBrick = new GlusterBrickEntity();
    newBrick.setVolumeId(volumeEntity.getId());
    newBrick.setServerId(server.getId());
    newBrick.setServerName(server.getHostName());
    newBrick.setBrickDirectory(replaceBrickModel.getBrickDirectory().getEntity());
    replaceBrickModel.startProgress();
    GlusterVolumeReplaceBrickActionParameters parameter = new GlusterVolumeReplaceBrickActionParameters(volumeEntity.getId(), existingBrick, newBrick);
    Frontend.getInstance().runAction(ActionType.ReplaceGlusterVolumeBrick, parameter, result -> {
        ReplaceBrickModel localModel = (ReplaceBrickModel) result.getState();
        localModel.stopProgress();
        setWindow(null);
    }, replaceBrickModel);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeReplaceBrickActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeReplaceBrickActionParameters)

Example 57 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class VolumeBrickListModel method updateActionAvailability.

private void updateActionAvailability() {
    GlusterVolumeEntity volumeEntity = getEntity();
    boolean allowRemove = true;
    boolean allowReplace = true;
    boolean allowAdvanced = true;
    boolean allowAdd = true;
    boolean allowReset = true;
    if (volumeEntity == null || volumeEntity.getVolumeType().isDispersedType() || !volumeEntity.getVolumeType().isSupported()) {
        allowRemove = false;
        allowAdd = false;
    }
    if (volumeEntity == null || getSelectedItems() == null || getSelectedItems().size() == 0) {
        allowRemove = false;
        allowReplace = false;
        allowAdvanced = false;
        allowReset = false;
    } else {
        if (getSelectedItems().size() == 1) {
            allowAdvanced = volumeEntity.isOnline() && getSelectedItems().get(0).isOnline();
        } else {
            allowReplace = false;
            allowAdvanced = false;
            allowReset = false;
        }
        GlusterAsyncTask volumeTask = volumeEntity.getAsyncTask();
        if (volumeTask != null && (volumeTask.getStatus() == JobExecutionStatus.STARTED || volumeTask.getType() == GlusterTaskType.REMOVE_BRICK && volumeTask.getStatus() == JobExecutionStatus.FINISHED)) {
            allowRemove = false;
            allowReplace = false;
            allowReset = false;
        } else if (volumeEntity.getVolumeType() == GlusterVolumeType.STRIPE || getSelectedItems().size() == volumeEntity.getBricks().size()) {
            allowRemove = false;
        } else if (volumeEntity.getVolumeType() == GlusterVolumeType.REPLICATE && (volumeEntity.getBricks().size() == VolumeListModel.REPLICATE_COUNT_DEFAULT || getSelectedItems().size() > 1)) {
            allowRemove = false;
        }
    }
    getRemoveBricksCommand().setIsExecutionAllowed(allowRemove);
    getReplaceBrickCommand().setIsExecutionAllowed(allowReplace);
    getBrickAdvancedDetailsCommand().setIsExecutionAllowed(allowAdvanced);
    getAddBricksCommand().setIsExecutionAllowed(allowAdd);
    getResetBrickCommand().setIsExecutionAllowed(allowReset);
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)

Example 58 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class VolumeBrickListModel method commitRemoveBricks.

private void commitRemoveBricks() {
    if (getConfirmWindow() != null) {
        return;
    }
    ConfirmationModel model = new ConfirmationModel();
    setConfirmWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().commitRemoveBricksTitle());
    model.setMessage(ConstantsManager.getInstance().getConstants().commitRemoveBricksMessage());
    model.setHelpTag(HelpTag.volume_remove_bricks_commit);
    // $NON-NLS-1$
    model.setHashName("volume_remove_bricks_commit");
    GlusterVolumeEntity volumeEntity = getVolumeEntity();
    GlusterAsyncTask volumeTask = volumeEntity.getAsyncTask();
    ArrayList<String> list = new ArrayList<>();
    for (GlusterBrickEntity brick : volumeEntity.getBricks()) {
        if (brick.getAsyncTask() != null && volumeTask != null && brick.getAsyncTask().getTaskId() != null && brick.getAsyncTask().getTaskId().equals(volumeTask.getTaskId()) && volumeTask.getStatus() == JobExecutionStatus.FINISHED) {
            list.add(brick.getQualifiedName());
        }
    }
    model.setItems(list);
    // $NON-NLS-1$
    UICommand okCommand = UICommand.createDefaultOkUiCommand("OnCommitRemoveBricks", this);
    model.getCommands().add(okCommand);
    // $NON-NLS-1$
    UICommand cancelCommand = UICommand.createCancelUiCommand("CancelConfirmation", this);
    model.getCommands().add(cancelCommand);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 59 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class VolumeBrickListModel method showRemoveBricksStatus.

private void showRemoveBricksStatus() {
    final GlusterVolumeEntity volumeEntity = getVolumeEntity();
    final ArrayList<GlusterBrickEntity> bricks = new ArrayList<>();
    for (GlusterBrickEntity brick : volumeEntity.getBricks()) {
        if (brick.getAsyncTask() != null && brick.getAsyncTask().getTaskId() != null) {
            bricks.add(brick);
        }
    }
    final ConfirmationModel cModel = new ConfirmationModel();
    cModel.setHelpTag(HelpTag.volume_remove_bricks_status);
    // //$NON-NLS-1$
    cModel.setHashName("volume_remove_bricks_status");
    // $NON-NLS-1$
    UICommand removeBrickStatusOk = new UICommand("CancelConfirmation", VolumeBrickListModel.this);
    removeBrickStatusOk.setTitle(ConstantsManager.getInstance().getConstants().ok());
    removeBrickStatusOk.setIsCancel(true);
    cModel.startProgress(ConstantsManager.getInstance().getConstants().fetchingDataMessage());
    cModel.getCommands().add(removeBrickStatusOk);
    cModel.setTitle(ConstantsManager.getInstance().getConstants().removeBricksStatusTitle());
    setConfirmWindow(cModel);
    // $NON-NLS-1$
    final UICommand stopRemoveBrickFromStatus = new UICommand("StopRemoveBricksOnStatus", this);
    stopRemoveBrickFromStatus.setTitle(ConstantsManager.getInstance().getConstants().stopRemoveBricksButton());
    stopRemoveBrickFromStatus.setIsExecutionAllowed(false);
    // $NON-NLS-1$
    final UICommand commitRemoveBrickFromStatus = new UICommand("CommitRemoveBricksOnStatus", this);
    commitRemoveBrickFromStatus.setTitle(ConstantsManager.getInstance().getConstants().commitRemoveBricksButton());
    commitRemoveBrickFromStatus.setIsExecutionAllowed(false);
    // $NON-NLS-1$
    final UICommand retainBricksFromStatus = new UICommand("RetainBricksOnStatus", this);
    retainBricksFromStatus.setTitle(ConstantsManager.getInstance().getConstants().retainBricksButton());
    retainBricksFromStatus.setIsExecutionAllowed(false);
    // $NON-NLS-1$
    final UICommand cancelCommand = new UICommand("CancelRemoveBricksStatus", this);
    cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().close());
    cancelCommand.setIsCancel(true);
    AsyncDataProvider.getInstance().getGlusterRemoveBricksStatus(new AsyncQuery<>(returnValue -> {
        cModel.stopProgress();
        if (returnValue.getSucceeded() && returnValue.getReturnValue() != null) {
            cancelConfirmation();
            RemoveBrickStatusModel removeBrickStatusModel;
            GlusterVolumeTaskStatusEntity removeBrickStatusEntity = returnValue.getReturnValue();
            if (getWindow() == null) {
                removeBrickStatusModel = new RemoveBrickStatusModel(volumeEntity, bricks);
                removeBrickStatusModel.setTitle(ConstantsManager.getInstance().getConstants().removeBricksStatusTitle());
                removeBrickStatusModel.setHelpTag(HelpTag.volume_remove_bricks_status);
                // //$NON-NLS-1$
                removeBrickStatusModel.setHashName("volume_remove_bricks_status");
                setWindow(removeBrickStatusModel);
                removeBrickStatusModel.getVolume().setEntity(volumeEntity.getName());
                removeBrickStatusModel.getCluster().setEntity(volumeEntity.getClusterName());
                removeBrickStatusModel.addStopRemoveBricksCommand(stopRemoveBrickFromStatus);
                removeBrickStatusModel.addCommitRemoveBricksCommand(commitRemoveBrickFromStatus);
                removeBrickStatusModel.addRetainBricksCommand(retainBricksFromStatus);
                removeBrickStatusModel.getCommands().add(cancelCommand);
            } else {
                removeBrickStatusModel = (RemoveBrickStatusModel) getWindow();
            }
            removeBrickStatusModel.showStatus(removeBrickStatusEntity);
        } else {
            cModel.setMessage(ConstantsManager.getInstance().getMessages().removeBrickStatusFailed(volumeEntity.getName()));
        }
    }), volumeEntity.getClusterId(), volumeEntity.getId(), bricks);
}
Also used : GlusterTaskType(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType) GlusterVolumeTaskStatusEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) GlusterVolumeReplaceBrickActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeReplaceBrickActionParameters) GlusterVolumeType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) 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) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GetConfigurationValueParameters(org.ovirt.engine.core.common.queries.GetConfigurationValueParameters) Mempool(org.ovirt.engine.core.common.businessentities.gluster.Mempool) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) GlusterVolumeRemoveBricksParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters) VolumeListModel(org.ovirt.engine.ui.uicommonweb.models.volumes.VolumeListModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) GlusterClientInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterClientInfo) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) GlusterVolumeBricksActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeBricksActionParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Iterator(java.util.Iterator) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeAdvancedDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeAdvancedDetails) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) BrickDetails(org.ovirt.engine.core.common.businessentities.gluster.BrickDetails) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) GlusterVolumeResetBrickActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeResetBrickActionParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) GlusterVolumeTaskStatusEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity)

Example 60 with GlusterVolumeEntity

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.

the class GlusterVolumeSnapshotListModel method createNewSnapshot.

private void createNewSnapshot(final GlusterVolumeSnapshotModel snapshotModel) {
    GlusterVolumeEntity volumeEntity = getEntity();
    final GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity();
    snapshot.setClusterId(volumeEntity.getClusterId());
    snapshot.setSnapshotName(snapshotModel.getSnapshotName().getEntity());
    snapshot.setVolumeId(volumeEntity.getId());
    snapshot.setDescription(snapshotModel.getDescription().getEntity());
    CreateGlusterVolumeSnapshotParameters parameter = new CreateGlusterVolumeSnapshotParameters(snapshot, false);
    snapshotModel.startProgress();
    Frontend.getInstance().runAction(ActionType.CreateGlusterVolumeSnapshot, parameter, result -> {
        GlusterVolumeSnapshotListModel localModel = (GlusterVolumeSnapshotListModel) result.getState();
        snapshotModel.stopProgress();
        localModel.postSnapshotAction(result.getReturnValue());
    }, this);
}
Also used : CreateGlusterVolumeSnapshotParameters(org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)

Aggregations

GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)220 ArrayList (java.util.ArrayList)57 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)49 Test (org.junit.Test)47 Guid (org.ovirt.engine.core.compat.Guid)30 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)30 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)26 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)20 VDS (org.ovirt.engine.core.common.businessentities.VDS)19 HashMap (java.util.HashMap)16 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)16 List (java.util.List)15 Map (java.util.Map)15 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)15 ActionType (org.ovirt.engine.core.common.action.ActionType)13 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)13 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)13 GlusterVolumeType (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType)13 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)12 GlusterTaskType (org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType)12