foreman-tasks 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.md +139 -0
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +140 -0
- data/app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb +26 -0
- data/app/controllers/foreman_tasks/tasks_controller.rb +19 -0
- data/app/helpers/foreman_tasks/tasks_helper.rb +16 -0
- data/app/lib/actions/base.rb +36 -0
- data/app/lib/actions/entry_action.rb +51 -0
- data/app/lib/actions/foreman/architecture/create.rb +29 -0
- data/app/lib/actions/foreman/architecture/destroy.rb +28 -0
- data/app/lib/actions/foreman/architecture/update.rb +21 -0
- data/app/lib/actions/foreman/host/import_facts.rb +40 -0
- data/app/lib/actions/helpers/args_serialization.rb +91 -0
- data/app/lib/actions/helpers/humanizer.rb +64 -0
- data/app/lib/actions/helpers/lock.rb +43 -0
- data/app/lib/actions/test_action.rb +17 -0
- data/app/models/foreman_tasks/concerns/action_subject.rb +102 -0
- data/app/models/foreman_tasks/concerns/architecture_action_subject.rb +20 -0
- data/app/models/foreman_tasks/concerns/host_action_subject.rb +42 -0
- data/app/models/foreman_tasks/lock.rb +176 -0
- data/app/models/foreman_tasks/task.rb +86 -0
- data/app/models/foreman_tasks/task/dynflow_task.rb +65 -0
- data/app/views/foreman_tasks/api/tasks/show.json.rabl +5 -0
- data/app/views/foreman_tasks/tasks/index.html.erb +51 -0
- data/app/views/foreman_tasks/tasks/show.html.erb +77 -0
- data/bin/dynflow-executor +43 -0
- data/config/routes.rb +20 -0
- data/db/migrate/20131205204140_create_foreman_tasks.rb +15 -0
- data/db/migrate/20131209122644_create_foreman_tasks_locks.rb +12 -0
- data/lib/foreman-tasks.rb +1 -0
- data/lib/foreman_tasks.rb +20 -0
- data/lib/foreman_tasks/dynflow.rb +101 -0
- data/lib/foreman_tasks/dynflow/configuration.rb +86 -0
- data/lib/foreman_tasks/dynflow/daemon.rb +88 -0
- data/lib/foreman_tasks/dynflow/persistence.rb +36 -0
- data/lib/foreman_tasks/engine.rb +58 -0
- data/lib/foreman_tasks/tasks/dynflow.rake +7 -0
- data/lib/foreman_tasks/version.rb +3 -0
- data/test/tasks_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +196 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
module ForemanTasks
|
2
|
+
|
3
|
+
# wrap the dynflow persistence to reflect the changes to execution plan
|
4
|
+
# in the Task model. This is probably a temporary solution and
|
5
|
+
# Dynflow will probably get more events-based API but it should be enought
|
6
|
+
# for start, until the requiements on the API are clear enough.
|
7
|
+
class Dynflow::Persistence < ::Dynflow::PersistenceAdapters::Sequel
|
8
|
+
|
9
|
+
def save_execution_plan(execution_plan_id, value)
|
10
|
+
super.tap do
|
11
|
+
begin
|
12
|
+
on_execution_plan_save(execution_plan_id, value)
|
13
|
+
rescue => e
|
14
|
+
ForemanTasks.dynflow.world.logger.error('Error on on_execution_plan_save event')
|
15
|
+
ForemanTasks.dynflow.world.logger.error(e.message)
|
16
|
+
ForemanTasks.dynflow.world.logger.error(e.backtrace.join("\n"))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def on_execution_plan_save(execution_plan_id, data)
|
22
|
+
# We can load the data unless the execution plan was properly planned and saved
|
23
|
+
# including its steps
|
24
|
+
if data[:state] == :pending
|
25
|
+
task = ::ForemanTasks::Task::DynflowTask.new
|
26
|
+
task.update_from_dynflow(data, false)
|
27
|
+
Lock.owner!(::User.current, task.id) if ::User.current
|
28
|
+
elsif data[:state] != :planning
|
29
|
+
if task = ::ForemanTasks::Task::DynflowTask.find_by_external_id(execution_plan_id)
|
30
|
+
task.update_from_dynflow(data, true)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module ForemanTasks
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
engine_name "foreman_tasks"
|
4
|
+
|
5
|
+
initializer 'foreman_tasks.register_plugin', :after => :finisher_hook do |app|
|
6
|
+
Foreman::Plugin.register :"foreman-tasks" do
|
7
|
+
requires_foreman '> 1.3'
|
8
|
+
divider :top_menu, :parent => :monitor_menu, :after => :audits
|
9
|
+
menu :top_menu, :tasks,
|
10
|
+
:url_hash => { :controller => 'foreman_tasks/tasks', :action => :index },
|
11
|
+
:caption => N_('Tasks'),
|
12
|
+
:parent => :monitor_menu
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
initializer 'foreman_tasks.ignore_dynflow_tables' do |app|
|
17
|
+
# Ignore Dynflow tables when schema-dumping. Dynflow tables are handled automatically by Dynflow.
|
18
|
+
ActiveRecord::SchemaDumper.ignore_tables << /^dynflow_.*$/
|
19
|
+
end
|
20
|
+
|
21
|
+
initializer "foreman_tasks.register_paths" do |app|
|
22
|
+
ForemanTasks.dynflow.config.eager_load_paths.concat(%W[#{ForemanTasks::Engine.root}/app/lib/actions])
|
23
|
+
end
|
24
|
+
|
25
|
+
initializer "foreman_tasks.load_app_instance_data" do |app|
|
26
|
+
app.config.paths['db/migrate'] += ForemanTasks::Engine.paths['db/migrate'].existent
|
27
|
+
end
|
28
|
+
|
29
|
+
# to enable async Foreman operations using Dynflow
|
30
|
+
if ENV['FOREMAN_TASKS_MONKEYS'] == 'true'
|
31
|
+
initializer "foreman_tasks.dynflow_initialize" do |app|
|
32
|
+
ForemanTasks.dynflow.require!
|
33
|
+
end
|
34
|
+
|
35
|
+
config.to_prepare do
|
36
|
+
::Api::V2::HostsController.send :include, ForemanTasks::Concerns::HostsControllerExtension
|
37
|
+
::Host::Base.send :include, ForemanTasks::Concerns::HostActionSubject
|
38
|
+
::Architecture.send :include, ForemanTasks::Concerns::ArchitectureActionSubject
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
initializer "foreman_tasks.initialize_dynflow", :after => :finisher_hook do
|
43
|
+
ForemanTasks.dynflow.initialize! unless ForemanTasks.dynflow.config.lazy_initialization
|
44
|
+
end
|
45
|
+
|
46
|
+
rake_tasks do
|
47
|
+
load File.expand_path('../tasks/dynflow.rake', __FILE__)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.table_name_prefix
|
52
|
+
"foreman_tasks_"
|
53
|
+
end
|
54
|
+
|
55
|
+
def use_relative_model_naming
|
56
|
+
true
|
57
|
+
end
|
58
|
+
end
|
data/test/tasks_test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: foreman-tasks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ivan Nečas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: uuidtools
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: dynflow
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: sequel
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sinatra
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: daemons
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: ! 'The goal of this plugin is to unify the way of showing task statuses
|
111
|
+
across the Foreman instance.
|
112
|
+
|
113
|
+
It defines Task model for keeping the information about the tasks and Lock for assigning
|
114
|
+
the tasks
|
115
|
+
|
116
|
+
to resources. The locking allows dealing with preventing multiple colliding tasks
|
117
|
+
to be run on the
|
118
|
+
|
119
|
+
same resource. It also optionally provides Dynflow infrastructure for using it for
|
120
|
+
managing the tasks.
|
121
|
+
|
122
|
+
'
|
123
|
+
email:
|
124
|
+
- inecas@redhat.com
|
125
|
+
executables: []
|
126
|
+
extensions: []
|
127
|
+
extra_rdoc_files: []
|
128
|
+
files:
|
129
|
+
- app/helpers/foreman_tasks/tasks_helper.rb
|
130
|
+
- app/lib/actions/helpers/args_serialization.rb
|
131
|
+
- app/lib/actions/helpers/humanizer.rb
|
132
|
+
- app/lib/actions/helpers/lock.rb
|
133
|
+
- app/lib/actions/entry_action.rb
|
134
|
+
- app/lib/actions/base.rb
|
135
|
+
- app/lib/actions/test_action.rb
|
136
|
+
- app/lib/actions/foreman/host/import_facts.rb
|
137
|
+
- app/lib/actions/foreman/architecture/create.rb
|
138
|
+
- app/lib/actions/foreman/architecture/update.rb
|
139
|
+
- app/lib/actions/foreman/architecture/destroy.rb
|
140
|
+
- app/views/foreman_tasks/api/tasks/show.json.rabl
|
141
|
+
- app/views/foreman_tasks/tasks/show.html.erb
|
142
|
+
- app/views/foreman_tasks/tasks/index.html.erb
|
143
|
+
- app/controllers/foreman_tasks/api/tasks_controller.rb
|
144
|
+
- app/controllers/foreman_tasks/tasks_controller.rb
|
145
|
+
- app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb
|
146
|
+
- app/models/foreman_tasks/concerns/architecture_action_subject.rb
|
147
|
+
- app/models/foreman_tasks/concerns/host_action_subject.rb
|
148
|
+
- app/models/foreman_tasks/concerns/action_subject.rb
|
149
|
+
- app/models/foreman_tasks/task/dynflow_task.rb
|
150
|
+
- app/models/foreman_tasks/lock.rb
|
151
|
+
- app/models/foreman_tasks/task.rb
|
152
|
+
- bin/dynflow-executor
|
153
|
+
- config/routes.rb
|
154
|
+
- db/migrate/20131209122644_create_foreman_tasks_locks.rb
|
155
|
+
- db/migrate/20131205204140_create_foreman_tasks.rb
|
156
|
+
- lib/foreman_tasks/tasks/dynflow.rake
|
157
|
+
- lib/foreman_tasks/engine.rb
|
158
|
+
- lib/foreman_tasks/version.rb
|
159
|
+
- lib/foreman_tasks/dynflow/configuration.rb
|
160
|
+
- lib/foreman_tasks/dynflow/persistence.rb
|
161
|
+
- lib/foreman_tasks/dynflow/daemon.rb
|
162
|
+
- lib/foreman_tasks/dynflow.rb
|
163
|
+
- lib/foreman_tasks.rb
|
164
|
+
- lib/foreman-tasks.rb
|
165
|
+
- MIT-LICENSE
|
166
|
+
- README.md
|
167
|
+
- test/test_helper.rb
|
168
|
+
- test/tasks_test.rb
|
169
|
+
homepage: https://github.com/iNecas/foreman-tasks
|
170
|
+
licenses: []
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
177
|
+
requirements:
|
178
|
+
- - ! '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
requirements: []
|
188
|
+
rubyforge_project:
|
189
|
+
rubygems_version: 1.8.23
|
190
|
+
signing_key:
|
191
|
+
specification_version: 3
|
192
|
+
summary: Foreman plugin for showing tasks information for resoruces and users
|
193
|
+
test_files:
|
194
|
+
- test/test_helper.rb
|
195
|
+
- test/tasks_test.rb
|
196
|
+
has_rdoc:
|