snmpjr 0.3.1-java → 0.3.2-java
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 +8 -8
- data/.semver +1 -1
- data/history.rdoc +4 -0
- data/lib/snmpjr/session_v2c.rb +6 -2
- data/snmpjr.gemspec +1 -1
- data/spec/integration/snmp_v2c/snmpjr_get_spec.rb +2 -1
- data/spec/snmpjr/session_v2c_spec.rb +9 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2Q0Njg3ZDA2MTZhNDliMzUwZjgyOTAxZjdhZjkyYzM3MjQ3MTdmOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzVkNDJmYWQzMDNiMmFmNGUwZTRjYjE1ZGZiZTdjYTQwZWM4MDYzNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTc0NDVlNDJiMTY3ZTcwMzhjNjkwNjk3YzhhZDBmOTgzZjVmMDU4M2RkMDlj
|
10
|
+
OWU5OTY1MGEwMDk3YTJiYjRiM2UzMzI1ZTlmZDRlNGYwMDZhMWVjMTljNzIx
|
11
|
+
MTkzNDQwOTU5ODE3ZjIzNjQxYjQ3MThkNzkxNWViZWM3Njg2ZWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YThiNGQ0MDUxMGRkYWZjOTk4ZmRiM2I4MWFiNWY1YzFlNmZjOGQ1MjE2NDVj
|
14
|
+
MTMxMjRkNzMyZmZhZjUwY2FlN2IzMjYyNjA2NmJmZmY3ODE4Y2JlZjM4ZDJj
|
15
|
+
M2IwYzZhOTIyMDk0ZmRlMmI2NjQ2NWE2ODZmYThhNTE2ZDYzMDQ=
|
data/.semver
CHANGED
data/history.rdoc
CHANGED
data/lib/snmpjr/session_v2c.rb
CHANGED
@@ -17,10 +17,10 @@ class Snmpjr
|
|
17
17
|
begin
|
18
18
|
result = @snmp.send(pdu, target)
|
19
19
|
rescue Exception => error
|
20
|
-
raise RuntimeError.new(error)
|
20
|
+
raise RuntimeError.new("#{error.inspect}: #{error_information pdu, target}")
|
21
21
|
end
|
22
22
|
if result.response.nil?
|
23
|
-
raise Snmpjr::TargetTimeoutError.new(
|
23
|
+
raise Snmpjr::TargetTimeoutError.new("Request timed out: #{error_information pdu, target}")
|
24
24
|
else
|
25
25
|
result.response.variable_bindings.map{|vb|
|
26
26
|
construct_response(vb)
|
@@ -28,6 +28,10 @@ class Snmpjr
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def error_information pdu, target
|
32
|
+
"#{target.address}, OIDs: #{pdu.to_array.map {|binding| binding.oid.to_s }.inspect}"
|
33
|
+
end
|
34
|
+
|
31
35
|
def close
|
32
36
|
@snmp.close
|
33
37
|
end
|
data/snmpjr.gemspec
CHANGED
@@ -46,9 +46,10 @@ describe "snmpjr for snmp v2c" do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'the request times out after 5 seconds' do
|
49
|
+
host_ip = IPSocket.getaddress('demo.snmplabs.com')
|
49
50
|
expect{
|
50
51
|
subject.get '1.3.6.1.2.1.1.1.0'
|
51
|
-
}.to raise_error(Snmpjr::TargetTimeoutError)
|
52
|
+
}.to raise_error(Snmpjr::TargetTimeoutError, %{Request timed out: #{host_ip}/161, OIDs: ["1.3.6.1.2.1.1.1.0"]})
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -31,16 +31,17 @@ describe Snmpjr::SessionV2C do
|
|
31
31
|
let(:vb2) { double :vb2 }
|
32
32
|
let(:results) { [vb1, vb2] }
|
33
33
|
let(:response) { double :response }
|
34
|
-
let(:pdu) { double :pdu }
|
35
|
-
let(:
|
34
|
+
let(:pdu) { double :pdu, to_array: [vb1, vb2] }
|
35
|
+
let(:address) { double :address, to_s: "1.2.3.4/567" }
|
36
|
+
let(:target) { double :target, address: address }
|
36
37
|
|
37
38
|
before do
|
38
39
|
allow(snmp_session).to receive(:send).and_return response
|
39
40
|
allow(vb1).to receive_message_chain('variable.to_s')
|
40
|
-
allow(vb1).to receive_message_chain('oid.to_s')
|
41
|
+
allow(vb1).to receive_message_chain('oid.to_s') { "1.2.3" }
|
41
42
|
allow(vb1).to receive(:is_exception)
|
42
43
|
allow(vb2).to receive_message_chain('variable.to_s')
|
43
|
-
allow(vb2).to receive_message_chain('oid.to_s')
|
44
|
+
allow(vb2).to receive_message_chain('oid.to_s') { "4.5.6" }
|
44
45
|
allow(vb2).to receive(:is_exception)
|
45
46
|
allow(response).to receive_message_chain('response.variable_bindings').and_return(results)
|
46
47
|
end
|
@@ -58,19 +59,20 @@ describe Snmpjr::SessionV2C do
|
|
58
59
|
it 'raises a timeout error' do
|
59
60
|
expect {
|
60
61
|
subject.send(pdu, target)
|
61
|
-
}.to raise_error(Snmpjr::TargetTimeoutError)
|
62
|
+
}.to raise_error(Snmpjr::TargetTimeoutError, 'Request timed out: 1.2.3.4/567, OIDs: ["1.2.3", "4.5.6"]')
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
context 'an exception is raised' do
|
67
|
+
let(:exception) { Exception.new "An error" }
|
66
68
|
before do
|
67
|
-
allow(snmp_session).to receive(:send).and_raise(
|
69
|
+
allow(snmp_session).to receive(:send).and_raise(exception)
|
68
70
|
end
|
69
71
|
|
70
72
|
it 'catches it and raises a ruby runtime error' do
|
71
73
|
expect{
|
72
74
|
subject.send(pdu, target)
|
73
|
-
}.to raise_error(RuntimeError)
|
75
|
+
}.to raise_error(RuntimeError, %{#{exception.inspect}: 1.2.3.4/567, OIDs: ["1.2.3", "4.5.6"]})
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snmpjr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Zen Kyprianou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-n-bake
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.4.
|
217
|
+
rubygems_version: 2.4.5
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Simple SNMP interface for JRuby
|