Search in sources :

Example 1 with ProcessResult

use of org.apache.cloudstack.utils.process.ProcessResult in project cloudstack by apache.

the class IpmitoolWrapper method executeCommands.

public OutOfBandManagementDriverResponse executeCommands(final List<String> commands, final Duration timeOut) {
    final ProcessResult result = RUNNER.executeCommands(commands, timeOut);
    if (LOG.isTraceEnabled()) {
        List<String> cleanedCommands = new ArrayList<String>();
        int maskNextCommand = 0;
        for (String command : commands) {
            if (maskNextCommand > 0) {
                cleanedCommands.add("**** ");
                maskNextCommand--;
                continue;
            }
            if (command.equalsIgnoreCase("-P")) {
                maskNextCommand = 1;
            } else if (command.toLowerCase().endsWith("password")) {
                maskNextCommand = 2;
            }
            cleanedCommands.add(command);
        }
        LOG.trace("Executed ipmitool process with commands: " + StringUtils.join(cleanedCommands, ", ") + "\nIpmitool execution standard output: " + result.getStdOutput() + "\nIpmitool execution error output: " + result.getStdError());
    }
    return new OutOfBandManagementDriverResponse(result.getStdOutput(), result.getStdError(), result.isSuccess());
}
Also used : OutOfBandManagementDriverResponse(org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverResponse) ProcessResult(org.apache.cloudstack.utils.process.ProcessResult) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 OutOfBandManagementDriverResponse (org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverResponse)1 ProcessResult (org.apache.cloudstack.utils.process.ProcessResult)1