Search in sources :

Example 41 with GlusterGeoRepSession

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

the class VolumeGeoRepListModel method showSessionOptions.

private void showSessionOptions() {
    if (getWindow() != null) {
        return;
    }
    GlusterGeoRepSession selectedGeoRepSession = getSelectedItem();
    GlusterVolumeGeoReplicationSessionConfigModel configModel = new GlusterVolumeGeoReplicationSessionConfigModel(selectedGeoRepSession);
    configModel.setTitle(constants.geoReplicationOptions());
    // $NON-NLS-1$
    configModel.setHashName("volume_geo_rep_configuration_display");
    configModel.setHelpTag(HelpTag.volume_geo_rep_configuration_display);
    configModel.startProgress();
    fetchConfigForSession(selectedGeoRepSession);
    setWindow(configModel);
    addUICommandsToConfigWindow(configModel);
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 42 with GlusterGeoRepSession

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

the class VolumeGeoRepListModel method updateActionAvailability.

private void updateActionAvailability(GlusterVolumeEntity volumeEntity) {
    boolean allowNewGeoRepSessionCommand = true;
    boolean allowStartSessionCommand = false;
    boolean allowStopSessionCommand = false;
    boolean allowResumeSessionCommand = false;
    boolean allowPauseSessionCommand = false;
    boolean allowSessionOptionsCommand = false;
    boolean allowRemoveSessionCommand = false;
    boolean allowSessionDetailsCommand = false;
    if (volumeEntity == null) {
        return;
    }
    if (getSelectedItems() != null && getSelectedItems().size() == 1) {
        GlusterGeoRepSession selectedSession = getSelectedItem();
        GeoRepSessionStatus sessionStatus = selectedSession.getStatus();
        allowStartSessionCommand = sessionStatus == GeoRepSessionStatus.CREATED || sessionStatus == GeoRepSessionStatus.STOPPED;
        allowStopSessionCommand = !allowStartSessionCommand;
        allowResumeSessionCommand = sessionStatus == GeoRepSessionStatus.PAUSED;
        allowPauseSessionCommand = sessionStatus == GeoRepSessionStatus.ACTIVE || sessionStatus == GeoRepSessionStatus.INITIALIZING;
        allowSessionOptionsCommand = true;
        allowNewGeoRepSessionCommand = volumeEntity.getStatus() == GlusterStatus.UP;
        allowRemoveSessionCommand = sessionStatus == GeoRepSessionStatus.STOPPED || sessionStatus == GeoRepSessionStatus.CREATED;
        allowSessionDetailsCommand = true;
    }
    getNewSessionCommand().setIsExecutionAllowed(allowNewGeoRepSessionCommand);
    getRemoveSessionCommand().setIsExecutionAllowed(allowRemoveSessionCommand);
    getStartSessionCommand().setIsExecutionAllowed(allowStartSessionCommand);
    getStopSessionCommand().setIsExecutionAllowed(allowStopSessionCommand);
    getPauseSessionCommand().setIsExecutionAllowed(allowPauseSessionCommand);
    getResumeSessionCommand().setIsExecutionAllowed(allowResumeSessionCommand);
    getSessionOptionsCommand().setIsExecutionAllowed(allowSessionOptionsCommand);
    getViewSessionDetailsCommand().setIsExecutionAllowed(allowSessionDetailsCommand);
    getRefreshSessionsCommand().setIsAvailable(true);
}
Also used : GeoRepSessionStatus(org.ovirt.engine.core.common.businessentities.gluster.GeoRepSessionStatus) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 43 with GlusterGeoRepSession

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

the class VolumeGeoRepListModel method performGeoRepAction.

private void performGeoRepAction(String commandName, String confirmTitle, HelpTag helpTag, String hashName, String action, ActionType actionType) {
    GlusterGeoRepSession selectedSession = getSelectedItem();
    if (selectedSession == null) {
        return;
    }
    initializeGeoRepActionConfirmation(confirmTitle, helpTag, hashName, constants.geoRepForceHelp(), messages.geoRepForceTitle(action), commandName, selectedSession.getMasterVolumeName(), selectedSession.getSlaveVolumeName(), selectedSession.getSlaveHostName(), null);
    onGeoRepSessionAction(actionType);
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 44 with GlusterGeoRepSession

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

the class VolumeGeoRepListModel method onGeoRepSessionAction.

private void onGeoRepSessionAction(ActionType actionType) {
    final GlusterVolumeGeoRepActionConfirmationModel cModel = (GlusterVolumeGeoRepActionConfirmationModel) getWindow();
    cModel.startProgress();
    boolean force = cModel.getForce().getEntity();
    GlusterGeoRepSession selectedSession = getSelectedItem();
    GlusterVolumeGeoRepSessionParameters sessionParamters = new GlusterVolumeGeoRepSessionParameters(selectedSession.getMasterVolumeId(), selectedSession.getId());
    sessionParamters.setForce(force);
    Frontend.getInstance().runAction(actionType, sessionParamters, result -> {
        if (cModel == null) {
            return;
        } else {
            cModel.stopProgress();
            if (!result.getReturnValue().getSucceeded()) {
                // cModel.setActionConfirmationMessage(result.getReturnValue().getFault().getMessage());
                setErrorMessage(result.getReturnValue(), cModel);
            } else {
                setWindow(null);
            }
        }
    }, this, false);
}
Also used : GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)

Example 45 with GlusterGeoRepSession

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

the class AddBricksToGlusterVolumeCommand method postAddBrickHandleGeoRepCase.

private void postAddBrickHandleGeoRepCase(final List<GlusterBrickEntity> bricksList, final Set<Guid> newServerIds) {
    // newServerIds is the set of ids of the servers that were not part of the volume before this attempt of brick
    // addition.
    final GlusterVolumeEntity volume = getGlusterVolume();
    List<GlusterGeoRepSession> sessions = new ArrayList<>();
    // Get all sessions for which the volume is a master
    List<GlusterGeoRepSession> geoRepSessionsForVolumeAsMaster = glusterGeoRepDao.getGeoRepSessions(volume.getId());
    if (geoRepSessionsForVolumeAsMaster != null && !geoRepSessionsForVolumeAsMaster.isEmpty()) {
        sessions.addAll(geoRepSessionsForVolumeAsMaster);
    }
    // Get session for which the volume is a slave
    GlusterGeoRepSession geoRepSessionForVolumeAsSlave = glusterGeoRepDao.getGeoRepSessionBySlaveVolume(volume.getId());
    if (geoRepSessionForVolumeAsSlave != null) {
        sessions.add(geoRepSessionForVolumeAsSlave);
    }
    // If this volume is empty, nothing to do.
    if (sessions.isEmpty()) {
        return;
    }
    List<Callable<Boolean>> perSessionCallables = new ArrayList<>();
    for (final GlusterGeoRepSession currentSession : sessions) {
        perSessionCallables.add(() -> {
            // Ids of servers on which steps like mount broker setup and/or passwordless ssh need to be done.
            Set<Guid> serverIdsToPrep = new HashSet<>(newServerIds);
            // Assume current volume as master volume of current session
            GlusterVolumeEntity masterVolume = volume;
            boolean succeeded = true;
            addCustomValue(GlusterConstants.VOLUME_NAME, currentSession.getMasterVolumeName());
            addCustomValue(GlusterConstants.GEO_REP_SLAVE_VOLUME_NAME, currentSession.getSlaveVolumeName());
            addCustomValue(GlusterConstants.GEO_REP_USER, currentSession.getUserName());
            if (currentSession.getMasterVolumeId().equals(volume.getId())) {
                /*
                     * If the volume is master, and there are any new servers, serverIdsToPrep is a set of all slave
                     * servers. This is bcoz the new server's keys also need to be updated to all slave servers.
                     */
                serverIdsToPrep = getSlaveNodesSet(currentSession);
            } else {
                // If its slave and non-root session, do partial mount broker setup
                if (!currentSession.getUserName().equalsIgnoreCase("root")) {
                    succeeded = evaluateReturnValue(errorType, backend.runInternalAction(ActionType.SetupGlusterGeoRepMountBrokerInternal, new SetUpMountBrokerParameters(volume.getClusterId(), serverIdsToPrep, volume.getName(), currentSession.getUserName())));
                    if (succeeded) {
                        auditLogDirector.log(this, AuditLogType.GLUSTER_SETUP_GEOREP_MOUNT_BROKER);
                    }
                }
                /*
                     * If the assumption that current volume is master, is invalid, which will be known here, update
                     * master volume correctly.
                     */
                masterVolume = glusterVolumeDao.getById(currentSession.getMasterVolumeId());
            }
            if (succeeded) {
                succeeded = evaluateReturnValue(errorType, runInternalAction(ActionType.SetUpPasswordLessSSHInternal, new SetUpPasswordLessSSHParameters(masterVolume.getClusterId(), serverIdsToPrep, currentSession.getUserName())));
            }
            if (succeeded) {
                auditLogDirector.log(this, AuditLogType.SET_UP_PASSWORDLESS_SSH);
                succeeded = evaluateReturnValue(errorType, runVdsCommand(VDSCommandType.CreateGlusterVolumeGeoRepSession, new GlusterVolumeGeoRepSessionVDSParameters(glusterUtil.getRandomUpServer(masterVolume.getClusterId()).getId(), currentSession.getMasterVolumeName(), currentSession.getSlaveHostName(), currentSession.getSlaveVolumeName(), currentSession.getUserName(), true)));
            }
            if (currentSession.getStatus() == GeoRepSessionStatus.ACTIVE || currentSession.getStatus() == GeoRepSessionStatus.INITIALIZING) {
                succeeded = evaluateReturnValue(errorType, runInternalAction(ActionType.StartGlusterVolumeGeoRep, new GlusterVolumeGeoRepSessionParameters(currentSession.getMasterVolumeId(), currentSession.getId(), true)));
            }
            return succeeded;
        });
    }
    ThreadPoolUtil.invokeAll(perSessionCallables);
}
Also used : SetUpMountBrokerParameters(org.ovirt.engine.core.common.action.gluster.SetUpMountBrokerParameters) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) Callable(java.util.concurrent.Callable) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeGeoRepSessionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters) SetUpPasswordLessSSHParameters(org.ovirt.engine.core.common.action.gluster.SetUpPasswordLessSSHParameters) HashSet(java.util.HashSet)

Aggregations

GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)49 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)12 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)9 GlusterVolumeGeoRepSessionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters)8 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 VDS (org.ovirt.engine.core.common.businessentities.VDS)6 Guid (org.ovirt.engine.core.compat.Guid)6 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)5 GlusterVolumeGeoRepSessionVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters)5 GlusterGeoRepSessionDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionDetails)3 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)3 HashMap (java.util.HashMap)2 Callable (java.util.concurrent.Callable)2 StorageDomainDR (org.ovirt.engine.core.common.businessentities.StorageDomainDR)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 CreateGlusterVolumeSnapshotVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters)2