snmpjr 0.3.0-java → 0.3.1-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 +2 -0
- data/lib/snmpjr/getter.rb +3 -2
- data/lib/snmpjr/pdu_v2c.rb +10 -7
- data/lib/snmpjr/pdu_v3.rb +9 -2
- data/snmpjr.gemspec +1 -1
- data/spec/snmpjr/getter_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTFjOWFjNzJhNTEwY2I0MjE0Njg3ODMwNzk0OGY2YWUyOGFkYzJhOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjA1NzRhZTA5MTI0MWM3NWVjZWFkZDQ0YmFlODM4NTcwOTdmZTJlNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yzc3ZmJiNWM2NGViNTE1ZTgzZGMzNmFmNjA3MWNlNmZhM2Y3ZGI0YzVjNTc5
|
10
|
+
MmJlZWI3YTVkYjkwZmE1MTFhNmM3Y2UzNWJkMDEwZjRjY2M1MTU2NGQxZjFk
|
11
|
+
ZWUzMDhlNWQ1NTEzOGI0YmRmMzdmZTcxNWEzMDI0NTY2YzA1YzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2YwNmFjMDJjMWEzZDJmNjEwMzlhMDA3YzYxNjRkYzJlZWU1NDBiYzhjZDQ5
|
14
|
+
ZWY2ZGViODdhZmFhNmJiMDMxODRkMTBkMGJhNTU3N2IyY2RlNjdkNWYxYmYy
|
15
|
+
NjQ2OTY2MjJiYWM0YzRiZmEyOTJlY2M4OTFkZTAwNDkyYTNlNmQ=
|
data/.semver
CHANGED
data/history.rdoc
CHANGED
data/lib/snmpjr/getter.rb
CHANGED
@@ -9,11 +9,12 @@ class Snmpjr
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def get oids
|
12
|
+
#TODO: Change it to be a session do end block
|
12
13
|
@session.start
|
13
14
|
begin
|
14
|
-
results = oids.each_slice(@max_oids_per_request).
|
15
|
+
results = oids.each_slice(@max_oids_per_request).flat_map{|partial_oids|
|
15
16
|
get_request partial_oids
|
16
|
-
}
|
17
|
+
}
|
17
18
|
ensure
|
18
19
|
@session.close
|
19
20
|
end
|
data/lib/snmpjr/pdu_v2c.rb
CHANGED
@@ -7,18 +7,21 @@ class Snmpjr
|
|
7
7
|
GET = -96
|
8
8
|
end
|
9
9
|
|
10
|
-
def initialize
|
11
|
-
@pdu = Snmpjr::Wrappers::PDU.new
|
12
|
-
end
|
13
|
-
|
14
10
|
def create oids
|
11
|
+
pdu = create_new_pdu
|
15
12
|
oids.map {|oid|
|
16
13
|
oid = Snmpjr::Wrappers::SMI::OID.new oid
|
17
14
|
variable_binding = Snmpjr::Wrappers::SMI::VariableBinding.new oid
|
18
|
-
|
15
|
+
pdu.add variable_binding
|
19
16
|
}
|
20
|
-
|
21
|
-
|
17
|
+
pdu.type = Snmpjr::PduV2C::Constants::GET
|
18
|
+
pdu
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def create_new_pdu
|
24
|
+
Snmpjr::Wrappers::PDU.new
|
22
25
|
end
|
23
26
|
|
24
27
|
end
|
data/lib/snmpjr/pdu_v3.rb
CHANGED
@@ -6,8 +6,15 @@ class Snmpjr
|
|
6
6
|
class PduV3 < Snmpjr::PduV2C
|
7
7
|
|
8
8
|
def initialize context = ''
|
9
|
-
@
|
10
|
-
|
9
|
+
@context_name = Snmpjr::Wrappers::SMI::OctetString.new(context)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def create_new_pdu
|
15
|
+
pdu = Snmpjr::Wrappers::ScopedPDU.new
|
16
|
+
pdu.context_name = @context_name
|
17
|
+
pdu
|
11
18
|
end
|
12
19
|
|
13
20
|
end
|
data/snmpjr.gemspec
CHANGED
data/spec/snmpjr/getter_spec.rb
CHANGED
@@ -48,6 +48,21 @@ describe Snmpjr::Getter do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
context 'when there is an uneven split of slices' do
|
52
|
+
before do
|
53
|
+
configuration.max_oids_per_request = 2
|
54
|
+
allow(pdu).to receive(:create).with(['1.2.3.4.5.6', '2.3.4.5.6.7']).and_return created_pdu_multiple_1
|
55
|
+
allow(pdu).to receive(:create).with(['6.5.4.3.2.1']).and_return created_pdu_multiple_2
|
56
|
+
allow(session).to receive(:send).with(created_pdu_multiple_1, target).and_return ['Foo', 'Baz']
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should not have duplicate results' do
|
60
|
+
expect(subject.get ['1.2.3.4.5.6', '2.3.4.5.6.7', '6.5.4.3.2.1']).to eq(['Foo', 'Baz', 'Bar'])
|
61
|
+
expect(session).to have_received(:send).with(created_pdu_multiple_1, target)
|
62
|
+
expect(session).to have_received(:send).with(created_pdu_multiple_2, target)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
51
66
|
it 'starts an snmp session' do
|
52
67
|
subject.get ['1.2.3.4.5.6', '6.5.4.3.2.1']
|
53
68
|
expect(session).to have_received(:start)
|
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.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Zen Kyprianou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-n-bake
|