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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5fe9e348c1efab758fe5a284d1930996c46c7de
4
- data.tar.gz: e0a372b1d4874cca69ea5ec54ec92b62e42926c0
3
+ metadata.gz: 3277325729411ef0c006c242754b121f24c567fd
4
+ data.tar.gz: a3e5077b6524e54541f846ddfd9e88eaac02bdda
5
5
  SHA512:
6
- metadata.gz: e7cac06f97608db518c02d48e690b64937528299d3f6b8d83fb87d67caf9a05a57b9c9b583ef565fa329cd75d6b06eeb71b0c07e587f5a3fc67d1ef842581f31
7
- data.tar.gz: b56b4203b95f04b32ca6963ce08a7f32730f9879ba9736ea6cb89b7f7ff40fbb8c181163a15be8aec616eb011d36463125c21fc27bc269d1edad64ee037e2ecc
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']
@@ -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', :after => :finisher_hook do |_app|
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
@@ -1,3 +1,3 @@
1
1
  module ForemanIcinga
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -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.0
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: 2015-12-28 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client