nagios-promoo 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a4c97556cd0192da5dc5a9919e453ae268e11b6
4
- data.tar.gz: 10753a0c8b874b989c6e1a08d6dcf48dc5275b30
3
+ metadata.gz: 776caf450626d472aa75ddd72a1cb24ed231b858
4
+ data.tar.gz: c1833207e57564af55bd7363f7ab0e19872a269a
5
5
  SHA512:
6
- metadata.gz: fd5cf2d9e47bb4a8ecd46eea83c9e092b2b6411bb20187c5f67b086fc2bd17f18ad3182244ebc5a458e8c5aaf68a4ab31d9ee66fc7819da21ca9806b667a4fc9
7
- data.tar.gz: f0131cefac9ffaa2125bcfde5cce57f6dc571eb382b1c4865a53fd03db8f286062e03232c0368c3d49191c6854ff34f45fa8e2aa8dcda3b8169c47587c868ab0
6
+ metadata.gz: 62f74f848f0de94c5f2b3c78477a0b5fc153c59ed0f8688daee0dc5ea66c307f7e9fc9eb3e4cb3492502d5f1dba011a5ecc58e588b4fbf9db10b9c81769dedd7
7
+ data.tar.gz: 340a9af73318b73f8c61ee64ca1d0a1fdd4bff45ba58d80eac594273aa635059bb52665a377ed9290c2132d6be0307c1a045d1041215d419ca8191df332170df
data/History.md CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ 1.7.0 / 2017-11-24
3
+ ==================
4
+
5
+ * Switching to AppDB IS in AppDB probes
6
+
2
7
  1.6.0 / 2017-11-20
3
8
  ==================
4
9
 
@@ -15,7 +15,16 @@ module Nagios
15
15
  end
16
16
 
17
17
  def options
18
- []
18
+ [
19
+ [
20
+ :vo,
21
+ {
22
+ type: :string,
23
+ required: true,
24
+ desc: 'Virtual Organization name (used to select the appropriate set of appliances)'
25
+ }
26
+ ]
27
+ ]
19
28
  end
20
29
 
21
30
  def declaration
@@ -28,27 +37,18 @@ module Nagios
28
37
  end
29
38
 
30
39
  def run(_args = [])
31
- @_count = 0
32
-
33
- Timeout.timeout(options[:timeout]) { check_appliances }
34
-
35
- if @_count < 1
36
- puts 'APPLIANCES CRITICAL - No appliances found in AppDB'
40
+ count = Timeout.timeout(options[:timeout]) { appliances_by_endpoint(options[:vo]).count }
41
+ if count < 1
42
+ puts "APPLIANCES CRITICAL - No appliances found for VO #{options[:vo]} in AppDB"
37
43
  exit 2
38
44
  end
39
45
 
40
- puts "APPLIANCES OK - Found #{@_count} appliances in AppDB"
46
+ puts "APPLIANCES OK - Found #{count} appliances for VO #{options[:vo]} in AppDB"
41
47
  rescue => ex
42
48
  puts "APPLIANCES UNKNOWN - #{ex.message}"
43
49
  puts ex.backtrace if options[:debug]
44
50
  exit 3
45
51
  end
46
-
47
- private
48
-
49
- def check_appliances
50
- @_count = [appdb_provider['provider:image']].flatten.compact.count
51
- end
52
52
  end
53
53
  end
54
54
  end
@@ -12,39 +12,61 @@ module Nagios
12
12
  end
13
13
  end
14
14
 
15
- APPDB_PROVIDERS_URL = 'https://appdb.egi.eu/rest/1.0/va_providers?listmode=details'.freeze
15
+ APPDB_IS_URL = 'http://is.marie.hellasgrid.gr/graphql'.freeze
16
+ DEFAULT_HEADERS = { 'Content-Type' => 'application/json' }.freeze
17
+ GQL_SIZES_BY_ENDPOINT = %|
18
+ {
19
+ siteServiceTemplates(
20
+ filter: { service: { endpointURL: { eq: "$$ENDPOINT$$" } } }, limit: 1000
21
+ ) {
22
+ items { resourceID }
23
+ }
24
+ }
25
+ |.freeze
26
+ GQL_APPLIANCES_BY_ENDPOINT = %|
27
+ {
28
+ siteServiceImages(
29
+ filter: { imageVoVmiInstanceVO: { eq: "$$VO$$" }, service: { endpointURL: { eq: "$$ENDPOINT$$" } } }, limit: 1000
30
+ ) {
31
+ items { applicationEnvironmentRepository applicationEnvironmentAppVersion }
32
+ }
33
+ }
34
+ |.freeze
16
35
 
17
- attr_reader :options
36
+ attr_reader :options, :endpoint
18
37
 
19
38
  def initialize(options)
20
39
  @options = options
40
+ @endpoint = options[:endpoint].gsub(%r{/+$}, '')
21
41
  end
22
42
 
23
- def appdb_provider
24
- return @_provider if @_provider
43
+ def sizes_by_endpoint
44
+ return @_sizes if @_sizes
25
45
 
26
- @_provider = appdb_providers.detect do |prov|
27
- prov['provider:endpoint_url'].chomp('/') == options[:endpoint].chomp('/')
28
- end
29
- raise "Could not locate site by endpoint #{options[:endpoint].inspect} in AppDB" unless @_provider
46
+ query = GQL_SIZES_BY_ENDPOINT.gsub('$$ENDPOINT$$', endpoint)
47
+ @_sizes = make(query)['data']['siteServiceTemplates']['items']
48
+ raise "Could not locate sizes from endpoint #{endpoint.inspect} in AppDB" unless @_sizes
30
49
 
31
- @_provider
50
+ @_sizes
32
51
  end
33
52
 
34
- private
53
+ def appliances_by_endpoint(vo)
54
+ return @_appliances if @_appliances
35
55
 
36
- def appdb_providers
37
- response = HTTParty.get(APPDB_PROVIDERS_URL)
38
- raise "Could not get site details from AppDB [HTTP #{response.code}]" unless response.success?
39
- raise 'Response from AppDB has unexpected structure' unless valid_response?(response.parsed_response)
56
+ query = GQL_APPLIANCES_BY_ENDPOINT.gsub('$$ENDPOINT$$', endpoint).gsub('$$VO$$', vo)
57
+ @_appliances = make(query)['data']['siteServiceImages']['items']
58
+ raise "Could not locate appliances from endpoint #{endpoint.inspect} in AppDB" unless @_appliances
40
59
 
41
- providers = response.parsed_response['appdb:appdb']['virtualization:provider']
42
- providers.delete_if { |prov| prov['provider:endpoint_url'].blank? }
60
+ @_appliances
43
61
  end
44
62
 
45
- def valid_response?(response)
46
- response['appdb:appdb'] \
47
- && response['appdb:appdb']['virtualization:provider']
63
+ private
64
+
65
+ def make(query)
66
+ response = HTTParty.post(APPDB_IS_URL, body: { query: query }.to_json, headers: DEFAULT_HEADERS)
67
+ raise "#{query.inspect} failed to get data from AppDB [HTTP #{response.code}]" unless response.success?
68
+
69
+ response.parsed_response
48
70
  end
49
71
  end
50
72
  end
@@ -28,27 +28,18 @@ module Nagios
28
28
  end
29
29
 
30
30
  def run(_args = [])
31
- @_count = 0
32
-
33
- Timeout.timeout(options[:timeout]) { check_sizes }
34
-
35
- if @_count < 1
31
+ count = Timeout.timeout(options[:timeout]) { sizes_by_endpoint.count }
32
+ if count < 1
36
33
  puts 'SIZES CRITICAL - No size/flavor/resource templates found in AppDB'
37
34
  exit 2
38
35
  end
39
36
 
40
- puts "SIZES OK - Found #{@_count} size/flavor/resource templates in AppDB"
37
+ puts "SIZES OK - Found #{count} size/flavor/resource templates in AppDB"
41
38
  rescue => ex
42
39
  puts "SIZES UNKNOWN - #{ex.message}"
43
40
  puts ex.backtrace if options[:debug]
44
41
  exit 3
45
42
  end
46
-
47
- private
48
-
49
- def check_sizes
50
- @_count = [appdb_provider['provider:template']].flatten.compact.count
51
- end
52
43
  end
53
44
  end
54
45
  end
@@ -104,42 +104,34 @@ module Nagios
104
104
  mpuri_versionless = versionless_mpuri(hv_image['ad:mpuri'])
105
105
  @_results[:expected] << mpuri_versionless
106
106
 
107
- matching = provider_appliances.detect { |appl| appl['mp_uri'] == mpuri_versionless }
107
+ matching = appliances_by_endpoint(options[:vo]).detect do |appl|
108
+ versionless_mpuri(appl['applicationEnvironmentRepository']) == mpuri_versionless
109
+ end
110
+
108
111
  unless matching
109
112
  @_results[:missing] << mpuri_versionless
110
113
  next
111
114
  end
112
115
 
113
- @_results[:outdated] << mpuri_versionless if hv_image['hv:version'] != matching['vmiversion']
114
- @_results[:found] << mpuri_versionless
115
- end
116
- end
117
-
118
- def provider_appliances
119
- return @_appliances if @_appliances
120
-
121
- @_appliances = [appdb_provider['provider:image']].flatten.compact
122
- @_appliances.keep_if { |appliance| appliance['voname'] == options[:vo] }
123
- @_appliances.reject { |appliance| appliance['mp_uri'].blank? }
116
+ unless hv_image['hv:version'] == matching['applicationEnvironmentAppVersion']
117
+ @_results[:outdated] << mpuri_versionless
118
+ end
124
119
 
125
- @_appliances.each do |appliance|
126
- appliance['mp_uri'] = versionless_mpuri(appliance['mp_uri'])
120
+ @_results[:found] << mpuri_versionless
127
121
  end
128
-
129
- @_appliances
130
122
  end
131
123
 
132
124
  def vo_list
133
125
  return @_hv_images if @_hv_images
134
126
 
135
- list = JSON.parse pkcs7_data
136
- raise "AppDB image list #{list_url.inspect} is empty or malformed" unless list && list['hv:imagelist']
127
+ list = JSON.parse(pkcs7_data)
128
+ raise 'AppDB image list is empty or malformed' unless list && list['hv:imagelist']
137
129
 
138
130
  list = list['hv:imagelist']
139
131
  unless Time.parse(list['dc:date:expires']) > Time.now
140
- raise "AppDB image list #{list_url.inspect} has expired"
132
+ raise 'AppDB image list has expired'
141
133
  end
142
- raise "AppDB image list #{list_url.inspect} doesn't contain images" unless list['hv:images']
134
+ raise "AppDB image list doesn't contain images" unless list['hv:images']
143
135
  @_last_update = Time.parse(list['dc:date:created'])
144
136
 
145
137
  @_hv_images = list['hv:images'].collect { |im| im['hv:image'] }
@@ -153,11 +145,9 @@ module Nagios
153
145
  end
154
146
 
155
147
  def retrieve_list
156
- response = HTTParty.get list_url
157
- unless response.success?
158
- raise 'Could not get a VO-wide image list' \
159
- "from #{list_url.inspect} [#{response.code}]"
160
- end
148
+ response = HTTParty.get(list_url)
149
+ raise "Could not get an image list from AppDB [HTTP #{response.code}]" unless response.success?
150
+
161
151
  response.parsed_response
162
152
  end
163
153
 
@@ -1,7 +1,7 @@
1
1
  module Nagios
2
2
  module Promoo
3
3
  module Appdb
4
- VERSION = '1.2.1'.freeze
4
+ VERSION = '1.3.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  module Nagios
2
2
  module Promoo
3
- VERSION = '1.6.0'.freeze
3
+ VERSION = '1.7.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nagios-promoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Parak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-20 00:00:00.000000000 Z
11
+ date: 2017-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport