sloe 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
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
- All options supported by Netconf 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.
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
@@ -1,3 +1,3 @@
1
1
  module Sloe
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
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
- super(args)
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
- self
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
@@ -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.1
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-16 00:00:00.000000000 Z
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/sloe_spec.rb
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/sloe_spec.rb
492
+ - spec/blocks_spec.rb
493
+ - spec/methods_spec.rb
492
494
  has_rdoc: