nagios-promoo 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nagios/promoo/appdb/master.rb +1 -1
- data/lib/nagios/promoo/appdb/probes/appliances_probe.rb +14 -11
- data/lib/nagios/promoo/appdb/probes/base_probe.rb +27 -8
- data/lib/nagios/promoo/appdb/probes/sizes_probe.rb +15 -12
- data/lib/nagios/promoo/appdb/probes/vmcatcher_probe.rb +57 -69
- data/lib/nagios/promoo/appdb/version.rb +1 -1
- data/lib/nagios/promoo/occi/master.rb +1 -1
- data/lib/nagios/promoo/occi/probes/base_probe.rb +8 -2
- data/lib/nagios/promoo/occi/probes/categories_probe.rb +18 -20
- data/lib/nagios/promoo/occi/probes/compute_probe.rb +75 -68
- data/lib/nagios/promoo/occi/probes/kinds_probe.rb +17 -19
- data/lib/nagios/promoo/occi/probes/mixins_probe.rb +7 -9
- data/lib/nagios/promoo/occi/version.rb +1 -1
- data/lib/nagios/promoo/opennebula/master.rb +1 -1
- data/lib/nagios/promoo/opennebula/probes/base_probe.rb +9 -3
- data/lib/nagios/promoo/opennebula/probes/virtual_machine_probe.rb +42 -44
- data/lib/nagios/promoo/opennebula/probes/xmlrpc_health_probe.rb +7 -10
- data/lib/nagios/promoo/opennebula/version.rb +1 -1
- data/lib/nagios/promoo/version.rb +1 -1
- data/nagios-promoo.gemspec +14 -14
- metadata +125 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e735c8510920fe9ed8dd4d200c31aca66a7771f
|
4
|
+
data.tar.gz: c7ca40aa71dbf5291d3b975860518758bce65bee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e1ca3d2b6a99c7a34d19b06e2feecdc49e24aecb63c6a57ce526c5ab1858a0ffcb9ec4f9272b80162c801f2002170d1faea6f3bae6cb0b4d445c1b51cc17acd
|
7
|
+
data.tar.gz: 9c15ac5874413491dcd88b478f71f681e71c796550bda663666b3ea38b0e4bd8c559f85513e8b0dbf867e7a00ffe96f4102792085b64d6c347839e56296ad71b
|
@@ -18,23 +18,26 @@ class Nagios::Promoo::Appdb::Probes::AppliancesProbe < Nagios::Promoo::Appdb::Pr
|
|
18
18
|
def runnable?; true; end
|
19
19
|
end
|
20
20
|
|
21
|
-
def run(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
puts "APPLIANCES CRITICAL -
|
28
|
-
puts ex.backtrace if options[:debug]
|
21
|
+
def run(args = [])
|
22
|
+
@_count = 0
|
23
|
+
|
24
|
+
Timeout::timeout(options[:timeout]) { check_appliances }
|
25
|
+
|
26
|
+
if @_count < 1
|
27
|
+
puts "APPLIANCES CRITICAL - No appliances found in AppDB"
|
29
28
|
exit 2
|
30
29
|
end
|
31
30
|
|
32
|
-
puts "APPLIANCES OK - Found #{
|
31
|
+
puts "APPLIANCES OK - Found #{@_count} appliances in AppDB"
|
32
|
+
rescue => ex
|
33
|
+
puts "APPLIANCES UNKNOWN - #{ex.message}"
|
34
|
+
puts ex.backtrace if options[:debug]
|
35
|
+
exit 3
|
33
36
|
end
|
34
37
|
|
35
38
|
private
|
36
39
|
|
37
|
-
def check_appliances
|
38
|
-
[appdb_provider
|
40
|
+
def check_appliances
|
41
|
+
@_count = [appdb_provider['provider:image']].flatten.compact.count
|
39
42
|
end
|
40
43
|
end
|
@@ -6,18 +6,37 @@ class Nagios::Promoo::Appdb::Probes::BaseProbe
|
|
6
6
|
APPDB_PROXY_URL = 'https://appdb.egi.eu/api/proxy'
|
7
7
|
APPDB_REQUEST_FORM = 'version=1.0&resource=broker&data=%3Cappdb%3Abroker%20xmlns%3Axs%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3Aappdb%3D%22http%3A%2F%2Fappdb.egi.eu%2Fapi%2F1.0%2Fappdb%22%3E%3Cappdb%3Arequest%20id%3D%22vaproviders%22%20method%3D%22GET%22%20resource%3D%22va_providers%22%3E%3Cappdb%3Aparam%20name%3D%22listmode%22%3Edetails%3C%2Fappdb%3Aparam%3E%3C%2Fappdb%3Arequest%3E%3C%2Fappdb%3Abroker%3E'
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
attr_reader :options
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def appdb_provider
|
16
|
+
return @_provider if @_provider
|
11
17
|
|
12
18
|
response = HTTParty.post(APPDB_PROXY_URL, { :body => APPDB_REQUEST_FORM })
|
13
19
|
fail "Could not get site"\
|
14
|
-
"details from AppDB [#{response.code}]" unless response.success?
|
20
|
+
"details from AppDB [HTTP #{response.code}]" unless response.success?
|
21
|
+
fail "Response from AppDB has unexpected structure" unless valid_response?(response.parsed_response)
|
22
|
+
|
23
|
+
providers = response.parsed_response['appdb:broker']['appdb:reply']['appdb:appdb']['virtualization:provider']
|
24
|
+
providers.delete_if { |prov| prov['provider:endpoint_url'].blank? }
|
25
|
+
|
26
|
+
@_provider = providers.select do |prov|
|
27
|
+
prov['provider:endpoint_url'].chomp('/') == options[:endpoint].chomp('/')
|
28
|
+
end.first
|
29
|
+
fail "Could not locate site by endpoint #{options[:endpoint].inspect} in AppDB" unless @_provider
|
30
|
+
|
31
|
+
@_provider
|
32
|
+
end
|
15
33
|
|
16
|
-
|
17
|
-
prov['provider:endpoint_url'] && (prov['provider:endpoint_url'].chomp('/') == options[:endpoint].chomp('/'))
|
18
|
-
end.first
|
19
|
-
fail "Could not locate site by endpoint #{options[:endpoint].inspect} in AppDB" unless @provider
|
34
|
+
private
|
20
35
|
|
21
|
-
|
36
|
+
def valid_response?(response)
|
37
|
+
response['appdb:broker'] \
|
38
|
+
&& response['appdb:broker']['appdb:reply'] \
|
39
|
+
&& response['appdb:broker']['appdb:reply']['appdb:appdb'] \
|
40
|
+
&& response['appdb:broker']['appdb:reply']['appdb:appdb']['virtualization:provider']
|
22
41
|
end
|
23
42
|
end
|
@@ -4,7 +4,7 @@ require File.join(File.dirname(__FILE__), 'base_probe')
|
|
4
4
|
class Nagios::Promoo::Appdb::Probes::SizesProbe < Nagios::Promoo::Appdb::Probes::BaseProbe
|
5
5
|
class << self
|
6
6
|
def description
|
7
|
-
['sizes', 'Run a probe checking size templates in AppDB']
|
7
|
+
['sizes', 'Run a probe checking size/flavor/resource templates in AppDB']
|
8
8
|
end
|
9
9
|
|
10
10
|
def options
|
@@ -18,23 +18,26 @@ class Nagios::Promoo::Appdb::Probes::SizesProbe < Nagios::Promoo::Appdb::Probes:
|
|
18
18
|
def runnable?; true; end
|
19
19
|
end
|
20
20
|
|
21
|
-
def run(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
puts "SIZES CRITICAL -
|
28
|
-
puts ex.backtrace if options[:debug]
|
21
|
+
def run(args = [])
|
22
|
+
@_count = 0
|
23
|
+
|
24
|
+
Timeout::timeout(options[:timeout]) { check_sizes }
|
25
|
+
|
26
|
+
if @_count < 1
|
27
|
+
puts "SIZES CRITICAL - No size/flavor/resource templates found in AppDB"
|
29
28
|
exit 2
|
30
29
|
end
|
31
30
|
|
32
|
-
puts "SIZES OK - Found #{
|
31
|
+
puts "SIZES OK - Found #{@_count} size/flavor/resource templates in AppDB"
|
32
|
+
rescue => ex
|
33
|
+
puts "SIZES UNKNOWN - #{ex.message}"
|
34
|
+
puts ex.backtrace if options[:debug]
|
35
|
+
exit 3
|
33
36
|
end
|
34
37
|
|
35
38
|
private
|
36
39
|
|
37
|
-
def check_sizes
|
38
|
-
[appdb_provider
|
40
|
+
def check_sizes
|
41
|
+
@_count = [appdb_provider['provider:template']].flatten.compact.count
|
39
42
|
end
|
40
43
|
end
|
@@ -26,91 +26,79 @@ class Nagios::Promoo::Appdb::Probes::VmcatcherProbe < Nagios::Promoo::Appdb::Pro
|
|
26
26
|
IMAGE_LIST_TEMPLATE = "https://$$TOKEN$$:x-oauth-basic@vmcaster.appdb.egi.eu/store/vo/$$VO$$/image.list"
|
27
27
|
IMAGE_LIST_BOUNDARY_REGEXP = /boundary="(?<prefix>-+)(?<id>[[:alnum:]]+)"/
|
28
28
|
|
29
|
-
def run(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
def run(args = [])
|
30
|
+
@_results = { found: [], outdated: [], missing: [], expected: [] }
|
31
|
+
|
32
|
+
Timeout::timeout(options[:timeout]) { check_vmc_sync }
|
33
|
+
|
34
|
+
if @_results[:missing].count >= options[:missing_critical]
|
35
|
+
puts "VMCATCHER CRITICAL - #{@_results[:missing].count} appliance(s) in #{options[:vo].inspect} missing"
|
36
|
+
exit 2
|
37
|
+
end
|
38
|
+
|
39
|
+
if @_results[:outdated].count >= options[:outdated_critical]
|
40
|
+
puts "VMCATCHER CRITICAL - #{@_results[:outdated].count} appliance(s) in #{options[:vo].inspect} outdated"
|
40
41
|
exit 2
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
#
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
# end
|
54
|
-
|
55
|
-
puts "VMCATCHER OK - All appliances registered in #{options[:vo].inspect} are available [#{results[:expected].count}]"
|
44
|
+
if @_results[:outdated].count > 0
|
45
|
+
puts "VMCATCHER WARNING - #{@_results[:outdated].count} appliances in #{options[:vo].inspect} outdated"
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "VMCATCHER OK - All appliances registered in #{options[:vo].inspect} are available [#{@_results[:expected].count}]"
|
50
|
+
rescue => ex
|
51
|
+
puts "VMCATCHER UNKNOWN - #{ex.message}"
|
52
|
+
puts ex.backtrace if options[:debug]
|
53
|
+
exit 3
|
56
54
|
end
|
57
55
|
|
58
56
|
private
|
59
57
|
|
60
|
-
def check_vmc_sync
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
elsif versionless_appliances(options).include?(mpuri_versionless)
|
71
|
-
results[:found] << mpuri_versionless
|
72
|
-
results[:outdated] << mpuri_versionless
|
73
|
-
else
|
74
|
-
results[:missing] << mpuri_versionless
|
58
|
+
def check_vmc_sync
|
59
|
+
vo_list.each do |hv_image|
|
60
|
+
mpuri_versionless = versionless_mpuri(hv_image['ad:mpuri'])
|
61
|
+
@_results[:expected] << mpuri_versionless
|
62
|
+
|
63
|
+
matching = provider_appliances.select { |appl| appl['mp_uri'] == mpuri_versionless }.first
|
64
|
+
|
65
|
+
unless matching
|
66
|
+
@_results[:missing] << mpuri_versionless
|
67
|
+
next
|
75
68
|
end
|
76
|
-
end
|
77
69
|
|
78
|
-
|
70
|
+
@_results[:outdated] << mpuri_versionless if hv_image['hv:version'] != matching['vmiversion']
|
71
|
+
@_results[:found] << mpuri_versionless
|
72
|
+
end
|
79
73
|
end
|
80
74
|
|
81
|
-
def provider_appliances
|
82
|
-
|
83
|
-
images.collect { |image| image['mp_uri'] }.reject { |mpuri| mpuri.blank? }
|
84
|
-
end
|
75
|
+
def provider_appliances
|
76
|
+
return @_appliances if @_appliances
|
85
77
|
|
86
|
-
|
87
|
-
|
88
|
-
|
78
|
+
@_appliances = [appdb_provider['provider:image']].flatten.compact
|
79
|
+
@_appliances.keep_if { |appliance| appliance['voname'] == options[:vo] }
|
80
|
+
@_appliances.reject { |appliance| appliance['mp_uri'].blank? }
|
89
81
|
|
90
|
-
|
91
|
-
|
82
|
+
@_appliances.each do |appliance|
|
83
|
+
appliance['mp_uri'] = versionless_mpuri(appliance['mp_uri'])
|
84
|
+
end
|
85
|
+
|
86
|
+
@_appliances
|
92
87
|
end
|
93
88
|
|
94
|
-
def vo_list
|
95
|
-
return @
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
fail "AppDB image list #{list_url.inspect} does " \
|
106
|
-
"not contain images" unless list && list['hv:imagelist'] && list['hv:imagelist']['hv:images']
|
107
|
-
rescue => ex
|
108
|
-
puts "VMCATCHER UNKNOWN - #{ex.message}"
|
109
|
-
puts ex.backtrace if options[:debug]
|
110
|
-
exit 3
|
111
|
-
end
|
89
|
+
def vo_list
|
90
|
+
return @_hv_images if @_hv_images
|
91
|
+
|
92
|
+
list_url = IMAGE_LIST_TEMPLATE.gsub('$$TOKEN$$', options[:token]).gsub('$$VO$$', options[:vo])
|
93
|
+
response = HTTParty.get list_url
|
94
|
+
fail "Could not get a VO-wide image list" \
|
95
|
+
"from #{list_url.inspect} [#{response.code}]" unless response.success?
|
96
|
+
|
97
|
+
list = JSON.parse OpenSSL::PKCS7.read_smime(response.parsed_response).data
|
98
|
+
fail "AppDB image list #{list_url.inspect} does " \
|
99
|
+
"not contain images" unless list && list['hv:imagelist'] && list['hv:imagelist']['hv:images']
|
112
100
|
|
113
|
-
@
|
101
|
+
@_hv_images = list['hv:imagelist']['hv:images'].collect { |im| im['hv:image'] }.reject { |im| im.blank? || im['ad:mpuri'].blank? }
|
114
102
|
end
|
115
103
|
|
116
104
|
def normalize_mpuri(mpuri)
|
@@ -3,8 +3,14 @@ class Nagios::Promoo::Occi::Probes::BaseProbe
|
|
3
3
|
def runnable?; false; end
|
4
4
|
end
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
attr_reader :options
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def client
|
13
|
+
@_client ||= Occi::Api::Client::ClientHttp.new({
|
8
14
|
:endpoint => options[:endpoint],
|
9
15
|
:auth => {
|
10
16
|
:type => options[:auth].gsub('-voms', ''),
|
@@ -23,34 +23,32 @@ class Nagios::Promoo::Occi::Probes::CategoriesProbe < Nagios::Promoo::Occi::Prob
|
|
23
23
|
def runnable?; true; end
|
24
24
|
end
|
25
25
|
|
26
|
-
def run(
|
26
|
+
def run(args = [])
|
27
27
|
categories = all_categories
|
28
28
|
categories -= options[:optional] if options[:optional]
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
fail "Failed to verify declared REST location for #{cat.inspect} (#{err.message})"
|
44
|
-
end
|
30
|
+
Timeout::timeout(options[:timeout]) do
|
31
|
+
categories.each do |cat|
|
32
|
+
fail "#{cat.inspect} is missing" unless client.model.get_by_id(cat, true)
|
33
|
+
next unless options[:check_location] && Nagios::Promoo::Occi::Probes::KindsProbe::INFRA_KINDS.include?(cat)
|
34
|
+
|
35
|
+
# Make sure declared locations are actually available as REST
|
36
|
+
# endpoints. Failure will raise an exception, no need to do
|
37
|
+
# anything here. To keep requirements reasonable, only INFRA
|
38
|
+
# kinds are considered relevant for this part of the check.
|
39
|
+
begin
|
40
|
+
client.list(cat)
|
41
|
+
rescue => err
|
42
|
+
fail "Failed to verify declared REST location for #{cat.inspect} (#{err.message})"
|
45
43
|
end
|
46
44
|
end
|
47
|
-
rescue => ex
|
48
|
-
puts "CATEGORIES CRITICAL - #{ex.message}"
|
49
|
-
puts ex.backtrace if options[:debug]
|
50
|
-
exit 2
|
51
45
|
end
|
52
46
|
|
53
47
|
puts 'CATEGORIES OK - All specified OCCI categories were found'
|
48
|
+
rescue => ex
|
49
|
+
puts "CATEGORIES CRITICAL - #{ex.message}"
|
50
|
+
puts ex.backtrace if options[:debug]
|
51
|
+
exit 2
|
54
52
|
end
|
55
53
|
|
56
54
|
private
|
@@ -33,127 +33,120 @@ class Nagios::Promoo::Occi::Probes::ComputeProbe < Nagios::Promoo::Occi::Probes:
|
|
33
33
|
APPDB_PROXY_URL = 'https://appdb.egi.eu/api/proxy'
|
34
34
|
APPDB_REQUEST_FORM = 'version=1.0&resource=broker&data=%3Cappdb%3Abroker%20xmlns%3Axs%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3Aappdb%3D%22http%3A%2F%2Fappdb.egi.eu%2Fapi%2F1.0%2Fappdb%22%3E%3Cappdb%3Arequest%20id%3D%22vaproviders%22%20method%3D%22GET%22%20resource%3D%22va_providers%22%3E%3Cappdb%3Aparam%20name%3D%22listmode%22%3Edetails%3C%2Fappdb%3Aparam%3E%3C%2Fappdb%3Arequest%3E%3C%2Fappdb%3Abroker%3E'
|
35
35
|
|
36
|
-
def run(
|
37
|
-
|
38
|
-
Timeout::timeout(options[:timeout]) { compute_provision(options) }
|
39
|
-
rescue Timeout::Error => ex
|
40
|
-
puts "COMPUTE CRITICAL - Probe execution timed out [#{options[:timeout]}s]"
|
41
|
-
exit 2
|
42
|
-
end
|
36
|
+
def run(args = [])
|
37
|
+
@_links = {}
|
43
38
|
|
44
|
-
|
39
|
+
Timeout::timeout(options[:timeout]) { compute_provision }
|
40
|
+
puts "COMPUTE OK - Instance(s) #{@_links[:compute].inspect} created & cleaned up"
|
41
|
+
rescue Timeout::Error => ex
|
42
|
+
puts "COMPUTE CRITICAL - Probe execution timed out [#{options[:timeout]}s]"
|
43
|
+
exit 2
|
45
44
|
end
|
46
45
|
|
47
46
|
private
|
48
47
|
|
49
|
-
def compute_provision
|
50
|
-
|
51
|
-
|
52
|
-
compute_link = compute_create(options)
|
53
|
-
links[:compute] = compute_link
|
54
|
-
wait4ready(compute_link, options)
|
48
|
+
def compute_provision
|
49
|
+
compute_create
|
55
50
|
|
56
51
|
if options[:with_storage]
|
57
|
-
|
58
|
-
|
59
|
-
wait4ready(storage_link, options)
|
60
|
-
|
61
|
-
slink = link_instances(compute_link, storage_link, options)
|
62
|
-
links[:storagelink] = slink
|
63
|
-
wait4ready(slink, options)
|
52
|
+
storage_create
|
53
|
+
link_instances
|
64
54
|
end
|
65
|
-
|
66
|
-
links
|
67
55
|
rescue => ex
|
68
56
|
puts "COMPUTE CRITICAL - #{ex.message}"
|
69
57
|
puts ex.backtrace if options[:debug]
|
70
58
|
exit 2
|
71
59
|
ensure
|
72
|
-
mandatory_cleanup
|
60
|
+
mandatory_cleanup @_links
|
73
61
|
end
|
74
62
|
|
75
|
-
def compute_create
|
76
|
-
client
|
63
|
+
def compute_create
|
64
|
+
client.delete('compute') if options[:cleanup]
|
77
65
|
|
78
|
-
compute = client
|
66
|
+
compute = client.get_resource('compute')
|
79
67
|
compute.title = compute.hostname = "#{COMPUTE_NAME_PREFIX}-#{Time.now.to_i}"
|
80
68
|
|
81
|
-
os_tpl, resource_tpl = appdb_information
|
82
|
-
compute.mixins << get_mixin(os_tpl, 'os_tpl'
|
83
|
-
compute.mixins << get_mixin(resource_tpl, 'resource_tpl'
|
69
|
+
os_tpl, resource_tpl = appdb_information
|
70
|
+
compute.mixins << get_mixin(os_tpl, 'os_tpl')
|
71
|
+
compute.mixins << get_mixin(resource_tpl, 'resource_tpl')
|
84
72
|
|
85
|
-
client
|
73
|
+
@_links[:compute] = client.create compute
|
74
|
+
wait4ready @_links[:compute]
|
86
75
|
end
|
87
76
|
|
88
|
-
def storage_create
|
89
|
-
client
|
77
|
+
def storage_create
|
78
|
+
client.delete('storage') if options[:cleanup]
|
90
79
|
|
91
|
-
storage = client
|
80
|
+
storage = client.get_resource('storage')
|
92
81
|
storage.title = "#{COMPUTE_NAME_PREFIX}-block-#{Time.now.to_i}"
|
93
82
|
storage.size = DEFAULT_STORAGE_SIZE # GB
|
94
83
|
|
95
|
-
client
|
84
|
+
@_links[:storage] = client.create storage
|
85
|
+
wait4ready @_links[:storage]
|
96
86
|
end
|
97
87
|
|
98
|
-
def link_instances
|
99
|
-
slink = client
|
100
|
-
slink.source =
|
101
|
-
slink.target =
|
88
|
+
def link_instances
|
89
|
+
slink = client.get_link('storagelink')
|
90
|
+
slink.source = @_links[:compute]
|
91
|
+
slink.target = @_links[:storage]
|
102
92
|
|
103
|
-
client
|
93
|
+
@_links[:storagelink] = client.create slink
|
94
|
+
wait4ready @_links[:storagelink]
|
104
95
|
end
|
105
96
|
|
106
|
-
def mandatory_cleanup(links
|
107
|
-
mandatory_cleanup_part links[:storagelink], true
|
108
|
-
mandatory_cleanup_part links[:storage], false
|
109
|
-
mandatory_cleanup_part links[:compute], false
|
97
|
+
def mandatory_cleanup(links)
|
98
|
+
mandatory_cleanup_part links[:storagelink], true
|
99
|
+
mandatory_cleanup_part links[:storage], false
|
100
|
+
mandatory_cleanup_part links[:compute], false
|
110
101
|
end
|
111
102
|
|
112
|
-
def mandatory_cleanup_part(link, wait4inactive
|
113
|
-
client
|
114
|
-
wait4inactive(link
|
103
|
+
def mandatory_cleanup_part(link, wait4inactive)
|
104
|
+
client.delete link
|
105
|
+
wait4inactive(link) if wait4inactive
|
115
106
|
rescue => ex
|
116
107
|
# ignore
|
117
108
|
end
|
118
109
|
|
119
|
-
def get_mixin(term, type
|
120
|
-
mxn = client
|
110
|
+
def get_mixin(term, type)
|
111
|
+
mxn = client.get_mixin(term, type, true)
|
121
112
|
fail "Mixin #{term.inspect} of type #{type.inspect} not found at the site" unless mxn
|
122
113
|
mxn
|
123
114
|
end
|
124
115
|
|
125
|
-
def wait4ready(link
|
116
|
+
def wait4ready(link)
|
126
117
|
state = nil
|
127
118
|
|
128
119
|
while !READY_STATES.include?(state) do
|
129
|
-
state = client
|
120
|
+
state = client.describe(link).first.state
|
130
121
|
fail "Provisioning failure on #{link.inspect}" if ERROR_STATES.include?(state)
|
131
122
|
sleep 5
|
132
123
|
end
|
133
124
|
end
|
134
125
|
|
135
|
-
def wait4inactive(link
|
126
|
+
def wait4inactive(link)
|
136
127
|
state = nil
|
137
128
|
|
138
129
|
while !NONREADY_STATES.include?(state) do
|
139
|
-
state = client
|
130
|
+
state = client.describe(link).first.state
|
140
131
|
fail "De-provisioning failure on #{link.inspect}" if ERROR_STATES.include?(state)
|
141
132
|
sleep 5
|
142
133
|
end
|
143
134
|
end
|
144
135
|
|
145
|
-
def appdb_information
|
146
|
-
[appdb_appliance
|
136
|
+
def appdb_information
|
137
|
+
[appdb_appliance, appdb_smallest_size]
|
147
138
|
rescue => ex
|
148
139
|
puts "COMPUTE UNKNOWN - #{ex.message}"
|
149
140
|
puts ex.backtrace if options[:debug]
|
150
141
|
exit 3
|
151
142
|
end
|
152
143
|
|
153
|
-
def appdb_appliance
|
154
|
-
|
155
|
-
|
156
|
-
|
144
|
+
def appdb_appliance
|
145
|
+
appliances = [appdb_provider['provider:image']].flatten.compact
|
146
|
+
appliances.delete_if { |appl| appl['mp_uri'].blank? }
|
147
|
+
|
148
|
+
appliance = appliances.select do |appl|
|
149
|
+
normalize_mpuri(appl['mp_uri']) == normalize_mpuri(options[:mpuri])
|
157
150
|
end.first
|
158
151
|
fail "Site does not have an appliance with MPURI "\
|
159
152
|
"#{normalize_mpuri(options[:mpuri]).inspect} published in AppDB" if appliance.blank?
|
@@ -161,41 +154,55 @@ class Nagios::Promoo::Occi::Probes::ComputeProbe < Nagios::Promoo::Occi::Probes:
|
|
161
154
|
appliance['va_provider_image_id'].split('#').last
|
162
155
|
end
|
163
156
|
|
164
|
-
def appdb_smallest_size
|
157
|
+
def appdb_smallest_size
|
165
158
|
sizes = []
|
166
|
-
[appdb_provider
|
159
|
+
templates = [appdb_provider['provider:template']].flatten.compact
|
160
|
+
|
161
|
+
templates.each do |template|
|
167
162
|
sizes << [
|
168
163
|
template['provider_template:resource_name'].split('#').last,
|
169
164
|
template['provider_template:main_memory_size'].to_i + (template['provider_template:physical_cpus'].to_i * CPU_SUM_WEIGHT)
|
170
165
|
]
|
171
166
|
end
|
172
167
|
fail "No appliance sizes available in AppDB" if sizes.blank?
|
173
|
-
sizes.sort! { |x,y| x.last <=> y.last }
|
174
168
|
|
169
|
+
sizes.sort! { |x,y| x.last <=> y.last }
|
175
170
|
sizes.first.first
|
176
171
|
end
|
177
172
|
|
178
|
-
def appdb_provider
|
179
|
-
return @
|
173
|
+
def appdb_provider
|
174
|
+
return @_provider if @_provider
|
180
175
|
|
181
176
|
parsed_response = cache_fetch('appdb-sites', options[:cache_expiration]) do
|
182
177
|
response = HTTParty.post(APPDB_PROXY_URL, { :body => APPDB_REQUEST_FORM })
|
183
178
|
fail "Could not get appliance "\
|
184
179
|
"details from AppDB [#{response.code}]" unless response.success?
|
180
|
+
fail "Response from AppDB has unexpected structure" unless valid_response?(response.parsed_response)
|
181
|
+
|
185
182
|
response.parsed_response
|
186
183
|
end
|
187
184
|
|
188
|
-
|
189
|
-
|
185
|
+
providers = parsed_response['appdb:broker']['appdb:reply']['appdb:appdb']['virtualization:provider']
|
186
|
+
providers.delete_if { |prov| prov['provider:endpoint_url'].blank? }
|
187
|
+
|
188
|
+
@_provider = providers.select do |prov|
|
189
|
+
prov['provider:endpoint_url'].chomp('/') == options[:endpoint].chomp('/')
|
190
190
|
end.first
|
191
|
-
fail "Could not locate site by endpoint #{options[:endpoint].inspect} in AppDB" unless @
|
191
|
+
fail "Could not locate site by endpoint #{options[:endpoint].inspect} in AppDB" unless @_provider
|
192
192
|
|
193
|
-
@
|
193
|
+
@_provider
|
194
194
|
end
|
195
195
|
|
196
196
|
def normalize_mpuri(mpuri)
|
197
197
|
mpuri.gsub(/\/+$/, '').gsub(/:\d+$/, '')
|
198
198
|
end
|
199
199
|
|
200
|
+
def valid_response?(response)
|
201
|
+
response['appdb:broker'] \
|
202
|
+
&& response['appdb:broker']['appdb:reply'] \
|
203
|
+
&& response['appdb:broker']['appdb:reply']['appdb:appdb'] \
|
204
|
+
&& response['appdb:broker']['appdb:reply']['appdb:appdb']['virtualization:provider']
|
205
|
+
end
|
206
|
+
|
200
207
|
include Nagios::Promoo::Utils::Cache
|
201
208
|
end
|