netconf 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/examples/confd/get-running.rb +27 -27
- data/examples/jnpr/edit-config-jnpr-set.rb +55 -55
- data/examples/jnpr/edit-config-jnpr-text.rb +64 -64
- data/examples/jnpr/edit-config-jnpr.rb +73 -73
- data/examples/jnpr/edit-config-std.rb +64 -64
- data/examples/jnpr/edit-config-text-std.rb +68 -68
- data/examples/jnpr/get-config-jnpr.rb +62 -62
- data/examples/jnpr/get-config-matching.rb +20 -20
- data/examples/jnpr/get-config-std.rb +49 -49
- data/examples/jnpr/get-inventory-serial-explicit.rb +27 -27
- data/examples/jnpr/get-inventory-serial.rb +25 -25
- data/examples/jnpr/get-inventory-telnet.rb +14 -14
- data/examples/jnpr/get-inventory.rb +16 -16
- data/examples/jnpr/scp.rb +22 -22
- data/lib/net/netconf.rb +11 -1
- data/lib/net/netconf/exception.rb +38 -38
- data/lib/net/netconf/ioproc.rb +88 -88
- data/lib/net/netconf/jnpr.rb +9 -9
- data/lib/net/netconf/jnpr/ioproc.rb +14 -14
- data/lib/net/netconf/jnpr/rpc.rb +162 -140
- data/lib/net/netconf/jnpr/serial.rb +15 -15
- data/lib/net/netconf/jnpr/telnet.rb +23 -23
- data/lib/net/netconf/rpc.rb +71 -71
- data/lib/net/netconf/rpc_std.rb +133 -134
- data/lib/net/netconf/serial.rb +135 -135
- data/lib/net/netconf/ssh.rb +78 -77
- data/lib/net/netconf/telnet.rb +52 -52
- data/lib/net/netconf/transport.rb +28 -5
- data/lib/net/netconf/version.rb +3 -0
- metadata +21 -12
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NmUzYzM2NDEyMGJjMzE0NDljYmYzNjIxOGE0ZTE5YWNiMDg0ZDNmMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjRiMTk0ZWJkMWUyZjRkNTFlNDJhZDBhMjU1M2I5NDI5MTgwODZiMg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Njg1NzU5NDZhY2ZiYWZkMGRmYTdjOTRjZWE1OWFjNmRhMzI0NjY4MzRjMzBl
|
10
|
+
NGQ0YWVmNWI0NjA0ZDU2ODY1OWI1NjQ0ZWJiNjhjM2MyMDg2ZjJmMjE5NWIy
|
11
|
+
ZDEzZGI0NzI1ZmM2NTZkNzhhNjlhNDI0NzhmY2NmNmI1NDk4ZGU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGNhYjE4NzdmOGFlMGJjNTI4YTZkNjYyMWNlOWZmZTBjNTZiNzM1ZTkyNjIw
|
14
|
+
YjYxMTVmMmExYzBkNTJkODg3MzFiMTU3ZmZhYWM5YmRhZWNjYzc1OWY1ODY5
|
15
|
+
MWNmZjdlNTAzNDBmNWVlMTAxM2RkMTliYjQ4OWU2NDQ4Y2IwNmE=
|
@@ -1,27 +1,27 @@
|
|
1
|
-
#
|
2
|
-
# This code is used to retrieve the running configuration
|
3
|
-
# from a Tail-F "confD" NETCONF server, and display the
|
4
|
-
# configured user names
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'net/netconf'
|
8
|
-
|
9
|
-
puts "NETCONF v#{Netconf::VERSION}"
|
10
|
-
|
11
|
-
login = { :target => 'jeap', :port => 2022,
|
12
|
-
:username => "admin", :password => "admin" }
|
13
|
-
|
14
|
-
Netconf::SSH.new( login ){ |dev|
|
15
|
-
|
16
|
-
config = dev.rpc.get_config
|
17
|
-
|
18
|
-
puts "Showing users on this device ..."
|
19
|
-
|
20
|
-
config.xpath("//users/user").each{|user|
|
21
|
-
puts "Username: #{user.xpath('name').text}"
|
22
|
-
}
|
23
|
-
|
24
|
-
}
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
#
|
2
|
+
# This code is used to retrieve the running configuration
|
3
|
+
# from a Tail-F "confD" NETCONF server, and display the
|
4
|
+
# configured user names
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'net/netconf'
|
8
|
+
|
9
|
+
puts "NETCONF v#{Netconf::VERSION}"
|
10
|
+
|
11
|
+
login = { :target => 'jeap', :port => 2022,
|
12
|
+
:username => "admin", :password => "admin" }
|
13
|
+
|
14
|
+
Netconf::SSH.new( login ){ |dev|
|
15
|
+
|
16
|
+
config = dev.rpc.get_config
|
17
|
+
|
18
|
+
puts "Showing users on this device ..."
|
19
|
+
|
20
|
+
config.xpath("//users/user").each{|user|
|
21
|
+
puts "Username: #{user.xpath('name').text}"
|
22
|
+
}
|
23
|
+
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
|
@@ -1,55 +1,55 @@
|
|
1
|
-
require 'net/netconf/jnpr'
|
2
|
-
|
3
|
-
puts "NETCONF v.#{Netconf::VERSION}"
|
4
|
-
|
5
|
-
login = { :target => 'vsrx', :username => "jeremy", :password => "jeremy1" }
|
6
|
-
|
7
|
-
new_host_name = "vsrx"
|
8
|
-
|
9
|
-
puts "Connecting to device: #{login[:target]}"
|
10
|
-
|
11
|
-
Netconf::SSH.new( login ){ |dev|
|
12
|
-
puts "Connected!"
|
13
|
-
|
14
|
-
location = []
|
15
|
-
location << 'set system location building "Main Campus, C"'
|
16
|
-
location << "set system location floor 15"
|
17
|
-
location << "set system location rack 1117"
|
18
|
-
|
19
|
-
begin
|
20
|
-
|
21
|
-
rsp = dev.rpc.lock_configuration
|
22
|
-
|
23
|
-
# --------------------------------------------------------------------
|
24
|
-
# configuration as BLOCK
|
25
|
-
|
26
|
-
rsp = dev.rpc.load_configuration( :format => 'set' ) {
|
27
|
-
"set system host-name #{new_host_name}"
|
28
|
-
}
|
29
|
-
|
30
|
-
# --------------------------------------------------------------------
|
31
|
-
# configuration as PARAM
|
32
|
-
|
33
|
-
rsp = dev.rpc.load_configuration( location, :format => 'set' )
|
34
|
-
|
35
|
-
rpc = dev.rpc.check_configuration
|
36
|
-
rpc = dev.rpc.commit_configuration
|
37
|
-
rpc = dev.rpc.unlock_configuration
|
38
|
-
|
39
|
-
rescue Netconf::LockError => e
|
40
|
-
puts "Lock error"
|
41
|
-
rescue Netconf::EditError => e
|
42
|
-
puts "Edit error"
|
43
|
-
rescue Netconf::ValidateError => e
|
44
|
-
puts "Validate error"
|
45
|
-
rescue Netconf::CommitError => e
|
46
|
-
puts "Commit error"
|
47
|
-
rescue Netconf::RpcError => e
|
48
|
-
puts "General RPC error"
|
49
|
-
else
|
50
|
-
puts "Configuration Committed."
|
51
|
-
end
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
|
1
|
+
require 'net/netconf/jnpr'
|
2
|
+
|
3
|
+
puts "NETCONF v.#{Netconf::VERSION}"
|
4
|
+
|
5
|
+
login = { :target => 'vsrx', :username => "jeremy", :password => "jeremy1" }
|
6
|
+
|
7
|
+
new_host_name = "vsrx"
|
8
|
+
|
9
|
+
puts "Connecting to device: #{login[:target]}"
|
10
|
+
|
11
|
+
Netconf::SSH.new( login ){ |dev|
|
12
|
+
puts "Connected!"
|
13
|
+
|
14
|
+
location = []
|
15
|
+
location << 'set system location building "Main Campus, C"'
|
16
|
+
location << "set system location floor 15"
|
17
|
+
location << "set system location rack 1117"
|
18
|
+
|
19
|
+
begin
|
20
|
+
|
21
|
+
rsp = dev.rpc.lock_configuration
|
22
|
+
|
23
|
+
# --------------------------------------------------------------------
|
24
|
+
# configuration as BLOCK
|
25
|
+
|
26
|
+
rsp = dev.rpc.load_configuration( :format => 'set' ) {
|
27
|
+
"set system host-name #{new_host_name}"
|
28
|
+
}
|
29
|
+
|
30
|
+
# --------------------------------------------------------------------
|
31
|
+
# configuration as PARAM
|
32
|
+
|
33
|
+
rsp = dev.rpc.load_configuration( location, :format => 'set' )
|
34
|
+
|
35
|
+
rpc = dev.rpc.check_configuration
|
36
|
+
rpc = dev.rpc.commit_configuration
|
37
|
+
rpc = dev.rpc.unlock_configuration
|
38
|
+
|
39
|
+
rescue Netconf::LockError => e
|
40
|
+
puts "Lock error"
|
41
|
+
rescue Netconf::EditError => e
|
42
|
+
puts "Edit error"
|
43
|
+
rescue Netconf::ValidateError => e
|
44
|
+
puts "Validate error"
|
45
|
+
rescue Netconf::CommitError => e
|
46
|
+
puts "Commit error"
|
47
|
+
rescue Netconf::RpcError => e
|
48
|
+
puts "General RPC error"
|
49
|
+
else
|
50
|
+
puts "Configuration Committed."
|
51
|
+
end
|
52
|
+
}
|
53
|
+
|
54
|
+
|
55
|
+
|
@@ -1,64 +1,64 @@
|
|
1
|
-
require 'net/netconf/jnpr'
|
2
|
-
|
3
|
-
puts "NETCONF v.#{Netconf::VERSION}"
|
4
|
-
|
5
|
-
login = { :target => 'vsrx', :username => "jeremy", :password => "jeremy1" }
|
6
|
-
|
7
|
-
new_host_name = "vsrx-gizmo"
|
8
|
-
|
9
|
-
puts "Connecting to device: #{login[:target]}"
|
10
|
-
|
11
|
-
Netconf::SSH.new( login ){ |dev|
|
12
|
-
puts "Connected!"
|
13
|
-
|
14
|
-
location = <<EOCONF
|
15
|
-
system {
|
16
|
-
location {
|
17
|
-
building "Main Campus, E"
|
18
|
-
floor 15
|
19
|
-
rack 1117
|
20
|
-
}
|
21
|
-
}
|
22
|
-
EOCONF
|
23
|
-
|
24
|
-
begin
|
25
|
-
|
26
|
-
rsp = dev.rpc.lock_configuration
|
27
|
-
|
28
|
-
# --------------------------------------------------------------------
|
29
|
-
# configuration as BLOCK
|
30
|
-
|
31
|
-
rsp = dev.rpc.load_configuration( :format => 'text' ) {
|
32
|
-
<<-EOCONF
|
33
|
-
system {
|
34
|
-
host-name #{new_host_name}
|
35
|
-
}
|
36
|
-
EOCONF
|
37
|
-
}
|
38
|
-
|
39
|
-
# --------------------------------------------------------------------
|
40
|
-
# configuration as PARAM
|
41
|
-
|
42
|
-
rsp = dev.rpc.load_configuration( location, :format => 'text' )
|
43
|
-
|
44
|
-
rpc = dev.rpc.check_configuration
|
45
|
-
rpc = dev.rpc.commit_configuration
|
46
|
-
rpc = dev.rpc.unlock_configuration
|
47
|
-
|
48
|
-
rescue Netconf::LockError => e
|
49
|
-
puts "Lock error"
|
50
|
-
rescue Netconf::EditError => e
|
51
|
-
puts "Edit error"
|
52
|
-
rescue Netconf::ValidateError => e
|
53
|
-
puts "Validate error"
|
54
|
-
rescue Netconf::CommitError => e
|
55
|
-
puts "Commit error"
|
56
|
-
rescue Netconf::RpcError => e
|
57
|
-
puts "General RPC error"
|
58
|
-
else
|
59
|
-
puts "Configuration Committed."
|
60
|
-
end
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
1
|
+
require 'net/netconf/jnpr'
|
2
|
+
|
3
|
+
puts "NETCONF v.#{Netconf::VERSION}"
|
4
|
+
|
5
|
+
login = { :target => 'vsrx', :username => "jeremy", :password => "jeremy1" }
|
6
|
+
|
7
|
+
new_host_name = "vsrx-gizmo"
|
8
|
+
|
9
|
+
puts "Connecting to device: #{login[:target]}"
|
10
|
+
|
11
|
+
Netconf::SSH.new( login ){ |dev|
|
12
|
+
puts "Connected!"
|
13
|
+
|
14
|
+
location = <<EOCONF
|
15
|
+
system {
|
16
|
+
location {
|
17
|
+
building "Main Campus, E"
|
18
|
+
floor 15
|
19
|
+
rack 1117
|
20
|
+
}
|
21
|
+
}
|
22
|
+
EOCONF
|
23
|
+
|
24
|
+
begin
|
25
|
+
|
26
|
+
rsp = dev.rpc.lock_configuration
|
27
|
+
|
28
|
+
# --------------------------------------------------------------------
|
29
|
+
# configuration as BLOCK
|
30
|
+
|
31
|
+
rsp = dev.rpc.load_configuration( :format => 'text' ) {
|
32
|
+
<<-EOCONF
|
33
|
+
system {
|
34
|
+
host-name #{new_host_name}
|
35
|
+
}
|
36
|
+
EOCONF
|
37
|
+
}
|
38
|
+
|
39
|
+
# --------------------------------------------------------------------
|
40
|
+
# configuration as PARAM
|
41
|
+
|
42
|
+
rsp = dev.rpc.load_configuration( location, :format => 'text' )
|
43
|
+
|
44
|
+
rpc = dev.rpc.check_configuration
|
45
|
+
rpc = dev.rpc.commit_configuration
|
46
|
+
rpc = dev.rpc.unlock_configuration
|
47
|
+
|
48
|
+
rescue Netconf::LockError => e
|
49
|
+
puts "Lock error"
|
50
|
+
rescue Netconf::EditError => e
|
51
|
+
puts "Edit error"
|
52
|
+
rescue Netconf::ValidateError => e
|
53
|
+
puts "Validate error"
|
54
|
+
rescue Netconf::CommitError => e
|
55
|
+
puts "Commit error"
|
56
|
+
rescue Netconf::RpcError => e
|
57
|
+
puts "General RPC error"
|
58
|
+
else
|
59
|
+
puts "Configuration Committed."
|
60
|
+
end
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
@@ -1,73 +1,73 @@
|
|
1
|
-
require 'net/netconf/jnpr'
|
2
|
-
|
3
|
-
puts "NETCONF v#{Netconf::VERSION}"
|
4
|
-
|
5
|
-
login = { :target => 'ex4', :username => "jeremy", :password => "jeremy1" }
|
6
|
-
|
7
|
-
new_host_name = "ex4-abc"
|
8
|
-
|
9
|
-
puts "Connecting to device: #{login[:target]}"
|
10
|
-
|
11
|
-
Netconf::SSH.new( login ){ |dev|
|
12
|
-
puts "Connected!"
|
13
|
-
|
14
|
-
# when providing a collection of configuration,
|
15
|
-
# you need to include the <configuration> as the
|
16
|
-
# toplevel element
|
17
|
-
|
18
|
-
location = Nokogiri::XML::Builder.new{ |x|
|
19
|
-
x.configuration {
|
20
|
-
x.system {
|
21
|
-
x.location {
|
22
|
-
x.building "Main Campus, D"
|
23
|
-
x.floor 22
|
24
|
-
x.rack 38
|
25
|
-
}
|
26
|
-
}
|
27
|
-
x.system {
|
28
|
-
x.services {
|
29
|
-
x.ftp;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
begin
|
36
|
-
|
37
|
-
rsp = dev.rpc.lock_configuration
|
38
|
-
|
39
|
-
# --------------------------------------------------------------------
|
40
|
-
# configuration as PARAM
|
41
|
-
|
42
|
-
rsp = dev.rpc.load_configuration( location, :action => 'replace' )
|
43
|
-
|
44
|
-
# --------------------------------------------------------------------
|
45
|
-
# configuration as BLOCK
|
46
|
-
|
47
|
-
rsp = dev.rpc.load_configuration{ |x|
|
48
|
-
x.system {
|
49
|
-
x.send(:'host-name', new_host_name )
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
rpc = dev.rpc.check_configuration
|
54
|
-
rpc = dev.rpc.commit_configuration
|
55
|
-
rpc = dev.rpc.unlock_configuration
|
56
|
-
|
57
|
-
rescue Netconf::LockError => e
|
58
|
-
puts "Lock error"
|
59
|
-
rescue Netconf::EditError => e
|
60
|
-
puts "Edit error"
|
61
|
-
rescue Netconf::ValidateError => e
|
62
|
-
puts "Validate error"
|
63
|
-
rescue Netconf::CommitError => e
|
64
|
-
puts "Commit error"
|
65
|
-
rescue Netconf::RpcError => e
|
66
|
-
puts "General RPC error"
|
67
|
-
else
|
68
|
-
puts "Configuration Committed."
|
69
|
-
end
|
70
|
-
}
|
71
|
-
|
72
|
-
|
73
|
-
|
1
|
+
require 'net/netconf/jnpr'
|
2
|
+
|
3
|
+
puts "NETCONF v#{Netconf::VERSION}"
|
4
|
+
|
5
|
+
login = { :target => 'ex4', :username => "jeremy", :password => "jeremy1" }
|
6
|
+
|
7
|
+
new_host_name = "ex4-abc"
|
8
|
+
|
9
|
+
puts "Connecting to device: #{login[:target]}"
|
10
|
+
|
11
|
+
Netconf::SSH.new( login ){ |dev|
|
12
|
+
puts "Connected!"
|
13
|
+
|
14
|
+
# when providing a collection of configuration,
|
15
|
+
# you need to include the <configuration> as the
|
16
|
+
# toplevel element
|
17
|
+
|
18
|
+
location = Nokogiri::XML::Builder.new{ |x|
|
19
|
+
x.configuration {
|
20
|
+
x.system {
|
21
|
+
x.location {
|
22
|
+
x.building "Main Campus, D"
|
23
|
+
x.floor 22
|
24
|
+
x.rack 38
|
25
|
+
}
|
26
|
+
}
|
27
|
+
x.system {
|
28
|
+
x.services {
|
29
|
+
x.ftp;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
begin
|
36
|
+
|
37
|
+
rsp = dev.rpc.lock_configuration
|
38
|
+
|
39
|
+
# --------------------------------------------------------------------
|
40
|
+
# configuration as PARAM
|
41
|
+
|
42
|
+
rsp = dev.rpc.load_configuration( location, :action => 'replace' )
|
43
|
+
|
44
|
+
# --------------------------------------------------------------------
|
45
|
+
# configuration as BLOCK
|
46
|
+
|
47
|
+
rsp = dev.rpc.load_configuration{ |x|
|
48
|
+
x.system {
|
49
|
+
x.send(:'host-name', new_host_name )
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
rpc = dev.rpc.check_configuration
|
54
|
+
rpc = dev.rpc.commit_configuration
|
55
|
+
rpc = dev.rpc.unlock_configuration
|
56
|
+
|
57
|
+
rescue Netconf::LockError => e
|
58
|
+
puts "Lock error"
|
59
|
+
rescue Netconf::EditError => e
|
60
|
+
puts "Edit error"
|
61
|
+
rescue Netconf::ValidateError => e
|
62
|
+
puts "Validate error"
|
63
|
+
rescue Netconf::CommitError => e
|
64
|
+
puts "Commit error"
|
65
|
+
rescue Netconf::RpcError => e
|
66
|
+
puts "General RPC error"
|
67
|
+
else
|
68
|
+
puts "Configuration Committed."
|
69
|
+
end
|
70
|
+
}
|
71
|
+
|
72
|
+
|
73
|
+
|