Search in sources :

Example 1 with SetUpMountBrokerParameters

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

the class CreateGlusterVolumeGeoRepSessionCommand method executeCommand.

@Override
protected void executeCommand() {
    boolean rootSession = getParameters().getUserName().equalsIgnoreCase("root");
    boolean succeeded = true;
    Set<Guid> remoteServerIds = getServerIds(remoteServersSet);
    Guid slaveHostId = getParameters().getSlaveHostId();
    if (!rootSession) {
        ActionReturnValue completeMountBrokerSetupOnSlaveInternalAction = backend.runInternalAction(ActionType.SetupGlusterGeoRepMountBrokerInternal, new SetUpMountBrokerParameters(vdsDao.get(slaveHostId).getClusterId(), new HashSet<>(Collections.singletonList(getParameters().getSlaveHostId())), getParameters().getSlaveVolumeName(), getParameters().getUserName(), getParameters().getUserGroup()));
        succeeded = evaluateReturnValue(AuditLogType.GLUSTER_GEOREP_SETUP_MOUNT_BROKER_FAILED, completeMountBrokerSetupOnSlaveInternalAction);
        remoteServerIds.remove(slaveHostId);
        if (succeeded) {
            auditLogDirector.log(this, AuditLogType.GLUSTER_SETUP_GEOREP_MOUNT_BROKER);
            if (!remoteServerIds.isEmpty()) {
                ActionReturnValue mountBrokerPartialSetupInternalAction = backend.runInternalAction(ActionType.SetupGlusterGeoRepMountBrokerInternal, new SetUpMountBrokerParameters(vdsDao.get(slaveHostId).getClusterId(), remoteServerIds, getParameters().getSlaveVolumeName(), getParameters().getUserName()));
                succeeded = evaluateReturnValue(AuditLogType.GLUSTER_GEOREP_SETUP_MOUNT_BROKER_FAILED, mountBrokerPartialSetupInternalAction);
                if (succeeded) {
                    auditLogDirector.log(this, AuditLogType.GLUSTER_SETUP_GEOREP_MOUNT_BROKER);
                }
            }
        }
    }
    if (succeeded) {
        remoteServerIds.add(slaveHostId);
        ActionReturnValue setUpPasswordLessSSHinternalAction = runInternalAction(ActionType.SetUpPasswordLessSSHInternal, new SetUpPasswordLessSSHParameters(upServer.getClusterId(), remoteServerIds, getParameters().getUserName()));
        succeeded = evaluateReturnValue(errorType, setUpPasswordLessSSHinternalAction);
        if (succeeded) {
            auditLogDirector.log(this, AuditLogType.SET_UP_PASSWORDLESS_SSH);
            VDSReturnValue createVdsReturnValue = runVdsCommand(VDSCommandType.CreateGlusterVolumeGeoRepSession, new GlusterVolumeGeoRepSessionVDSParameters(upServer.getId(), getGlusterVolumeName(), vdsDao.get(slaveHostId).getHostName(), getParameters().getSlaveVolumeName(), getParameters().getUserName(), getParameters().isForce()));
            succeeded = evaluateReturnValue(AuditLogType.GLUSTER_GEOREP_SESSION_CREATE_FAILED, createVdsReturnValue);
            if (succeeded) {
                glusterGeoRepSyncJob.refreshGeoRepDataForVolume(getGlusterVolume());
            }
        }
    }
    setSucceeded(succeeded);
}
Also used : SetUpMountBrokerParameters(org.ovirt.engine.core.common.action.gluster.SetUpMountBrokerParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GlusterVolumeGeoRepSessionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters) Guid(org.ovirt.engine.core.compat.Guid) SetUpPasswordLessSSHParameters(org.ovirt.engine.core.common.action.gluster.SetUpPasswordLessSSHParameters) HashSet(java.util.HashSet) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 2 with SetUpMountBrokerParameters

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

the class SetupGlusterGeoRepMountBrokerInternalCommand method executeCommand.

@Override
protected void executeCommand() {
    boolean succeeded = true;
    final SetUpMountBrokerParameters parameters = getParameters();
    final List<Callable<VDSReturnValue>> mountBrokerSetupReturnStatuses = new ArrayList<>();
    for (final Guid currentRemoteServerId : getParameters().getRemoteServerIds()) {
        mountBrokerSetupReturnStatuses.add(() -> setUpMountBrokerPartial(currentRemoteServerId, parameters.getRemoteUserName(), parameters.getRemoteUserGroup(), parameters.getRemoteVolumeName(), parameters.isPartial()));
    }
    List<VDSReturnValue> returnValues = ThreadPoolUtil.invokeAll(mountBrokerSetupReturnStatuses);
    List<String> errors = new ArrayList<>();
    for (VDSReturnValue currentReturnValue : returnValues) {
        if (!currentReturnValue.getSucceeded()) {
            succeeded = false;
            errors.add(currentReturnValue.getVdsError().getMessage());
        }
    }
    if (!errors.isEmpty()) {
        propagateFailure(AuditLogType.GLUSTER_GEOREP_SETUP_MOUNT_BROKER_FAILED, errors);
    }
    setSucceeded(succeeded);
}
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) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 3 with SetUpMountBrokerParameters

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

the class SetupGlusterGeoRepMountBrokerInternalCommandTest method commandFailsSlaveVolumeNotUp.

@Test
public void commandFailsSlaveVolumeNotUp() {
    command = spy(new SetupGlusterGeoRepMountBrokerInternalCommand(new SetUpMountBrokerParameters(Guid.newGuid(), new HashSet<>(Collections.singletonList(Guid.newGuid())), null, null), null));
    doReturn(vds).when(command).getUpServer();
    doReturn(volume).when(command).getSlaveVolume();
    doReturn(GlusterStatus.DOWN).when(volume).getStatus();
    assertFalse(command.validate());
}
Also used : SetUpMountBrokerParameters(org.ovirt.engine.core.common.action.gluster.SetUpMountBrokerParameters) HashSet(java.util.HashSet) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 4 with SetUpMountBrokerParameters

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

the class SetupGlusterGeoRepMountBrokerInternalCommandTest method commandFailsSlaveNotOvirtMonitored.

@Test
public void commandFailsSlaveNotOvirtMonitored() {
    command = spy(new SetupGlusterGeoRepMountBrokerInternalCommand(new SetUpMountBrokerParameters(Guid.newGuid(), new HashSet<>(Collections.singletonList(Guid.newGuid())), null, null), null));
    doReturn(vds).when(command).getUpServer();
    doReturn(null).when(command).getSlaveVolume();
    assertFalse(command.validate());
}
Also used : SetUpMountBrokerParameters(org.ovirt.engine.core.common.action.gluster.SetUpMountBrokerParameters) HashSet(java.util.HashSet) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 5 with SetUpMountBrokerParameters

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

the class SetupGlusterGeoRepMountBrokerInternalCommandTest method commandSucceeds.

@Test
public void commandSucceeds() {
    command = spy(new SetupGlusterGeoRepMountBrokerInternalCommand(new SetUpMountBrokerParameters(Guid.newGuid(), new HashSet<>(Collections.singletonList(Guid.newGuid())), null, null), null));
    doReturn(vds).when(command).getUpServer();
    doReturn(volume).when(command).getSlaveVolume();
    doReturn(GlusterStatus.UP).when(volume).getStatus();
    assertTrue(command.validate());
}
Also used : SetUpMountBrokerParameters(org.ovirt.engine.core.common.action.gluster.SetUpMountBrokerParameters) HashSet(java.util.HashSet) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Aggregations

SetUpMountBrokerParameters (org.ovirt.engine.core.common.action.gluster.SetUpMountBrokerParameters)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)3 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)3 Guid (org.ovirt.engine.core.compat.Guid)3 ArrayList (java.util.ArrayList)2 Callable (java.util.concurrent.Callable)2 SetUpPasswordLessSSHParameters (org.ovirt.engine.core.common.action.gluster.SetUpPasswordLessSSHParameters)2 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 GlusterVolumeGeoRepSessionVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 GlusterVolumeGeoRepSessionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters)1 GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)1 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)1