[email protected] writes:

> Hi,
>
> I was studying the dynflow documentation, but there are some pieces or 
> examples missing in order for me to understand how to do this and I cannot 
> find examples in the Katello sources either. Therefore, I would appreciate 
> some help.
>
> I have written one main task that is a composition of smaller tasks:
>
>     class MainAction < Actions::EntryAction
>       def plan(args)
>         sequence do
>           plan_action ::Actions::MyPlugin::FirstTask, args
>           plan_action ::Actions:: MyPlugin::SecondTask, args
>         end
>         plan_self
>       end
>
>     ...
>
> I have wrapped the smaller tasks into runner objects derived from 
> ForemanTasksCore::Runner::Base and use publish_data() to emit output for 
> the console. In the dynflow console, I can observe that the tasks are 
> publishing output when browsing into the smaller tasks. But what is unclear 
> for me is how I can fetch this output and show it in the console of the 
> main action such that I can observe the progress in the foreman-task task 
> page. I believe it needs to work somehow by including 
> ::Actions::Helpers::WithContinuousOutput? I can see something similar 
> working with delegated actions in the foreman_ansible plugin. However, I do 
> not need delegated actions as everything happens locally anyway.
>
> Thanks for reading. Looking forward to an answer.

Hi Gerrit,

The easiest way you could go is, on the entry action of the task, to
override the humanized_output, as done in [1]. In there, just to pass
the output from a sub-action.

The simplest way to go with our example would be

```
def humanized_output
  planned_actions(::Actions::MyPlugin::FirstTask).first.output
end
```

The continious output [2] is there just as a interface to keep the
format of the output messages in sync between the task and the UI, when
relying on the output that it produces: this is the format we are using
for ansible and remote execution.

I'm interested into the case you're trying to solve to see, what would
be the best way to address it (+ I'm curious of course :)

[1] - 
https://github.com/theforeman/foreman-tasks/blob/826b902cb8604e9ba1332fa5468f6ea49c7e980f/app/lib/actions/helpers/with_delegated_action.rb#L24
[2] -
https://github.com/theforeman/foreman-tasks/blob/826b902cb8604e9ba1332fa5468f6ea49c7e980f/lib/foreman_tasks_core/continuous_output.rb

-- Ivan

>
> Regards,
>
> --Gerrit
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to