sloe 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -4
- data/lib/sloe/junos.rb +4 -12
- data/lib/sloe/version.rb +1 -1
- data/spec/methods_spec.rb +10 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
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 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:
|
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
|
|
@@ -54,16 +54,30 @@ An alternate way to use this module is:
|
|
54
54
|
puts device.snmp.get_value('sysDescr.0')
|
55
55
|
|
56
56
|
|
57
|
-
All options supported by Netconf, Net::SCP and SNMP are supported in this gem too. The
|
57
|
+
All options supported by Netconf, Net::SCP and SNMP are supported in this gem too. The `:target` Netconf::SSH option is aliased to the SNMP `:host` option so there is no need to duplicate that option key.
|
58
58
|
|
59
59
|
## Vendor specific Netconf extensions
|
60
60
|
|
61
|
-
Sloe supports vendor specific Netconf extensions. To add that vendor specific support call new() on one of the supported classes. Sloe supports the following:
|
61
|
+
Sloe supports vendor specific Netconf extensions. To add that vendor specific support call `new()` on one of the supported classes. Sloe supports the following:
|
62
62
|
|
63
63
|
*Sloe::Device - no vendor specific Netconf extensions added
|
64
64
|
*Sloe::Junos - Junos vendor specific Netconf extensions added
|
65
65
|
|
66
|
-
Just simply call Sloe::Junos.new() to get the Junos extensions added
|
66
|
+
Just simply call `Sloe::Junos.new()` to get the Junos extensions added
|
67
|
+
|
68
|
+
### Junos specific extension
|
69
|
+
|
70
|
+
For Junos specific Netconf extensions please refer to the [Juniper webiste](http://www.juniper.net/techpubs/en_US/junos12.3/information-products/topic-collections/netconf-guide/index.html)
|
71
|
+
|
72
|
+
As well as supporting Junos specific Netconf RPCs Sloe::Junos also supports the `cli()` method. This method allows you to execute CLI commands on the Juniper device. For example
|
73
|
+
|
74
|
+
device.cli("show version")
|
75
|
+
device.cli("show ospf interfaces")
|
76
|
+
|
77
|
+
By default this call will respond with an XML result tree fragment, a Nokogiri::XML object. To get what you would see on the CLI modify the `cli()` call with the `:format => 'text'` attribute and chain the Nokogiri `text()` method. Here is an example that will return just the output from "show version"
|
78
|
+
|
79
|
+
device.cli("show version", :format => 'text').text
|
80
|
+
|
67
81
|
|
68
82
|
## SUPPORT
|
69
83
|
|
data/lib/sloe/junos.rb
CHANGED
@@ -4,20 +4,12 @@ require 'sloe/common'
|
|
4
4
|
module Sloe
|
5
5
|
class Junos < Sloe::Common
|
6
6
|
|
7
|
-
# attr_reader :snmp
|
8
|
-
|
9
7
|
def initialize(args, &block)
|
10
|
-
# @snmp_args = {:host => args[:target], :mib_dir => args[:mib_dir], :mib_modules => args[:mib_modules]}
|
11
|
-
# @snmp = SNMP::Manager.new(@snmp_args)
|
12
|
-
|
13
|
-
# if block_given?
|
14
8
|
super( args, &block )
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# self
|
20
|
-
# end
|
9
|
+
end
|
10
|
+
|
11
|
+
def cli(cmd_str, attrs = nil)
|
12
|
+
self.rpc.command(cmd_str, attrs)
|
21
13
|
end
|
22
14
|
end
|
23
15
|
end
|
data/lib/sloe/version.rb
CHANGED
data/spec/methods_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe Sloe do
|
|
13
13
|
:mib_modules => ["SNMPv2-SMI", "SNMPv2-MIB", "IF-MIB", "IP-MIB", "TCP-MIB", "UDP-MIB"].concat(@jnx_mibs)
|
14
14
|
}
|
15
15
|
|
16
|
-
@dut = Sloe::
|
16
|
+
@dut = Sloe::Junos.new(@args)
|
17
17
|
end
|
18
18
|
|
19
19
|
context "SNMP API" do
|
@@ -64,4 +64,13 @@ describe Sloe do
|
|
64
64
|
File.delete('/var/tmp/test')
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
context "CLI API" do
|
69
|
+
it "cli.('show version') functions without error" do
|
70
|
+
lambda { @dut.cli("show version") }.should_not raise_error
|
71
|
+
end
|
72
|
+
it "cli.('show version') contains OS information" do
|
73
|
+
@dut.cli("show version").text.should =~ /JUNOS Base OS/
|
74
|
+
end
|
75
|
+
end
|
67
76
|
end
|