foreman_icinga 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/app/models/host_status/icinga_status.rb +4 -1
- data/app/services/icinga.rb +1 -2
- data/lib/foreman_icinga/engine.rb +1 -1
- data/lib/foreman_icinga/version.rb +1 -1
- data/test/unit/icinga_test.rb +2 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3277325729411ef0c006c242754b121f24c567fd
|
4
|
+
data.tar.gz: a3e5077b6524e54541f846ddfd9e88eaac02bdda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09c9ea01e0cf162bcdf8f28139f80fc9e1e73043463b16619a98a350505a777d981cfa23953bf9ff06b2b56d28e414d85c3d3eaa2f2827ea0489c0b8d45b36ce
|
7
|
+
data.tar.gz: 28735b6498e8d5dffc73607fd80c10d97c3f28cc95d1d933ff79ef805c08ecceabca5c92b2e8677d325c182889ac6a3cbdb8683978882ae0e337e9eb10518329
|
@@ -5,7 +5,7 @@ module HostStatus
|
|
5
5
|
CRITICAL = 2
|
6
6
|
UNKNOWN = 3
|
7
7
|
|
8
|
-
def relevant?
|
8
|
+
def relevant?(options = {})
|
9
9
|
host_not_in_build? && host_known_in_icinga?
|
10
10
|
end
|
11
11
|
|
@@ -62,9 +62,12 @@ module HostStatus
|
|
62
62
|
|
63
63
|
def call_icinga
|
64
64
|
client.call('deployment/health/check', '', 'host' => host.name)
|
65
|
+
rescue RestClient::Unauthorized
|
66
|
+
nil
|
65
67
|
end
|
66
68
|
|
67
69
|
def parse_host_status(response)
|
70
|
+
return UNKNOWN if response.nil?
|
68
71
|
return UNKNOWN if response.key?('status') && response['status'] == 'error'
|
69
72
|
return UNKNOWN unless response.key?('healthy')
|
70
73
|
if response['healthy']
|
data/app/services/icinga.rb
CHANGED
@@ -47,7 +47,6 @@ class Icinga
|
|
47
47
|
|
48
48
|
def default_params
|
49
49
|
{
|
50
|
-
'token' => token,
|
51
50
|
'json' => true
|
52
51
|
}
|
53
52
|
end
|
@@ -83,6 +82,6 @@ class Icinga
|
|
83
82
|
def icinga_url_for(route, params = {})
|
84
83
|
base = URI.join(address, route).to_s
|
85
84
|
return base if params.empty?
|
86
|
-
base + '?' + params.to_query
|
85
|
+
base + '?' + params.to_query + '&token=' + token
|
87
86
|
end
|
88
87
|
end
|
@@ -18,7 +18,7 @@ module ForemanIcinga
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
initializer 'foreman_icinga.register_plugin', :
|
21
|
+
initializer 'foreman_icinga.register_plugin', :before => :finisher_hook do |_app|
|
22
22
|
Foreman::Plugin.register :foreman_icinga do
|
23
23
|
requires_foreman '>= 1.10'
|
24
24
|
register_custom_status HostStatus::IcingaStatus
|
data/test/unit/icinga_test.rb
CHANGED
@@ -6,16 +6,10 @@ class IcingaTest < ActiveSupport::TestCase
|
|
6
6
|
@icinga = Icinga.new
|
7
7
|
end
|
8
8
|
|
9
|
-
test '#default_params should contain token' do
|
10
|
-
default_params = @icinga.send('default_params')
|
11
|
-
assert_kind_of Hash, default_params
|
12
|
-
assert_equal '123456', default_params['token']
|
13
|
-
end
|
14
|
-
|
15
9
|
test '#icinga_url_for should return valid urls' do
|
16
|
-
assert_equal 'http://example.com/test/bla',
|
10
|
+
assert_equal 'http://example.com/test/bla&token=123456',
|
17
11
|
@icinga.send('icinga_url_for', 'test/bla')
|
18
|
-
assert_equal 'http://example.com/test/blubb?param=1',
|
12
|
+
assert_equal 'http://example.com/test/blubb?param=1&token=123456',
|
19
13
|
@icinga.send('icinga_url_for', 'test/blubb', 'param' => '1')
|
20
14
|
end
|
21
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_icinga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Goebel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|