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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations