Class: OpennebulaOcciProbe
Overview
OpennebulaOcciProbe - OCCI client query service implementation.
Constant Summary
OpennebulaProbe::CRIT_MSG, OpennebulaProbe::OK_MSG, OpennebulaProbe::UNKWN_MSG, OpennebulaProbe::WARN_MSG
Instance Attribute Summary
#logger, #message, #retval
Instance Method Summary
collapse
#crit?, #run, #warn?
Constructor Details
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/probe/opennebula_occi_probe.rb', line 22
def initialize(opts)
super(opts)
if @opts.user_cred
creds = {
type: 'x509',
user_cert: @opts.user_cred,
user_cert_password: @opts.password,
ca_path: @opts.ca_path,
ca_file: @opts.ca_file,
voms: @opts.voms
}
else
creds = {
username: @opts.username,
password: @opts.password,
type: 'basic'
}
end
@client = OcciClient.new(
endpoint: @endpoint,
auth: creds,
occi: @opts.service,
template: @opts.template_uuid,
vmname: @opts.vmname,
timeout: @opts.timeout
)
end
|
Instance Method Details
#check_crit ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/probe/opennebula_occi_probe.rb', line 52
def check_crit
@logger.info "Checking for basic connectivity at #{@endpoint}"
begin
@client.network.all
@client.compute.all unless @opts.service == 'rocci'
@client.storage.all
rescue StandardError => e
@logger.error "Failed to check connectivity: #{e}"
@logger.debug "#{e.backtrace.join("\n")}"
return true
end
false
end
|
#check_resources(resources) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/probe/opennebula_occi_probe.rb', line 70
def check_resources(resources)
if resources.map { |x| x[:resource] }.reduce(true) { |product, resource| product && resource.nil? }
@logger.info 'There are no resources to check, for details on how to specify resources see --help'
return false
end
resources.each do |resource_hash|
resource = resource_hash[:resource]
next unless resource
begin
@logger.info "Looking for #{resource_hash[:resource_string]}s: #{resource.inspect}"
result = resource.map { |id| resource_hash[:resource_connection].find id }
@logger.debug result
end
end
false
end
|
#check_warn ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/probe/opennebula_occi_probe.rb', line 91
def check_warn
@logger.info "Checking for resource availability at #{@endpoint}"
resources = []
unless @opts.service == 'rocci'
resources << { resource: @opts.storage,
resource_string: 'image',
resource_connection: @client.storage
}
end
resources << { resource: @opts.compute,
resource_string: 'compute instance',
resource_connection: @client.compute
}
resources << { resource: @opts.network,
resource_string: 'network',
resource_connection: @client.network
}
if !@opts.template_uuid.nil?
@client.compute.create_check_destroy
else
check_resources(resources)
end
false
rescue StandardError => e
@logger.error "Failed to check resource availability: #{e.message}"
@logger.debug "#{e.backtrace.join("\n")}"
return true
end
|