Skip to content

Commit

Permalink
Merge branch 'i307-authmsg-1.2.1' into release-1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Jun 1, 2011
2 parents 21709b2 + ee016b8 commit 09784a9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import com.dtolabs.rundeck.core.CoreException;
import com.dtolabs.rundeck.core.NodesetFailureException;
import com.dtolabs.rundeck.core.common.Framework;
import com.dtolabs.rundeck.core.common.INodeEntry;
import com.dtolabs.rundeck.core.execution.ExecutionServiceThread;
import com.dtolabs.rundeck.core.execution.FailedNodesListener;
Expand All @@ -36,6 +37,7 @@
import org.apache.tools.ant.taskdefs.Parallel;
import org.apache.tools.ant.taskdefs.Sequential;

import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.concurrent.Callable;
Expand All @@ -50,6 +52,9 @@ public class DefaultNodeDispatcher implements NodeDispatcher{
public static final String STATUS_LISTENER_REF_ID = DefaultNodeDispatcher.class.getName() + ":status.listener";
public static final String NODE_NAME_LOCAL_REF_ID = DefaultNodeDispatcher.class.getName() + ":node.name";
public static final String NODE_USER_LOCAL_REF_ID = DefaultNodeDispatcher.class.getName() + ":node.user";
public static final String FWK_PROP_AUTH_CANCEL_MSG = "framework.messages.error.ssh.authcancel";
public static final String FWK_PROP_AUTH_CANCEL_MSG_DEFAULT =
"Authentication failure connecting to node: \"{0}\". Make sure your resource definitions and credentials are up to date.";

/**
* Execute a node dispatch request, in serial with parallel threads.
Expand All @@ -61,7 +66,7 @@ public class DefaultNodeDispatcher implements NodeDispatcher{
* @param failedListener listener for results of failed nodes (when keepgoing is true)
* @param factory factory to produce executable items given input nodes
*/
public void executeNodedispatch(final Project project, final Collection<INodeEntry> nodes,
public void executeNodedispatch(final Project project, final Framework framework, final Collection<INodeEntry> nodes,
final int threadcount, final boolean keepgoing,
final FailedNodesListener failedListener,
final NodeCallableFactory factory) {
Expand Down Expand Up @@ -112,6 +117,18 @@ public void reportSuccess(final String nodename) {
+ "Connection Timeout (after " + factory.getRemoteTimeout()
+ "ms): " + e.getMessage(), e,
Project.MSG_ERR);
} else if (e instanceof BuildException && null != e.getCause()
&& e.getCause() instanceof JSchException
&& (e.getCause().getMessage().contains("Auth cancel"))) {
final String msgformat;
if (framework.getPropertyLookup().hasProperty(FWK_PROP_AUTH_CANCEL_MSG)) {
msgformat = framework.getProperty(FWK_PROP_AUTH_CANCEL_MSG);
} else {
msgformat = FWK_PROP_AUTH_CANCEL_MSG_DEFAULT;
}

project.log(MessageFormat.format(msgformat, node.getNodename(), e.getMessage()), e,
Project.MSG_ERR);
} else {
project.log("Failed execution for node: " + node.getNodename() + ": " + e.getMessage(),
Project.MSG_ERR);
Expand Down Expand Up @@ -192,6 +209,18 @@ public void reportSuccess(final String nodename) {
+ "Connection Timeout (after " + factory.getRemoteTimeout()
+ "ms): "+e.getMessage(), e,
Project.MSG_ERR);
} else if (e instanceof BuildException && null != e.getCause()
&& e.getCause() instanceof JSchException
&& (e.getCause().getMessage().contains("Auth cancel"))) {
final String msgformat;
if (framework.getPropertyLookup().hasProperty(FWK_PROP_AUTH_CANCEL_MSG)) {
msgformat = framework.getProperty(FWK_PROP_AUTH_CANCEL_MSG);
} else {
msgformat = FWK_PROP_AUTH_CANCEL_MSG_DEFAULT;
}

project.log(MessageFormat.format(msgformat, node.getNodename(), e.getMessage()), e,
Project.MSG_ERR);
} else {
project.log("Failed execution for node: " + node.getNodename() + ": " + e.getMessage(),
Project.MSG_ERR);
Expand Down
16 changes: 0 additions & 16 deletions core/src/java/com/dtolabs/rundeck/core/cli/ExecTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1156,22 +1156,6 @@ StringBuffer generate(final Collection c) throws NodesGeneratorException, IOExce
public static NodeDispatcher createNodeDispatcher() {
return new DefaultNodeDispatcher();
}
/**
* Execute a node dispatch request, in serial with parallel threads.
*
* @param project Ant project
* @param nodes node set to iterate over
* @param threadcount max number of parallel threads
* @param keepgoing if true, continue execution even if a node fails
* @param failedListener listener for results of failed nodes (when keepgoing is true)
* @param factory factory to produce executable items given input nodes
*/
public static void executeNodedispatch(final Project project, final Collection<INodeEntry> nodes,
final int threadcount, final boolean keepgoing,
final FailedNodesListener failedListener,
final NodeCallableFactory factory) {
createNodeDispatcher().executeNodedispatch(project, nodes, threadcount, keepgoing, failedListener, factory);
}

/**
* This BuildListener repeats all events to a secondary BuildListener, but converts messageLogged events' priorities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package com.dtolabs.rundeck.core.cli;

import com.dtolabs.rundeck.core.common.Framework;
import com.dtolabs.rundeck.core.common.INodeEntry;
import com.dtolabs.rundeck.core.execution.FailedNodesListener;
import org.apache.tools.ant.Project;
Expand All @@ -46,7 +47,7 @@ public interface NodeDispatcher {
* @param failedListener listener for results of failed nodes (when keepgoing is true)
* @param factory factory to produce executable items given input nodes
*/
public void executeNodedispatch(final Project project, final Collection<INodeEntry> nodes,
public void executeNodedispatch(final Project project, final Framework framework, final Collection<INodeEntry> nodes,
final int threadcount, final boolean keepgoing,
final FailedNodesListener failedListener,
final NodeCallableFactory factory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public Map<String, String> getMap() {

try {
nodeDispatcher.executeNodedispatch(project,
getFramework(),
c,
getContext().getNodeSet().getThreadCount(),
getContext().getNodeSet().isKeepgoing(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void testDoAction() throws Exception {

final boolean wascalled[]={false};
action.setNodeDispatcher(new NodeDispatcher() {
public void executeNodedispatch(Project project, Collection<INodeEntry> nodes, int threadcount,
public void executeNodedispatch(Project project, Framework fwk, Collection<INodeEntry> nodes, int threadcount,
boolean keepgoing, FailedNodesListener failedListener,
NodeCallableFactory factory) {
wascalled[0] = true;
Expand Down Expand Up @@ -190,7 +190,7 @@ public void executeNodedispatch(Project project, Collection<INodeEntry> nodes, i
final NodeEntryImpl nodeentry = new NodeEntryImpl(AbstractBaseTest.localNodeHostname, AbstractBaseTest.localNodeHostname);
final boolean wascalled[] = {false};
action.setNodeDispatcher(new NodeDispatcher() {
public void executeNodedispatch(Project project, Collection<INodeEntry> nodes, int threadcount,
public void executeNodedispatch(Project project, Framework fwk, Collection<INodeEntry> nodes, int threadcount,
boolean keepgoing, FailedNodesListener failedListener,
NodeCallableFactory factory) {
wascalled[0] = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public ExecutionResult executeWorkflow() {
throw new NodesetEmptyException(baseNodeSet);
}

nodeDispatcher.executeNodedispatch(new Project(), nodes, baseNodeSet.getThreadCount(),
nodeDispatcher.executeNodedispatch(new Project(),framework, nodes, baseNodeSet.getThreadCount(),
baseNodeSet.isKeepgoing(), listener.getFailedNodesListener(), this);
nodesuccess=true;

Expand Down

0 comments on commit 09784a9

Please sign in to comment.