def _compute_returned_code(self): """ Compute the returned code that this Execution instance should returned. This method is used internally, it is not normally called by the client. The actual execution *should* have completed (task_self().resume() or task_self().join()) """ returned_rc = ACTION_RC_OK for action in self.executed_actions.values(): current_rc = action.rc # We reach an error, we will return an error if is_error_rc(current_rc): return current_rc if is_warning_rc(current_rc): returned_rc = ACTION_RC_WARNING continue return returned_rc
def _update_remote_action(self, ssh_worker): """ Update the fields of the related remote action """ # Worker SSH overall_rc = ACTION_RC_OK overall_stdout = "" overall_stderr = "" for rc, nodes in ssh_worker.iter_retcodes(): for buf, nodes in ssh_worker.iter_buffers(nodes): overall_stdout += "%s: %s" % (nodes, buf) for error, nodes in ssh_worker.iter_errors(nodes): overall_stderr += "%s: %s" % (nodes, error) if is_error_rc(rc): overall_rc = rc break if is_warning_rc(rc): overall_rc = rc self.action.rc = overall_rc self.action.stdout = overall_stdout self.action.stderr = overall_stderr