Search in sources :

Example 1 with VolumeStatus

use of org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus in project ovirt-engine by oVirt.

the class VolumeStatusCell method render.

@Override
public void render(Context context, GlusterVolumeEntity volume, SafeHtmlBuilder sb, String id) {
    // Nothing to render if no volume is provided:
    if (volume == null) {
        return;
    }
    VolumeStatus status = GlusterVolumeUtils.getVolumeStatus(volume);
    ImageResource statusImage = getStatusImage(status);
    // Generate the HTML for the image:
    SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML());
    if (status == VolumeStatus.ALL_BRICKS_DOWN || status == VolumeStatus.SOME_BRICKS_DOWN || GlusterVolumeUtils.isHealingRequired(volume)) {
        SafeHtml alertImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.alertImage()).getHTML());
        sb.append(templates.statusWithAlertTemplate(statusImageHtml, alertImageHtml, id, status.toString()));
    } else {
        sb.append(templates.statusTemplate(statusImageHtml, id, status.toString()));
    }
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) VolumeStatus(org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus)

Example 2 with VolumeStatus

use of org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus in project ovirt-engine by oVirt.

the class VolumeListModel method start.

private void start() {
    if (getSelectedItems() == null) {
        return;
    }
    ArrayList<String> volumesForForceStartWarning = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        GlusterVolumeEntity volume = (GlusterVolumeEntity) item;
        VolumeStatus status = GlusterVolumeUtils.getVolumeStatus(volume);
        if (status == VolumeStatus.ALL_BRICKS_DOWN || status == VolumeStatus.SOME_BRICKS_DOWN) {
            volumesForForceStartWarning.add(volume.getName());
        }
    }
    prepareForStartVolume(true);
    if (!volumesForForceStartWarning.isEmpty()) {
        final ConfirmationModel cModel = new ConfirmationModel();
        cModel.setHelpTag(HelpTag.volume_start);
        // $NON-NLS-1$
        cModel.setHashName("volume_start");
        setConfirmWindow(cModel);
        cModel.setMessage(ConstantsManager.getInstance().getConstants().startForceVolumeMessage());
        cModel.setTitle(ConstantsManager.getInstance().getConstants().confirmStartVolume());
        cModel.setForceLabel(ConstantsManager.getInstance().getConstants().startForceLabel());
        cModel.setItems(volumesForForceStartWarning);
        cModel.getForce().setIsAvailable(true);
        cModel.getForce().setEntity(true);
        cModel.getForce().getEntityChangedEvent().addListener((ev, sender, args) -> {
            if (cModel.getCommands() != null && cModel.getCommands().get(0) != null) {
                cModel.getCommands().get(0).setIsExecutionAllowed(cModel.getForce().getEntity());
            }
        });
        // $NON-NLS-1$
        cModel.getCommands().add(UICommand.createDefaultOkUiCommand("startVolumeWithForceOption", this));
        // $NON-NLS-1$
        cModel.getCommands().add(UICommand.createCancelUiCommand("closeConfirmationWindow", this));
    }
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) VolumeStatus(org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus)

Example 3 with VolumeStatus

use of org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus in project ovirt-engine by oVirt.

the class VolumeListModel method prepareForStartVolume.

private void prepareForStartVolume(boolean noForceStart) {
    boolean force = false;
    ConfirmationModel cModel;
    if (getConfirmWindow() != null) {
        cModel = (ConfirmationModel) getConfirmWindow();
        closeConfirmationWindow();
        force = cModel.getForce().getEntity();
    }
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        GlusterVolumeEntity volume = (GlusterVolumeEntity) item;
        VolumeStatus status = GlusterVolumeUtils.getVolumeStatus(volume);
        if (!noForceStart && (status == VolumeStatus.ALL_BRICKS_DOWN || status == VolumeStatus.SOME_BRICKS_DOWN)) {
            list.add(new GlusterVolumeActionParameters(volume.getId(), force));
        } else if (noForceStart && status == VolumeStatus.DOWN) {
            list.add(new GlusterVolumeActionParameters(volume.getId(), false));
        }
    }
    onStartVolume(list);
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) VolumeStatus(org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) GlusterVolumeActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeActionParameters)

Example 4 with VolumeStatus

use of org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus in project ovirt-engine by oVirt.

the class VolumeListModel method updateActionAvailability.

private void updateActionAvailability() {
    boolean allowStart = true;
    boolean allowStop = true;
    boolean allowRemove = true;
    boolean allowStartRebalance = true;
    boolean allowStopRebalance = true;
    boolean allowStatusRebalance = true;
    boolean allowOptimize = true;
    boolean allowStartProfiling = false;
    boolean allowStopProfiling = false;
    boolean allowProfileStatisticsDetails = false;
    boolean allowConfigureClusterSnapshotOptions = true;
    boolean allowConfigureVolumeSnapshotOptions = false;
    boolean allowCreateSnapshot = false;
    boolean allowEditSnapshotSchedule = false;
    boolean allowCreateGeoRepSession = false;
    if (getSelectedItems() == null || getSelectedItems().size() == 0) {
        allowStart = false;
        allowStop = false;
        allowRemove = false;
        allowStartRebalance = false;
        allowStopRebalance = false;
        allowStatusRebalance = false;
        allowOptimize = false;
    } else {
        List<GlusterVolumeEntity> list = getSelectedItems();
        allowStartProfiling = isStartProfileAvailable(list);
        allowStopProfiling = isStopProfileAvailable(list);
        for (GlusterVolumeEntity volume : list) {
            if (volume.getStatus() == GlusterStatus.UP) {
                VolumeStatus status = GlusterVolumeUtils.getVolumeStatus(volume);
                allowStart = status == VolumeStatus.ALL_BRICKS_DOWN || status == VolumeStatus.SOME_BRICKS_DOWN;
                allowRemove = false;
                if (!volume.getVolumeType().isDistributedType()) {
                    allowStartRebalance = false;
                }
            } else if (volume.getStatus() == GlusterStatus.DOWN) {
                allowStop = false;
                allowStartRebalance = false;
            }
            GlusterAsyncTask asyncTask = volume.getAsyncTask();
            if (asyncTask != null) {
                allowStartRebalance = allowStartRebalance && (asyncTask.getStatus() == null ? asyncTask.getJobStatus() != JobExecutionStatus.STARTED : asyncTask.getStatus() != JobExecutionStatus.STARTED);
            }
        }
        if (list.size() == 1) {
            GlusterVolumeEntity volumeEntity = list.get(0);
            GlusterAsyncTask asyncTask = volumeEntity.getAsyncTask();
            allowStopRebalance = volumeEntity.getStatus() == GlusterStatus.UP && asyncTask != null && asyncTask.getType() == GlusterTaskType.REBALANCE && asyncTask.getStatus() == JobExecutionStatus.STARTED;
            allowConfigureVolumeSnapshotOptions = volumeEntity.getStatus() == GlusterStatus.UP;
            allowCreateGeoRepSession = volumeEntity.getStatus() == GlusterStatus.UP;
            allowCreateSnapshot = isCreateSnapshotAvailable(volumeEntity);
        } else {
            allowStopRebalance = false;
        }
        allowStatusRebalance = getRebalanceStatusAvailability(getSelectedItems());
        allowProfileStatisticsDetails = getProfileStatisticsAvailability(list);
        allowEditSnapshotSchedule = isEditSnapshotScheduleAvailable(list);
    }
    getStartCommand().setIsExecutionAllowed(allowStart);
    getStopCommand().setIsExecutionAllowed(allowStop);
    getRemoveVolumeCommand().setIsExecutionAllowed(allowRemove);
    getStartRebalanceCommand().setIsExecutionAllowed(allowStartRebalance);
    getStopRebalanceCommand().setIsExecutionAllowed(allowStopRebalance);
    getStatusRebalanceCommand().setIsExecutionAllowed(allowStatusRebalance);
    getOptimizeForVirtStoreCommand().setIsExecutionAllowed(allowOptimize);
    getConfigureClusterSnapshotOptionsCommand().setIsExecutionAllowed(allowConfigureClusterSnapshotOptions);
    getConfigureVolumeSnapshotOptionsCommand().setIsExecutionAllowed(allowConfigureVolumeSnapshotOptions);
    getCreateSnapshotCommand().setIsExecutionAllowed(allowCreateSnapshot);
    getEditSnapshotScheduleCommand().setIsExecutionAllowed(allowEditSnapshotSchedule);
    getNewVolumeCommand().setIsAvailable(true);
    getRemoveVolumeCommand().setIsAvailable(true);
    getStartVolumeProfilingCommand().setIsExecutionAllowed(allowStartProfiling);
    getStopVolumeProfilingCommand().setIsExecutionAllowed(allowStopProfiling);
    getShowVolumeProfileDetailsCommand().setIsExecutionAllowed(allowProfileStatisticsDetails);
    getNewGeoRepSessionCommand().setIsExecutionAllowed(allowCreateGeoRepSession);
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) VolumeStatus(org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus)

Example 5 with VolumeStatus

use of org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus in project ovirt-engine by oVirt.

the class VolumeStatusColumn method getTooltip.

@Override
public SafeHtml getTooltip(GlusterVolumeEntity volume) {
    if (volume == null) {
        return null;
    }
    VolumeStatus status = GlusterVolumeUtils.getVolumeStatus(volume);
    String tooltip = null;
    switch(status) {
        case DOWN:
            tooltip = constants.down();
            break;
        case UP:
            tooltip = constants.up();
            break;
        case SOME_BRICKS_DOWN:
            tooltip = constants.volumeBricksDown();
            break;
        case ALL_BRICKS_DOWN:
            tooltip = constants.volumeAllBricksDown();
            break;
        default:
            tooltip = constants.down();
    }
    if ((status == VolumeStatus.UP || status == VolumeStatus.SOME_BRICKS_DOWN) && GlusterVolumeUtils.isHealingRequired(volume)) {
        tooltip = messages.needsGlusterHealingWithVolumeStatus(tooltip);
    }
    return SafeHtmlUtils.fromSafeConstant(tooltip);
}
Also used : VolumeStatus(org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus)

Aggregations

VolumeStatus (org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils.VolumeStatus)6 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)3 ArrayList (java.util.ArrayList)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 GlusterVolumeActionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeActionParameters)1 GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)1