protected CommandReport createCommandReport(int exitCode, HostRoleStatus status, String structuredOut,
                                              String stdout, String stderr) {
    CommandReport report = null;

    if (hostRoleCommand != null) {
      if (executionCommand == null) {
        ExecutionCommandWrapper wrapper = hostRoleCommand.getExecutionCommandWrapper();

        if (wrapper != null) {
          executionCommand = wrapper.getExecutionCommand();
        }
      }

      if (executionCommand != null) {
        RoleCommand roleCommand = executionCommand.getRoleCommand();

        report = new CommandReport();

        report.setActionId(StageUtils.getActionId(hostRoleCommand.getRequestId(), hostRoleCommand.getStageId()));
        report.setClusterId(executionCommand.getClusterId());
        //report.setConfigurationTags(executionCommand.getConfigurationTags());
        report.setRole(executionCommand.getRole());
        report.setRoleCommand((roleCommand == null) ? null : roleCommand.toString());
        report.setServiceName(executionCommand.getServiceName());
        report.setTaskId(executionCommand.getTaskId());

        report.setStructuredOut(structuredOut);
        report.setStdErr((stderr == null) ? "" : stderr);
        report.setStdOut((stdout == null) ? "" : stdout);
        report.setStatus((status == null) ? null : status.toString());
        report.setExitCode(exitCode);
      }
    }

    return report;
  }
Creates a CommandReport used to report back to Ambari the status of this ServerAction.

@param exitCode      an integer value declaring the exit code for this action - 0 typically
                     indicates success.
@param status        a HostRoleStatus indicating the status of this action
@param structuredOut a String containing the (typically) JSON-formatted data representing the
                     output from this action (this data is stored in the database, along with
                     the command status)
@param stdout        A string containing the data from the standard out stream (this data is stored in
                     the database, along with the command status)
@param stderr        A string containing the data from the standard error stream (this data is stored
                     in the database, along with the command status)
@return the generated CommandReport, or null if the HostRoleCommand or ExecutionCommand
properties are missing
ambari-server/src/main/java/org/apache/ambari/server/serveraction/AbstractServerAction.java