5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/zabbirc/zabbix/resource/finders.rb', line 5
def find id, *options
options = options.
options = options.reverse_merge({
:"#{id_attr_name}s" => id
})
res = api.send(model_name).get options
ret = if res.size == 0
nil
elsif res.size > 1
raise IDNotUniqueError, "#{model_name.camelize} ID `#{id}` is not unique"
else
self.new res.first
end
rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError, OpenSSL::SSL::SSLError => e
Zabbirc.logger.error "Zabbix::Resource#find: #{e}"
raise NotConnected, e
else
Connection.up!
ret
end
|