foreman_dlm 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +84 -0
- data/Rakefile +47 -0
- data/app/controllers/api/v2/dlmlocks_controller.rb +157 -0
- data/app/controllers/concerns/foreman/controller/parameters/dlmlocks.rb +15 -0
- data/app/controllers/concerns/foreman_dlm/find_host_by_client_cert.rb +63 -0
- data/app/controllers/concerns/foreman_dlm/find_host_by_ip.rb +54 -0
- data/app/controllers/dlmlocks_controller.rb +13 -0
- data/app/helpers/foreman_dlm/dlmlock_helper.rb +15 -0
- data/app/models/concerns/foreman_dlm/host_extensions.rb +14 -0
- data/app/models/concerns/foreman_dlm/host_monitoring_extensions.rb +36 -0
- data/app/models/dlmlock/update.rb +5 -0
- data/app/models/dlmlock.rb +79 -0
- data/app/views/api/v2/dlmlocks/acquire.json.rabl +3 -0
- data/app/views/api/v2/dlmlocks/base.json.rabl +3 -0
- data/app/views/api/v2/dlmlocks/create.json.rabl +3 -0
- data/app/views/api/v2/dlmlocks/index.json.rabl +3 -0
- data/app/views/api/v2/dlmlocks/main.json.rabl +7 -0
- data/app/views/api/v2/dlmlocks/release.json.rabl +3 -0
- data/app/views/api/v2/dlmlocks/show.json.rabl +8 -0
- data/app/views/api/v2/dlmlocks/update.json.rabl +3 -0
- data/app/views/api/v2/errors/precondition_failed.json.rabl +5 -0
- data/app/views/dlmlocks/_details.html.erb +35 -0
- data/app/views/dlmlocks/_list.html.erb +45 -0
- data/app/views/dlmlocks/index.html.erb +2 -0
- data/app/views/dlmlocks/show.html.erb +7 -0
- data/app/views/dlmlocks/welcome.html.erb +14 -0
- data/config/routes.rb +25 -0
- data/db/migrate/20170824084100_add_dlmlock.foreman_dlm.rb +12 -0
- data/lib/foreman_dlm/engine.rb +76 -0
- data/lib/foreman_dlm/version.rb +3 -0
- data/lib/foreman_dlm.rb +4 -0
- data/lib/tasks/foreman_dlm_tasks.rake +37 -0
- data/locale/Makefile +60 -0
- data/locale/en/foreman_dlm.po +19 -0
- data/locale/foreman_dlm.pot +19 -0
- data/locale/gemspec.rb +2 -0
- data/test/controllers/api/v2/dlmlocks_controller_test.rb +367 -0
- data/test/controllers/dlmlocks_test.rb +24 -0
- data/test/controllers/find_host_by_client_cert_test.rb +91 -0
- data/test/factories/dlmlock.rb +6 -0
- data/test/models/dlmlock_test.rb +201 -0
- data/test/models/host_monitoring_test.rb +42 -0
- data/test/test_plugin_helper.rb +9 -0
- metadata +124 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class HostMonitoringTest < ActiveSupport::TestCase
|
4
|
+
let(:host) { FactoryBot.create(:host, :managed, :with_monitoring) }
|
5
|
+
let(:monitoring_mock) { mock('monitoring') }
|
6
|
+
let(:exception) { ProxyAPI::ProxyException.new(host.monitoring_proxy.url, StandardError.new, 'Some error message') }
|
7
|
+
|
8
|
+
setup do
|
9
|
+
skip unless ForemanDlm.with_monitoring?
|
10
|
+
User.current = users(:admin)
|
11
|
+
Host::Managed.any_instance.stubs(:monitoring).returns(monitoring_mock)
|
12
|
+
monitoring_mock.stubs(:query_host).returns({})
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'a free and enabled DLM lock' do
|
16
|
+
let(:dlmlock) { FactoryBot.create(:dlmlock) }
|
17
|
+
|
18
|
+
test 'creates monitoring downtime' do
|
19
|
+
monitoring_mock.expects(:set_downtime_host).once
|
20
|
+
assert dlmlock.acquire!(host)
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'does not fail on monitoring proxy error' do
|
24
|
+
monitoring_mock.expects(:set_downtime_host).once.raises(exception)
|
25
|
+
assert dlmlock.acquire!(host)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'an acquired DLM lock' do
|
30
|
+
let(:dlmlock) { FactoryBot.create(:dlmlock, :host => host) }
|
31
|
+
|
32
|
+
test 'removes monitoring dowmtine' do
|
33
|
+
monitoring_mock.expects(:del_downtime_host).once
|
34
|
+
assert dlmlock.release!(host)
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'does not fail on monitoring proxy error' do
|
38
|
+
monitoring_mock.expects(:del_downtime_host).once.raises(exception)
|
39
|
+
assert dlmlock.release!(host)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This calls the main test_helper in Foreman-core
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
# Add plugin to FactoryBot's paths
|
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
|
9
|
+
FactoryBot.reload
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: foreman_dlm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Timo Goebel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Adds a Distributed Lock Manager to Foreman. This enables painless system
|
42
|
+
updates for clusters.
|
43
|
+
email:
|
44
|
+
- timo.goebel@dm.de
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- LICENSE
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- app/controllers/api/v2/dlmlocks_controller.rb
|
53
|
+
- app/controllers/concerns/foreman/controller/parameters/dlmlocks.rb
|
54
|
+
- app/controllers/concerns/foreman_dlm/find_host_by_client_cert.rb
|
55
|
+
- app/controllers/concerns/foreman_dlm/find_host_by_ip.rb
|
56
|
+
- app/controllers/dlmlocks_controller.rb
|
57
|
+
- app/helpers/foreman_dlm/dlmlock_helper.rb
|
58
|
+
- app/models/concerns/foreman_dlm/host_extensions.rb
|
59
|
+
- app/models/concerns/foreman_dlm/host_monitoring_extensions.rb
|
60
|
+
- app/models/dlmlock.rb
|
61
|
+
- app/models/dlmlock/update.rb
|
62
|
+
- app/views/api/v2/dlmlocks/acquire.json.rabl
|
63
|
+
- app/views/api/v2/dlmlocks/base.json.rabl
|
64
|
+
- app/views/api/v2/dlmlocks/create.json.rabl
|
65
|
+
- app/views/api/v2/dlmlocks/index.json.rabl
|
66
|
+
- app/views/api/v2/dlmlocks/main.json.rabl
|
67
|
+
- app/views/api/v2/dlmlocks/release.json.rabl
|
68
|
+
- app/views/api/v2/dlmlocks/show.json.rabl
|
69
|
+
- app/views/api/v2/dlmlocks/update.json.rabl
|
70
|
+
- 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
|
76
|
+
- config/routes.rb
|
77
|
+
- db/migrate/20170824084100_add_dlmlock.foreman_dlm.rb
|
78
|
+
- lib/foreman_dlm.rb
|
79
|
+
- lib/foreman_dlm/engine.rb
|
80
|
+
- lib/foreman_dlm/version.rb
|
81
|
+
- lib/tasks/foreman_dlm_tasks.rake
|
82
|
+
- locale/Makefile
|
83
|
+
- locale/en/foreman_dlm.po
|
84
|
+
- locale/foreman_dlm.pot
|
85
|
+
- locale/gemspec.rb
|
86
|
+
- test/controllers/api/v2/dlmlocks_controller_test.rb
|
87
|
+
- test/controllers/dlmlocks_test.rb
|
88
|
+
- test/controllers/find_host_by_client_cert_test.rb
|
89
|
+
- test/factories/dlmlock.rb
|
90
|
+
- test/models/dlmlock_test.rb
|
91
|
+
- test/models/host_monitoring_test.rb
|
92
|
+
- test/test_plugin_helper.rb
|
93
|
+
homepage: https://github.com/timogoebel/foreman_dlm
|
94
|
+
licenses:
|
95
|
+
- GPL-3.0
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.7.3
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Distributed Lock Manager for Foreman.
|
117
|
+
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
|
+
- test/controllers/api/v2/dlmlocks_controller_test.rb
|
124
|
+
- test/controllers/find_host_by_client_cert_test.rb
|