mirror of https://github.com/apache/jclouds.git
reduced verbosity of status commands
This commit is contained in:
parent
921dae7395
commit
b85b861d8b
|
@ -44,7 +44,7 @@ import com.google.common.base.Objects;
|
||||||
public class SudoAwareInitManager {
|
public class SudoAwareInitManager {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger computeLogger = Logger.NULL;
|
||||||
protected NodeMetadata node;
|
protected NodeMetadata node;
|
||||||
protected final InitBuilder init;
|
protected final InitBuilder init;
|
||||||
protected final boolean runAsRoot;
|
protected final boolean runAsRoot;
|
||||||
|
@ -68,7 +68,7 @@ public class SudoAwareInitManager {
|
||||||
public void refreshSshIfNewAdminCredentialsConfigured(AdminAccess input) {
|
public void refreshSshIfNewAdminCredentialsConfigured(AdminAccess input) {
|
||||||
if (input.getAdminCredentials() != null && input.shouldGrantSudoToAdminUser()) {
|
if (input.getAdminCredentials() != null && input.shouldGrantSudoToAdminUser()) {
|
||||||
ssh.disconnect();
|
ssh.disconnect();
|
||||||
logger.debug(">> reconnecting as %s@%s", input.getAdminCredentials().identity, ssh.getHostAddress());
|
computeLogger.debug(">> reconnecting as %s@%s", input.getAdminCredentials().identity, ssh.getHostAddress());
|
||||||
ssh = sshFactory.apply(node = NodeMetadataBuilder.fromNodeMetadata(node).adminPassword(null).credentials(
|
ssh = sshFactory.apply(node = NodeMetadataBuilder.fromNodeMetadata(node).adminPassword(null).credentials(
|
||||||
input.getAdminCredentials()).build());
|
input.getAdminCredentials()).build());
|
||||||
ssh.connect();
|
ssh.connect();
|
||||||
|
@ -79,19 +79,24 @@ public class SudoAwareInitManager {
|
||||||
ExecResponse returnVal;
|
ExecResponse returnVal;
|
||||||
String command = (runAsRoot) ? execScriptAsRoot(action) : execScriptAsDefaultUser(action);
|
String command = (runAsRoot) ? execScriptAsRoot(action) : execScriptAsDefaultUser(action);
|
||||||
returnVal = runCommand(command);
|
returnVal = runCommand(command);
|
||||||
if (logger.isTraceEnabled())
|
if (computeLogger.isTraceEnabled())
|
||||||
logger.trace("<< %s[%s]", action, returnVal);
|
computeLogger.trace("<< %s[%s]", action, returnVal);
|
||||||
|
else if ("status".equals(action))
|
||||||
|
computeLogger.trace("<< %s(%d)", action, returnVal.getExitCode());
|
||||||
else
|
else
|
||||||
logger.debug("<< %s(%d)", action, returnVal.getExitCode());
|
computeLogger.debug("<< %s(%d)", action, returnVal.getExitCode());
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecResponse runCommand(String command) {
|
public ExecResponse runCommand(String command) {
|
||||||
ExecResponse returnVal;
|
String statement = String.format(">> running [%s] as %s@%s", command.replace(
|
||||||
logger.debug(">> running [%s] as %s@%s", command.replace(node.getAdminPassword() != null ? node
|
node.getAdminPassword() != null ? node.getAdminPassword() : "XXXXX", "XXXXX"), ssh.getUsername(), ssh
|
||||||
.getAdminPassword() : "XXXXX", "XXXXX"), ssh.getUsername(), ssh.getHostAddress());
|
.getHostAddress());
|
||||||
returnVal = ssh.exec(command);
|
if (command.endsWith("status"))
|
||||||
return returnVal;
|
computeLogger.trace(statement);
|
||||||
|
else
|
||||||
|
computeLogger.debug(statement);
|
||||||
|
return ssh.exec(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|
Loading…
Reference in New Issue