foreman_dlm 0.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -6
  3. data/app/controllers/api/v2/dlmlock_events_controller.rb +42 -0
  4. data/app/controllers/api/v2/dlmlocks_controller.rb +31 -16
  5. data/app/controllers/concerns/foreman_dlm/find_host_by_client_cert.rb +7 -13
  6. data/app/controllers/concerns/foreman_dlm/find_host_by_ip.rb +1 -1
  7. data/app/controllers/concerns/foreman_dlm/update_checkin_time.rb +22 -0
  8. data/app/controllers/foreman_dlm/application_controller.rb +19 -0
  9. data/app/controllers/foreman_dlm/dlmlocks_controller.rb +82 -0
  10. data/app/helpers/foreman_dlm/dlmlock_helper.rb +33 -0
  11. data/app/jobs/foreman_dlm/refresh_dlmlock_status.rb +17 -0
  12. data/app/models/concerns/foreman_dlm/dlm_facet_host_extensions.rb +13 -0
  13. data/app/models/concerns/foreman_dlm/expirable.rb +36 -0
  14. data/app/models/concerns/foreman_dlm/host_extensions.rb +21 -2
  15. data/app/models/concerns/foreman_dlm/host_monitoring_extensions.rb +2 -0
  16. data/app/models/concerns/foreman_dlm/user_extensions.rb +13 -0
  17. data/app/models/foreman_dlm/dlm_facet.rb +7 -0
  18. data/app/models/foreman_dlm/dlmlock/update.rb +9 -0
  19. data/app/models/foreman_dlm/dlmlock.rb +137 -0
  20. data/app/models/foreman_dlm/dlmlock_event.rb +23 -0
  21. data/app/models/host_status/dlmlock_status.rb +44 -0
  22. data/app/views/api/v2/dlmlock_events/index.json.rabl +2 -0
  23. data/app/views/api/v2/dlmlocks/show.json.rabl +1 -1
  24. data/app/views/api/v2/errors/precondition_failed.json.rabl +1 -1
  25. data/app/views/foreman_dlm/api/v2/dlm_facets/base.json.rabl +1 -0
  26. data/app/views/foreman_dlm/api/v2/dlm_facets/base_with_root.json.rabl +3 -0
  27. data/app/views/foreman_dlm/api/v2/dlm_facets/show.json.rabl +3 -0
  28. data/app/views/foreman_dlm/dlmlocks/_details.html.erb +42 -0
  29. data/app/views/{dlmlocks → foreman_dlm/dlmlocks}/_list.html.erb +3 -1
  30. data/app/views/foreman_dlm/dlmlocks/index.html.erb +2 -0
  31. data/app/views/foreman_dlm/dlmlocks/show.html.erb +10 -0
  32. data/app/views/{dlmlocks → foreman_dlm/dlmlocks}/welcome.html.erb +2 -2
  33. data/app/views/hosts/_dlmlocks_tab.html.erb +39 -0
  34. data/config/routes.rb +20 -13
  35. data/contrib/systemd/foreman-dlm-expire-events.service +10 -0
  36. data/contrib/systemd/foreman-dlm-expire-events.timer +8 -0
  37. data/db/migrate/20170824084100_add_dlmlock.foreman_dlm.rb +1 -1
  38. data/db/migrate/20180627150003_rename_dlmlock_sti_models.rb +9 -0
  39. data/db/migrate/20180704162345_add_dlmlock_events.rb +11 -0
  40. data/db/migrate/20180711090022_add_hosts_fk_to_dlmlocks.rb +5 -0
  41. data/db/migrate/20180711111903_create_dlm_facets.foreman_dlm.rb +10 -0
  42. data/db/migrate/20180713113208_update_permissions_for_scoped_models.rb +13 -0
  43. data/lib/foreman_dlm/engine.rb +58 -19
  44. data/lib/foreman_dlm/version.rb +1 -1
  45. data/lib/tasks/dlmlock_events.rake +19 -0
  46. data/lib/tasks/foreman_dlm_tasks.rake +2 -4
  47. data/test/controllers/api/v2/dlmlocks_controller_test.rb +73 -52
  48. data/test/controllers/api/v2/dlmlocks_dlmlock_events_controller_test.rb +81 -0
  49. data/test/controllers/api/v2/hosts_controller_test.rb +28 -0
  50. data/test/controllers/find_host_by_client_cert_test.rb +2 -2
  51. data/test/controllers/foreman_dlm/dlmlocks_test.rb +55 -0
  52. data/test/controllers/hosts_controller_test.rb +12 -0
  53. data/test/factories/dlm_facets.rb +6 -0
  54. data/test/factories/dlmlock.rb +6 -2
  55. data/test/factories/dlmlock_events.rb +13 -0
  56. data/test/factories/host.rb +7 -0
  57. data/test/integration/foreman_dlm/dlmlocks_test.rb +28 -0
  58. data/test/jobs/refresh_dlmlock_status_test.rb +10 -0
  59. data/test/models/foreman_dlm/dlm_facet_test.rb +13 -0
  60. data/test/models/foreman_dlm/dlmlock_event_test.rb +19 -0
  61. data/test/models/foreman_dlm/dlmlock_test.rb +307 -0
  62. data/test/models/host_managed_test.rb +41 -0
  63. data/test/models/host_monitoring_test.rb +1 -1
  64. data/test/models/host_status/dlmlock_status_test.rb +45 -0
  65. data/test/models/user_test.rb +5 -0
  66. data/test/test_plugin_helper.rb +5 -3
  67. metadata +108 -30
  68. data/app/controllers/dlmlocks_controller.rb +0 -13
  69. data/app/models/dlmlock/update.rb +0 -5
  70. data/app/models/dlmlock.rb +0 -79
  71. data/app/views/dlmlocks/_details.html.erb +0 -35
  72. data/app/views/dlmlocks/index.html.erb +0 -2
  73. data/app/views/dlmlocks/show.html.erb +0 -7
  74. data/test/controllers/dlmlocks_test.rb +0 -24
  75. data/test/models/dlmlock_test.rb +0 -201
@@ -0,0 +1,13 @@
1
+ require 'test_plugin_helper'
2
+
3
+ module ForemanDlm
4
+ class DlmFacetTest < ActiveSupport::TestCase
5
+ setup do
6
+ User.current = users(:admin)
7
+ end
8
+
9
+ subject { FactoryBot.create(:dlm_facet) }
10
+ should belong_to(:host)
11
+ should validate_presence_of(:host)
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ require 'test_plugin_helper'
2
+
3
+ module ForemanDlm
4
+ class DlmlockEventTest < ActiveSupport::TestCase
5
+ should belong_to(:dlmlock)
6
+ should belong_to(:host)
7
+ should belong_to(:user)
8
+
9
+ test 'should expire lock events' do
10
+ event_count = 5
11
+ FactoryBot.create_list(:dlmlock_event, event_count)
12
+ FactoryBot.create_list(:dlmlock_event, event_count, :old_event)
13
+ assert_difference(-> { ForemanDlm::DlmlockEvent.count }, -1 * event_count) do
14
+ ForemanDlm::DlmlockEvent.expire(created_before: 7.days, batch_size: 2, sleep_time: 0.0001)
15
+ end
16
+ assert_equal event_count, ForemanDlm::DlmlockEvent.count
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,307 @@
1
+ require 'test_plugin_helper'
2
+
3
+ module ForemanDlm
4
+ class DlmlockTest < ActiveSupport::TestCase
5
+ setup do
6
+ User.current = users(:admin)
7
+ end
8
+
9
+ should belong_to(:host)
10
+ should have_many(:dlmlock_events)
11
+
12
+ subject { FactoryBot.create(:dlmlock) }
13
+ should validate_presence_of(:name)
14
+ should validate_uniqueness_of(:name)
15
+
16
+ let(:host1) { FactoryBot.create(:host, :managed) }
17
+ let(:host2) { FactoryBot.create(:host, :managed) }
18
+
19
+ class HostWithCallbacks < ::Host::Managed
20
+ attr_accessor :callbacks
21
+
22
+ def initialize(*attributes, &block)
23
+ super
24
+ @callbacks = []
25
+ end
26
+
27
+ after_lock :callback1
28
+ after_unlock :callback2
29
+
30
+ def callback1
31
+ Rails.logger.debug "callback1 executed for #{self} (#{self.class})"
32
+ callbacks << 'callback1'
33
+ end
34
+
35
+ def callback2
36
+ Rails.logger.debug "callback2 executed for #{self} (#{self.class})"
37
+ callbacks << 'callback2'
38
+ end
39
+ end
40
+
41
+ let(:host1_with_callbacks) { HostWithCallbacks.create(:name => 'test1.example.com') }
42
+ let(:host2_with_callbacks) { HostWithCallbacks.create(:name => 'test2.example.com') }
43
+
44
+ context 'a free and enabled DLM lock' do
45
+ let(:dlmlock) { FactoryBot.create(:dlmlock) }
46
+
47
+ test 'should be enabled and unlocked' do
48
+ assert_equal true, dlmlock.enabled?
49
+ assert_equal false, dlmlock.disabled?
50
+ assert_equal false, dlmlock.locked?
51
+ assert_equal false, dlmlock.taken?
52
+ end
53
+
54
+ test 'can be acquired' do
55
+ assert_nil dlmlock.host
56
+ assert dlmlock.acquire!(host1)
57
+ assert_equal host1, dlmlock.reload.host
58
+ end
59
+
60
+ test 'can be released' do
61
+ assert_nil dlmlock.host
62
+ assert dlmlock.release!(host1)
63
+ assert_nil dlmlock.reload.host
64
+ end
65
+
66
+ test 'creates a dlmlock_event on acquisition by owner' do
67
+ assert_difference -> { DlmlockEvent.count }, 1 do
68
+ assert dlmlock.acquire!(host1)
69
+ end
70
+
71
+ event = DlmlockEvent.last
72
+ assert_equal 'acquire', event.event_type
73
+ assert_equal host1.id, event.host_id
74
+ assert_equal users(:admin).id, event.user_id
75
+ assert_equal dlmlock.id, event.dlmlock_id
76
+ end
77
+
78
+ test 'triggers after_lock callback' do
79
+ host = HostWithCallbacks.new
80
+ host.name = 'test.example.com'
81
+ host.save
82
+ assert dlmlock.acquire!(host)
83
+ assert_equal ['callback1'], host.callbacks
84
+ end
85
+
86
+ context 'with a parameter disabeling the locking' do
87
+ setup do
88
+ FactoryBot.create(:host_parameter, host: host1, name: 'can_acquire_update_locks', value: 'false')
89
+ end
90
+
91
+ test 'can not be acquired' do
92
+ assert_nil dlmlock.host
93
+ assert_not dlmlock.acquire!(host1)
94
+ assert_nil dlmlock.reload.host
95
+ end
96
+ end
97
+ end
98
+
99
+ context 'a free and disabled DLM lock' do
100
+ let(:dlmlock) { FactoryBot.create(:dlmlock, :enabled => false) }
101
+
102
+ test 'should be disabled and unlocked' do
103
+ assert_equal false, dlmlock.enabled?
104
+ assert_equal true, dlmlock.disabled?
105
+ assert_equal false, dlmlock.locked?
106
+ assert_equal false, dlmlock.taken?
107
+ end
108
+
109
+ test 'can not be acquired' do
110
+ assert_nil dlmlock.host
111
+ assert_equal false, dlmlock.acquire!(host1)
112
+ assert_nil dlmlock.reload.host
113
+ end
114
+
115
+ test 'can not be released' do
116
+ assert_nil dlmlock.host
117
+ assert_equal false, dlmlock.release!(host1)
118
+ assert_nil dlmlock.reload.host
119
+ end
120
+
121
+ test 'triggers no callbacks' do
122
+ host = HostWithCallbacks.new
123
+ host.name = 'test.example.com'
124
+ host.save
125
+ assert_equal false, dlmlock.release!(host)
126
+ assert_equal [], host.callbacks
127
+ end
128
+ end
129
+
130
+ context 'an acquired DLM lock' do
131
+ let(:dlmlock) { FactoryBot.create(:dlmlock, :host => host1) }
132
+
133
+ test 'should be enabled and locked' do
134
+ assert_equal true, dlmlock.enabled?
135
+ assert_equal false, dlmlock.disabled?
136
+ assert_equal true, dlmlock.locked?
137
+ assert_equal true, dlmlock.taken?
138
+ assert_equal true, dlmlock.locked_by?(host1)
139
+ assert_equal true, dlmlock.acquired_by?(host1)
140
+ end
141
+
142
+ test 'can be acquired by owner' do
143
+ assert_equal host1, dlmlock.host
144
+ assert dlmlock.acquire!(host1)
145
+ assert_equal host1, dlmlock.reload.host
146
+ end
147
+
148
+ test 'can not be acquired by other host' do
149
+ assert_equal host1, dlmlock.host
150
+ assert_equal false, dlmlock.acquire!(host2)
151
+ assert_equal host1, dlmlock.reload.host
152
+ end
153
+
154
+ test 'can be released by owner' do
155
+ assert_equal host1, dlmlock.host
156
+ assert dlmlock.release!(host1)
157
+ assert_nil dlmlock.reload.host
158
+ end
159
+
160
+ test 'can not be released by other host' do
161
+ assert_equal host1, dlmlock.host
162
+ assert_equal false, dlmlock.release!(host2)
163
+ assert_equal host1, dlmlock.reload.host
164
+ end
165
+
166
+ test 'records audit change on release by owner' do
167
+ dlmlock
168
+ assert_difference -> { DlmlockEvent.count }, 1 do
169
+ assert dlmlock.release!(host1)
170
+ end
171
+
172
+ event = DlmlockEvent.last
173
+ assert_equal 'release', event.event_type
174
+ assert_equal host1.id, event.host_id
175
+ assert_equal users(:admin).id, event.user_id
176
+ assert_equal dlmlock.id, event.dlmlock_id
177
+ end
178
+
179
+ test 'records no audit change on acquisition by owner' do
180
+ assert_no_difference "Audit.where(auditable_type: 'ForemanDlm::Dlmlock', action: 'update').count" do
181
+ assert dlmlock.acquire!(host1)
182
+ end
183
+ end
184
+
185
+ test 'triggers after_unlock callback on release by owner' do
186
+ host = HostWithCallbacks.new
187
+ host.name = 'test.example.com'
188
+ host.save
189
+ dlmlock.host = host
190
+ dlmlock.save
191
+ assert dlmlock.release!(host)
192
+ assert_equal ['callback2'], host.callbacks
193
+ end
194
+
195
+ test 'triggers no callbacks on release attempt by other host' do
196
+ assert host1_with_callbacks
197
+ assert host2_with_callbacks
198
+ dlmlock.update(:host => host1_with_callbacks)
199
+ assert_equal false, dlmlock.release!(host2_with_callbacks)
200
+ assert_equal [], host1_with_callbacks.callbacks
201
+ assert_equal [], host2_with_callbacks.callbacks
202
+ end
203
+
204
+ test 'triggers no callbacks on acquiry attempt by owner' do
205
+ assert host1_with_callbacks
206
+ dlmlock.update(:host => host1_with_callbacks)
207
+ assert dlmlock.acquire!(host1_with_callbacks)
208
+ assert_equal [], host1_with_callbacks.callbacks
209
+ end
210
+ end
211
+
212
+ context 'scoped search' do
213
+ test 'can be searched by name' do
214
+ dlmlock = FactoryBot.create(:dlmlock)
215
+ assert_equal Dlmlock::Update.find(dlmlock.id), Dlmlock.search_for("name ~ #{dlmlock.name}").first
216
+ end
217
+ end
218
+
219
+ describe '#locked' do
220
+ subject { Dlmlock.locked }
221
+
222
+ it 'includes only Distributed Locks that are locked' do
223
+ locked = FactoryBot.create(:dlmlock, :locked)
224
+ not_locked = FactoryBot.create(:dlmlock)
225
+
226
+ assert_includes subject, locked
227
+ assert_not_includes subject, not_locked
228
+ end
229
+ end
230
+
231
+ describe '#stale' do
232
+ subject { Dlmlock.stale }
233
+
234
+ it 'includes only Distributed Locks that are stale' do
235
+ now = Time.now.utc
236
+
237
+ travel_to now do
238
+ stale = FactoryBot.create(:dlmlock, :locked, updated_at: now - 5.hours)
239
+ not_stale = FactoryBot.create(:dlmlock, :locked, updated_at: now)
240
+ not_locked = FactoryBot.create(:dlmlock)
241
+
242
+ assert_includes subject, stale
243
+ assert_not_includes subject, not_stale
244
+ assert_not_includes subject, not_locked
245
+ end
246
+ end
247
+ end
248
+
249
+ context '#log_events' do
250
+ let(:dlmlock) { FactoryBot.create(:dlmlock) }
251
+
252
+ test 'logs acquire event' do
253
+ assert_difference -> { DlmlockEvent.count }, 1 do
254
+ dlmlock.acquire!(host1)
255
+ end
256
+
257
+ event = DlmlockEvent.last
258
+ assert_equal 'acquire', event.event_type
259
+ assert_equal host1, event.host
260
+ end
261
+
262
+ test 'logs disable event' do
263
+ assert_difference -> { DlmlockEvent.count }, 1 do
264
+ dlmlock.disable!
265
+ end
266
+
267
+ event = DlmlockEvent.last
268
+ assert_equal 'disable', event.event_type
269
+ end
270
+
271
+ test 'logs enable event' do
272
+ dlmlock.update(enabled: false)
273
+
274
+ assert_difference -> { DlmlockEvent.count }, 1 do
275
+ dlmlock.enable!
276
+ end
277
+
278
+ event = DlmlockEvent.last
279
+ assert_equal 'enable', event.event_type
280
+ end
281
+
282
+ test 'logs failed event' do
283
+ dlmlock.acquire!(host1)
284
+
285
+ assert_difference -> { DlmlockEvent.count }, 1 do
286
+ dlmlock.acquire!(host2)
287
+ end
288
+
289
+ event = DlmlockEvent.last
290
+ assert_equal 'fail', event.event_type
291
+ assert_equal host1, event.host
292
+ end
293
+
294
+ test 'logs release event' do
295
+ dlmlock.acquire!(host1)
296
+
297
+ assert_difference -> { DlmlockEvent.count }, 1 do
298
+ assert dlmlock.release!(host1)
299
+ end
300
+
301
+ event = DlmlockEvent.last
302
+ assert_equal 'release', event.event_type
303
+ assert_equal host1, event.host
304
+ end
305
+ end
306
+ end
307
+ end
@@ -0,0 +1,41 @@
1
+ require 'test_plugin_helper'
2
+
3
+ module Host
4
+ class ManagedTest < ActiveSupport::TestCase
5
+ should have_many(:dlmlocks)
6
+ should have_many(:dlmlock_events)
7
+ should have_one(:dlm_facet)
8
+
9
+ describe '#can_acquire_update_locks?' do
10
+ let(:host) { FactoryBot.create(:host, :managed) }
11
+
12
+ it 'should be true without a host parameter' do
13
+ assert host.can_acquire_update_locks?
14
+ end
15
+
16
+ it 'should be true if parameter is true' do
17
+ FactoryBot.create(:host_parameter, host: host, name: 'can_acquire_update_locks', value: 'true')
18
+ assert host.can_acquire_update_locks?
19
+ end
20
+
21
+ it 'should be false if parameter is false' do
22
+ FactoryBot.create(:host_parameter, host: host, name: 'can_acquire_update_locks', value: 'false')
23
+ assert_not host.can_acquire_update_locks?
24
+ end
25
+ end
26
+
27
+ context 'scoped search on' do
28
+ context 'a host' do
29
+ let(:host) { FactoryBot.create(:host, :with_dlm_facet) }
30
+ setup do
31
+ host
32
+ end
33
+
34
+ test 'can be searched by dlm checkin time' do
35
+ results = Host.search_for('last_dlm_checkin_at < "2 weeks from now"')
36
+ assert_includes results, host
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -27,7 +27,7 @@ class HostMonitoringTest < ActiveSupport::TestCase
27
27
  end
28
28
 
29
29
  context 'an acquired DLM lock' do
30
- let(:dlmlock) { FactoryBot.create(:dlmlock, :host => host) }
30
+ let(:dlmlock) { FactoryBot.create(:dlmlock, :host => host) }
31
31
 
32
32
  test 'removes monitoring dowmtine' do
33
33
  monitoring_mock.expects(:del_downtime_host).once
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_plugin_helper'
4
+
5
+ class DlmlockStatusTest < ActiveSupport::TestCase
6
+ let(:host) { FactoryBot.create(:host, :managed) }
7
+
8
+ describe '#to_status' do
9
+ test 'should return STALE if host has any stale dlmlocks' do
10
+ now = Time.now.utc
11
+
12
+ travel_to now do
13
+ FactoryBot.create(:dlmlock, :locked, host: host, updated_at: now - 5.hours)
14
+ status = host.get_status(HostStatus::DlmlockStatus)
15
+
16
+ assert_not_empty host.dlmlocks.stale
17
+ assert_equal HostStatus::DlmlockStatus::STALE, status.to_status
18
+ end
19
+ end
20
+
21
+ test 'should return OK if host has no stale dlmlocks' do
22
+ status = host.get_status(HostStatus::DlmlockStatus)
23
+
24
+ assert_empty host.dlmlocks.stale
25
+ assert_equal HostStatus::DlmlockStatus::OK, status.to_status
26
+ end
27
+ end
28
+
29
+ describe '#relevant?' do
30
+ test 'should return true if host has any dlmlocks' do
31
+ FactoryBot.create(:dlmlock, host: host)
32
+ status = host.get_status(HostStatus::DlmlockStatus)
33
+
34
+ assert_not_empty host.dlmlocks
35
+ assert_equal true, status.relevant?
36
+ end
37
+
38
+ test 'should return false if host has no dlmlocks' do
39
+ status = host.get_status(HostStatus::DlmlockStatus)
40
+
41
+ assert_empty host.dlmlocks
42
+ assert_equal false, status.relevant?
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+ should have_many(:dlmlock_events)
5
+ end
@@ -3,7 +3,9 @@ require 'test_helper'
3
3
 
4
4
  # Add plugin to FactoryBot's paths
5
5
  FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
- if ForemanDlm.with_monitoring?
7
- FactoryBot.definition_file_paths << "#{ForemanMonitoring::Engine.root}/test/factories"
8
- end
6
+
7
+ # Add factories of external plugin dependencies
8
+ FactoryBot.definition_file_paths << "#{ForemanMonitoring::Engine.root}/test/factories" if ForemanDlm.with_monitoring?
9
+
10
+ # Reload factory paths
9
11
  FactoryBot.reload
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_dlm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-06 00:00:00.000000000 Z
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rubocop
14
+ name: rdoc
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,19 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rdoc
28
+ name: rubocop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.25.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.25.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-performance
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.13.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.13.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.9.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.9.1
41
69
  description: Adds a Distributed Lock Manager to Foreman. This enables painless system
42
70
  updates for clusters.
43
71
  email:
@@ -49,16 +77,27 @@ files:
49
77
  - LICENSE
50
78
  - README.md
51
79
  - Rakefile
80
+ - app/controllers/api/v2/dlmlock_events_controller.rb
52
81
  - app/controllers/api/v2/dlmlocks_controller.rb
53
82
  - app/controllers/concerns/foreman/controller/parameters/dlmlocks.rb
54
83
  - app/controllers/concerns/foreman_dlm/find_host_by_client_cert.rb
55
84
  - app/controllers/concerns/foreman_dlm/find_host_by_ip.rb
56
- - app/controllers/dlmlocks_controller.rb
85
+ - app/controllers/concerns/foreman_dlm/update_checkin_time.rb
86
+ - app/controllers/foreman_dlm/application_controller.rb
87
+ - app/controllers/foreman_dlm/dlmlocks_controller.rb
57
88
  - app/helpers/foreman_dlm/dlmlock_helper.rb
89
+ - app/jobs/foreman_dlm/refresh_dlmlock_status.rb
90
+ - app/models/concerns/foreman_dlm/dlm_facet_host_extensions.rb
91
+ - app/models/concerns/foreman_dlm/expirable.rb
58
92
  - app/models/concerns/foreman_dlm/host_extensions.rb
59
93
  - app/models/concerns/foreman_dlm/host_monitoring_extensions.rb
60
- - app/models/dlmlock.rb
61
- - app/models/dlmlock/update.rb
94
+ - app/models/concerns/foreman_dlm/user_extensions.rb
95
+ - app/models/foreman_dlm/dlm_facet.rb
96
+ - app/models/foreman_dlm/dlmlock.rb
97
+ - app/models/foreman_dlm/dlmlock/update.rb
98
+ - app/models/foreman_dlm/dlmlock_event.rb
99
+ - app/models/host_status/dlmlock_status.rb
100
+ - app/views/api/v2/dlmlock_events/index.json.rabl
62
101
  - app/views/api/v2/dlmlocks/acquire.json.rabl
63
102
  - app/views/api/v2/dlmlocks/base.json.rabl
64
103
  - app/views/api/v2/dlmlocks/create.json.rabl
@@ -68,33 +107,60 @@ files:
68
107
  - app/views/api/v2/dlmlocks/show.json.rabl
69
108
  - app/views/api/v2/dlmlocks/update.json.rabl
70
109
  - app/views/api/v2/errors/precondition_failed.json.rabl
71
- - app/views/dlmlocks/_details.html.erb
72
- - app/views/dlmlocks/_list.html.erb
73
- - app/views/dlmlocks/index.html.erb
74
- - app/views/dlmlocks/show.html.erb
75
- - app/views/dlmlocks/welcome.html.erb
110
+ - app/views/foreman_dlm/api/v2/dlm_facets/base.json.rabl
111
+ - app/views/foreman_dlm/api/v2/dlm_facets/base_with_root.json.rabl
112
+ - app/views/foreman_dlm/api/v2/dlm_facets/show.json.rabl
113
+ - app/views/foreman_dlm/dlmlocks/_details.html.erb
114
+ - app/views/foreman_dlm/dlmlocks/_list.html.erb
115
+ - app/views/foreman_dlm/dlmlocks/index.html.erb
116
+ - app/views/foreman_dlm/dlmlocks/show.html.erb
117
+ - app/views/foreman_dlm/dlmlocks/welcome.html.erb
118
+ - app/views/hosts/_dlmlocks_tab.html.erb
76
119
  - config/routes.rb
120
+ - contrib/systemd/foreman-dlm-expire-events.service
121
+ - contrib/systemd/foreman-dlm-expire-events.timer
77
122
  - db/migrate/20170824084100_add_dlmlock.foreman_dlm.rb
123
+ - db/migrate/20180627150003_rename_dlmlock_sti_models.rb
124
+ - db/migrate/20180704162345_add_dlmlock_events.rb
125
+ - db/migrate/20180711090022_add_hosts_fk_to_dlmlocks.rb
126
+ - db/migrate/20180711111903_create_dlm_facets.foreman_dlm.rb
127
+ - db/migrate/20180713113208_update_permissions_for_scoped_models.rb
78
128
  - lib/foreman_dlm.rb
79
129
  - lib/foreman_dlm/engine.rb
80
130
  - lib/foreman_dlm/version.rb
131
+ - lib/tasks/dlmlock_events.rake
81
132
  - lib/tasks/foreman_dlm_tasks.rake
82
133
  - locale/Makefile
83
134
  - locale/en/foreman_dlm.po
84
135
  - locale/foreman_dlm.pot
85
136
  - locale/gemspec.rb
86
137
  - test/controllers/api/v2/dlmlocks_controller_test.rb
87
- - test/controllers/dlmlocks_test.rb
138
+ - test/controllers/api/v2/dlmlocks_dlmlock_events_controller_test.rb
139
+ - test/controllers/api/v2/hosts_controller_test.rb
88
140
  - test/controllers/find_host_by_client_cert_test.rb
141
+ - test/controllers/foreman_dlm/dlmlocks_test.rb
142
+ - test/controllers/hosts_controller_test.rb
143
+ - test/factories/dlm_facets.rb
89
144
  - test/factories/dlmlock.rb
90
- - test/models/dlmlock_test.rb
145
+ - test/factories/dlmlock_events.rb
146
+ - test/factories/host.rb
147
+ - test/integration/foreman_dlm/dlmlocks_test.rb
148
+ - test/jobs/refresh_dlmlock_status_test.rb
149
+ - test/models/foreman_dlm/dlm_facet_test.rb
150
+ - test/models/foreman_dlm/dlmlock_event_test.rb
151
+ - test/models/foreman_dlm/dlmlock_test.rb
152
+ - test/models/host_managed_test.rb
91
153
  - test/models/host_monitoring_test.rb
154
+ - test/models/host_status/dlmlock_status_test.rb
155
+ - test/models/user_test.rb
92
156
  - test/test_plugin_helper.rb
93
- homepage: https://github.com/timogoebel/foreman_dlm
157
+ homepage: https://github.com/dm-drogeriemarkt/foreman_dlm
94
158
  licenses:
95
159
  - GPL-3.0
96
- metadata: {}
97
- post_install_message:
160
+ metadata:
161
+ rubygems_mfa_required: 'true'
162
+ is_foreman_plugin: 'true'
163
+ post_install_message:
98
164
  rdoc_options: []
99
165
  require_paths:
100
166
  - lib
@@ -109,16 +175,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
175
  - !ruby/object:Gem::Version
110
176
  version: '0'
111
177
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.3
114
- signing_key:
178
+ rubygems_version: 3.3.3
179
+ signing_key:
115
180
  specification_version: 4
116
181
  summary: Distributed Lock Manager for Foreman.
117
182
  test_files:
118
- - test/models/host_monitoring_test.rb
119
- - test/models/dlmlock_test.rb
120
- - test/factories/dlmlock.rb
121
- - test/test_plugin_helper.rb
122
- - test/controllers/dlmlocks_test.rb
123
183
  - test/controllers/api/v2/dlmlocks_controller_test.rb
184
+ - test/controllers/api/v2/dlmlocks_dlmlock_events_controller_test.rb
185
+ - test/controllers/api/v2/hosts_controller_test.rb
124
186
  - test/controllers/find_host_by_client_cert_test.rb
187
+ - test/controllers/foreman_dlm/dlmlocks_test.rb
188
+ - test/controllers/hosts_controller_test.rb
189
+ - test/factories/dlm_facets.rb
190
+ - test/factories/dlmlock.rb
191
+ - test/factories/dlmlock_events.rb
192
+ - test/factories/host.rb
193
+ - test/integration/foreman_dlm/dlmlocks_test.rb
194
+ - test/jobs/refresh_dlmlock_status_test.rb
195
+ - test/models/foreman_dlm/dlm_facet_test.rb
196
+ - test/models/foreman_dlm/dlmlock_event_test.rb
197
+ - test/models/foreman_dlm/dlmlock_test.rb
198
+ - test/models/host_managed_test.rb
199
+ - test/models/host_monitoring_test.rb
200
+ - test/models/host_status/dlmlock_status_test.rb
201
+ - test/models/user_test.rb
202
+ - test/test_plugin_helper.rb
@@ -1,13 +0,0 @@
1
- class DlmlocksController < ::ApplicationController
2
- include Foreman::Controller::AutoCompleteSearch
3
-
4
- before_action :setup_search_options, :only => :index
5
- before_action :find_resource, :only => [:show]
6
-
7
- def index
8
- @dlmlocks = resource_base_search_and_page(:host)
9
- end
10
-
11
- def show
12
- end
13
- end
@@ -1,5 +0,0 @@
1
- class Dlmlock::Update < Dlmlock
2
- def humanized_type
3
- _('Update Lock')
4
- end
5
- end