Katello/katello — pull request #3550 by iNecas (2014-01-08 16:28:13+00:00)
Title: DO NOT MERGE: Dynflow integration code to Katello + async tasks rework

Opening PR for starting review of the work done so far on Dynflow and async tasks rework. There are known issues and limitations, but we would like to get the current work into master as soon as possible and continue with further development from there, so that others can base their work on that as well. Also rebasing is not fun :)

**Installation instructions:**

1. Put this into your Foreman's Gemfile.local.rb file:
```ruby
gem 'dynflow', :git => 'git@github.com:iNecas/dynflow.git'
gem 'sinatra', :require => false # we use the dynflow web console
gem 'sequel', :require => false # we use the dynflow default Dynflow persistence adapter
gem 'foreman-tasks', :git => 'git@github.com:iNecas/foreman-tasks.git'
```

2. `rake db:migrate`
3. profit

**Rewrited actions:**

1. repo discovery (except canceling: we want to work on general appraoch to canceling approach, but not in the scope of this PR):

2. repository sychronization triggered from repo details (the sync status page should still work, as it uses Pulp api directly, should be replaced later, suggesting out of scope of this PR)

3. installation, update and uninstallation of system packages (not groups yet)

**How it works**

When the action is triggered in the UI, the task details page is shown updating the progress.

The top right corner in bastion has a new widget with number of currently running tasks of the user, showing the list of recent tasks on click.

The models for the tasks and locks are defined https://github.com/iNecas/foreman-tasks, as well as basic UI usable from Foreman without Katello and API that the bastion uses for the task reports.

The task can be linked to many resources. Products and repositories have new tab: tasks, showing the recent tasks.

The polling for updates on tasks happens for all parts of the UI page that shows the tasks (or task details). All the parts are updated at once, using bulk_search method https://github.com/iNecas/foreman-tasks/blob/master/app/controllers/foreman_tasks/api/tasks_controller.rb#L57.

There is also page for showing all tasks in the system (available under Administrer -> Tasks)

**Relation to foreman-tasks**

The [foreman-tasks](https://github.com/iNecas/foreman-tasks) is an attempt to get the tasks and background execution (perhaps orchestration as well) of Foreman and Katello on the same code-base and it's usable even without Katello).

**Dealing with having two apis for statuses temporarily**

Obviously, we will not be able to get all the things with task status rewritten through the night. Therefore, the current tasks API uses the current format when the Katello::TaskStatus object appears and sends the new representation, when ForemanTasks::Task object is there instead. The same happens in the UI.

**Things to do to get the current work into master**

- [ ] Ruby tests for the backend part (at least for repo discovery and repo sync, the remote actions are questionable, depends on where Mcollective integration goes)
- [ ] Package deps
- [ ] Update the installer (in case the installer works by the time all the other checkboxes are checked)
- [ ] Address the need-to-have review comments (the list should follow):

**Things to do, but not necessary for the merging**

- [ ] Rewrite the rest of remote actions to Dynflow::Action - it's questionable if we still want to keep the this feature in Katello, as Foreman goes the mcollective way
- [ ] Implement search and pagination for tasks tables
- [ ] Hammer plugin for task statuses and waiting for async tasks.
- [ ] Address review comments that don't require immediate action (the list shoul follow):