use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class GlusterHookStatusChangeCommand method executeCommand.
@Override
protected void executeCommand() {
entity = getGlusterHook();
addCustomValue(GlusterConstants.HOOK_NAME, entity.getName());
if (getAllUpServers().size() < clusterUtils.getServerCount(getGlusterHook().getClusterId())) {
errors.add(EngineMessage.CLUSTER_ALL_SERVERS_NOT_UP.toString());
}
List<Callable<Pair<VDS, VDSReturnValue>>> taskList = new ArrayList<>();
for (final VDS upServer : getAllUpServers()) {
taskList.add(() -> {
VDSReturnValue returnValue = runVdsCommand(getStatusChangeVDSCommand(), new GlusterHookVDSParameters(upServer.getId(), entity.getGlusterCommand(), entity.getStage(), entity.getName()));
return new Pair<>(upServer, returnValue);
});
}
boolean atLeastOneSuccess = false;
List<Pair<VDS, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(taskList);
for (Pair<VDS, VDSReturnValue> pairResult : pairResults) {
VDSReturnValue retValue = pairResult.getSecond();
if (retValue.getSucceeded()) {
atLeastOneSuccess = true;
// update status in database
updateServerHookStatusInDb(getGlusterHook().getId(), pairResult.getFirst().getId(), getNewStatus());
} else {
errors.add(retValue.getVdsError().getMessage());
}
}
setSucceeded(atLeastOneSuccess);
if (errors.size() > 0) {
// conflict in status
entity.addStatusConflict();
handleVdsErrors(getAuditLogTypeValue(), errors);
addCustomValue(GlusterConstants.FAILURE_MESSAGE, StringUtils.join(errors, System.lineSeparator()));
}
// The intention was to enable/disable hook. So we update the entity with new status if command succeeded
if (getSucceeded()) {
entity.setStatus(getNewStatus());
// no longer conflicts as all hooks have same status
entity.removeStatusConflict();
updateHookInDb(entity);
if (entity.getConflictStatus() == 0) {
// all conflicts have been resolved, remove server hooks
glusterHooksDao.removeGlusterServerHooks(entity.getId());
}
}
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class GlusterHookSyncJob method saveHookContent.
private void saveHookContent(List<Callable<Pair<GlusterHookEntity, VDSReturnValue>>> contentTasksList) {
if (contentTasksList.isEmpty()) {
return;
}
List<Pair<GlusterHookEntity, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(contentTasksList);
for (Pair<GlusterHookEntity, VDSReturnValue> pairResult : pairResults) {
final GlusterHookEntity hook = pairResult.getFirst();
if (!pairResult.getSecond().getSucceeded()) {
log.info("Failed to get content of hook '{}' with error: {}", hook.getHookKey(), pairResult.getSecond().getVdsError().getMessage());
logMessage(hook.getClusterId(), hook.getHookKey(), AuditLogType.GLUSTER_HOOK_GETCONTENT_FAILED);
continue;
}
final String content = (String) pairResult.getSecond().getReturnValue();
hooksDao.updateGlusterHookContent(hook.getId(), hook.getChecksum(), content);
}
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class CommitRemoveGlusterVolumeBricksCommand method executeCommand.
@Override
protected void executeCommand() {
GlusterVolumeEntity volume = getGlusterVolume();
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.CommitRemoveGlusterVolumeBricks, new GlusterVolumeRemoveBricksVDSParameters(getUpServer().getId(), volume.getName(), getParameters().getBricks()));
setSucceeded(returnValue.getSucceeded());
if (!getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT_FAILED, returnValue.getVdsError().getMessage());
return;
}
addCustomValue(GlusterConstants.NO_OF_BRICKS, String.valueOf(getParameters().getBricks().size()));
endStepJobCommitted();
glusterDBUtils.removeBricksFromVolumeInDb(volume, getParameters().getBricks(), getParameters().getReplicaCount());
glusterVolumeDao.updateVolumeTask(volume.getId(), null);
releaseVolumeLock();
getReturnValue().setActionReturnValue(returnValue.getReturnValue());
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class CreateGlusterVolumeCommand method executeCommand.
/*
* (non-Javadoc)
*
* @see org.ovirt.engine.core.bll.CommandBase#executeCommand()
*/
@Override
protected void executeCommand() {
// set the gluster volume name for audit purpose
setGlusterVolumeName(getVolume().getName());
if (getVolume().getTransportTypes() == null || getVolume().getTransportTypes().isEmpty()) {
getVolume().addTransportType(TransportType.TCP);
}
// GLUSTER access protocol is enabled by default
getVolume().addAccessProtocol(AccessProtocol.GLUSTER);
if (!getVolume().getAccessProtocols().contains(AccessProtocol.NFS)) {
getVolume().disableNFS();
}
if (getVolume().getAccessProtocols().contains(AccessProtocol.CIFS)) {
getVolume().enableCifs();
}
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.CreateGlusterVolume, new CreateGlusterVolumeVDSParameters(upServer.getId(), getVolume(), upServer.getClusterCompatibilityVersion(), getParameters().isForce()));
setSucceeded(returnValue.getSucceeded());
if (!getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_CREATE_FAILED, returnValue.getVdsError().getMessage());
return;
}
// Volume created successfully. Insert it to database.
GlusterVolumeEntity createdVolume = (GlusterVolumeEntity) returnValue.getReturnValue();
setVolumeType(createdVolume);
setBrickOrder(createdVolume.getBricks());
if (createdVolume.getIsArbiter()) {
setArbiterFlag(createdVolume);
}
addVolumeToDb(createdVolume);
// If we log successful volume creation at the end of this command,
// the messages from SetGlusterVolumeOptionCommand appear first,
// making it look like options were set before volume was created.
// Hence we explicitly log the volume creation before setting the options.
auditLogDirector.log(this, AuditLogType.GLUSTER_VOLUME_CREATE);
// And don't log it at the end
setCommandShouldBeLogged(false);
// set all options of the volume
setVolumeOptions(createdVolume);
getReturnValue().setActionReturnValue(createdVolume.getId());
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue 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);
}
Aggregations