sloe 0.3.1 → 0.3.2
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.
- data/README.md +20 -6
- data/lib/sloe/version.rb +1 -1
- data/lib/sloe.rb +11 -7
- data/spec/blocks_spec.rb +30 -0
- data/spec/{sloe_spec.rb → methods_spec.rb} +0 -0
- metadata +6 -4
data/README.md
CHANGED
@@ -18,19 +18,16 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
This gem augments the functionality of Netconf::SSH and SNMP gems. Please refer to those gem's documentation or detailed instruction on how to use this gem.
|
21
|
+
This gem augments the functionality of Netconf::SSH, Net::SCP and SNMP gems. Please refer to those gem's documentation or detailed instruction on how to use this gem.
|
22
22
|
|
23
|
-
All SNMP methods are accessed via the snmp() method.
|
23
|
+
All Netconf methods are accessed via the rpc() method. All Net::SCP methods are access via the scp() method. All SNMP methods are accessed via the snmp() method. For example:
|
24
24
|
|
25
25
|
require 'sloe'
|
26
26
|
|
27
27
|
# create options hash
|
28
|
-
|
29
28
|
options = {:target => 'remotehost', :username => 'foo', :password => 'bar'}
|
30
29
|
|
31
30
|
Sloe::Device.new(options) { |device|
|
32
|
-
# establish connection to device
|
33
|
-
device.open
|
34
31
|
|
35
32
|
# call a Netconf RPC and display some of output
|
36
33
|
inventory = device.rpc.get_chassis_inventory
|
@@ -40,7 +37,24 @@ All SNMP methods are accessed via the snmp() method.
|
|
40
37
|
puts device.snmp.get_value('sysDescr.0')
|
41
38
|
}
|
42
39
|
|
43
|
-
|
40
|
+
An alternate way to use this module is:
|
41
|
+
|
42
|
+
require 'sloe'
|
43
|
+
|
44
|
+
# create options hash
|
45
|
+
options = {:target => 'remotehost', :username => 'foo', :password => 'bar'}
|
46
|
+
|
47
|
+
device = Sloe::Device.new(options)
|
48
|
+
|
49
|
+
# call a Netconf RPC and display some of output
|
50
|
+
inventory = device.rpc.get_chassis_inventory
|
51
|
+
puts "Chassis: " + inventory.xpath('chassis/description').text
|
52
|
+
|
53
|
+
# display SNMP data
|
54
|
+
puts device.snmp.get_value('sysDescr.0')
|
55
|
+
|
56
|
+
|
57
|
+
All options supported by Netconf, Net::SCP and SNMP are supported in this gem too. The :target option is aliased to the SNMP :host option so there is no need to duplicate that option key.
|
44
58
|
|
45
59
|
## SUPPORT
|
46
60
|
|
data/lib/sloe/version.rb
CHANGED
data/lib/sloe.rb
CHANGED
@@ -9,14 +9,18 @@ module Sloe
|
|
9
9
|
|
10
10
|
attr_reader :snmp
|
11
11
|
|
12
|
-
def initialize(args)
|
13
|
-
|
14
|
-
self.open
|
15
|
-
|
16
|
-
@snmp_args = {:host => args[:target], :mib_dir => args[:mib_dir], :mib_modules => args[:mib_modules]}
|
12
|
+
def initialize(args, &block)
|
13
|
+
@snmp_args = {:host => args[:target], :mib_dir => args[:mib_dir], :mib_modules => args[:mib_modules]}
|
17
14
|
@snmp = SNMP::Manager.new(@snmp_args)
|
18
|
-
|
19
|
-
|
15
|
+
|
16
|
+
if block_given?
|
17
|
+
super( args, &block )
|
18
|
+
return
|
19
|
+
else
|
20
|
+
super(args)
|
21
|
+
self.open
|
22
|
+
self
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
data/spec/blocks_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'sloe'
|
2
|
+
require 'ruby-debug'
|
3
|
+
|
4
|
+
describe Sloe do
|
5
|
+
context "invoked with block" do
|
6
|
+
before(:all) do
|
7
|
+
@login = {
|
8
|
+
:target => 'capella',
|
9
|
+
:username => 'dgethings',
|
10
|
+
:password => 'mcisamilf'
|
11
|
+
}
|
12
|
+
@hostname = ''
|
13
|
+
end
|
14
|
+
|
15
|
+
it "calls Netconf RPC" do
|
16
|
+
Sloe::Device.new( @login ) { |dut|
|
17
|
+
sw_info = dut.rpc.get_system_information
|
18
|
+
@hostname = sw_info.xpath('//host-name').text
|
19
|
+
}
|
20
|
+
@hostname.should include @login[:target]
|
21
|
+
end
|
22
|
+
|
23
|
+
it "calls SNMP RPC" do
|
24
|
+
Sloe::Device.new ( @login ) { |dut|
|
25
|
+
@hostname = dut.snmp.get_value( 'sysName.0' ).to_s
|
26
|
+
}
|
27
|
+
@hostname.should include @login[:target]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sloe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01
|
12
|
+
date: 2013-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: snmp
|
@@ -460,7 +460,8 @@ files:
|
|
460
460
|
- mibs/VRRP-MIB.yaml
|
461
461
|
- mibs/WWW-MIB.yaml
|
462
462
|
- sloe.gemspec
|
463
|
-
- spec/
|
463
|
+
- spec/blocks_spec.rb
|
464
|
+
- spec/methods_spec.rb
|
464
465
|
- spec_helper.rb
|
465
466
|
homepage: https://github.com/dgjnpr/Sloe
|
466
467
|
licenses: []
|
@@ -488,5 +489,6 @@ specification_version: 3
|
|
488
489
|
summary: A one stop shop for collecting data from a network device using NETCONF or
|
489
490
|
SNMP
|
490
491
|
test_files:
|
491
|
-
- spec/
|
492
|
+
- spec/blocks_spec.rb
|
493
|
+
- spec/methods_spec.rb
|
492
494
|
has_rdoc:
|