junos-ez-stdlib 0.0.12 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELOG.md +17 -3
  2. data/README.md +10 -0
  3. data/docs/Providers/IPports.md +61 -0
  4. data/docs/Providers/L1ports.md +29 -0
  5. data/docs/Providers/L2ports.md +43 -0
  6. data/docs/Providers/StaticHosts.md +26 -0
  7. data/docs/Providers/StaticRoutes.md +37 -0
  8. data/docs/Providers/UserAuths.md +32 -0
  9. data/docs/{Users.md → Providers/Users.md} +17 -0
  10. data/docs/Providers/Vlans.md +43 -0
  11. data/docs/Providers_Resources.md +24 -0
  12. data/docs/README_FIRST.md +27 -0
  13. data/docs/Utils/Config.md +161 -0
  14. data/docs/Utils/Filesystem.md +78 -0
  15. data/docs/Utils/Routing-Engine.md +248 -0
  16. data/examples/re_upgrade.rb +1 -1
  17. data/examples/re_utils.rb +1 -0
  18. data/examples/vlans.rb +7 -1
  19. data/lib/junos-ez/ip_ports.rb +3 -1
  20. data/lib/junos-ez/ip_ports/classic.rb +49 -14
  21. data/lib/junos-ez/l1_ports.rb +51 -11
  22. data/lib/junos-ez/l2_ports.rb +1 -1
  23. data/lib/junos-ez/l2_ports/vlan.rb +176 -60
  24. data/lib/junos-ez/provider.rb +4 -1
  25. data/lib/junos-ez/system/st_hosts.rb +0 -0
  26. data/lib/junos-ez/system/st_routes.rb +0 -0
  27. data/lib/junos-ez/system/userauths.rb +0 -0
  28. data/lib/junos-ez/system/users.rb +0 -0
  29. data/lib/junos-ez/utils/config.rb +33 -2
  30. data/lib/junos-ez/utils/re.rb +22 -3
  31. data/lib/junos-ez/vlans.rb +5 -3
  32. data/lib/junos-ez/vlans/vlan.rb +6 -0
  33. metadata +14 -13
  34. data/docs/Config_Utils.md +0 -3
  35. data/docs/Filesys_Utils.md +0 -3
  36. data/docs/IPports.md +0 -3
  37. data/docs/L1ports.md +0 -3
  38. data/docs/L2ports.md +0 -3
  39. data/docs/RE_utils.md +0 -3
  40. data/docs/StaticHosts.md +0 -3
  41. data/docs/StaticRoutes.md +0 -3
  42. data/docs/Vlans.md +0 -3
  43. data/lib/junos-ez/system/user_ssh_keys.rb +0 -113
data/CHANGELOG.md CHANGED
@@ -1,19 +1,33 @@
1
1
  # 2013-April
2
2
 
3
- 0.0.10: 2013-04-29
3
+ 0.0.10: 2013-04-26
4
4
 
5
5
  Initial release of code into RubyGems. Code tested on EX and SRX-branch. Consider this code
6
6
  as "early-adopter". Comments/feedback is welcome and appreciated.
7
7
 
8
- 0.0.11: 2013-04-29
8
+ 0.0.11: 2013-04-26
9
9
 
10
10
  Updated Junos::Ez::RE::Utils
11
11
  #memory changed :procs from Hash to Array
12
12
  #users changed return from Hash to Array
13
13
 
14
- 0.0.12: 2013-04-29 (In-Progress)
14
+ 0.0.12: 2013-04-26
15
15
 
16
16
  Updated Junos::Ez::FS:Utils#ls to include :symlink information
17
17
  Adding Junos::Ez::Users::Provider for login management
18
18
  Adding Junos::Ez::UserAuths::Provider for SSH-key management
19
19
 
20
+ 0.0.14: 2013-04-28
21
+
22
+ Completed initial documentation. Still more work to be done with these files
23
+ but the "enough to get started" information is now available
24
+
25
+ 0.0.15: 2013-05-02
26
+
27
+ L2ports - added support for framework to read [edit vlans] stanza to recognize interfaces configured
28
+ there vs. under [edit interfaces]
29
+
30
+ IPports - added :acl_in and :acl_out for stateless ACL filtering. added .status method to return
31
+ runtime status information about the port
32
+
33
+ RE::Utils - misc updates, and documentation
data/README.md CHANGED
@@ -179,3 +179,13 @@ documentation on Providers/Resources, see the *docs* directory.
179
179
  # LICENSES
180
180
 
181
181
  BSD-2, See LICENSE file
182
+
183
+ # SUPPORT
184
+
185
+ Support for this software is made available exclusively through Github repo issue tracking. You are also welcome to contact the CONTRIBUTORS directly via their provided contact information.
186
+
187
+ If you find a bug, please open an issue against this repo.
188
+
189
+ If you have suggestions or ideas, please write them up and add them to the "SUGGESTION-BOX" folder of this repo (via pull request). This way we can share the ideas with the community and crowdsource for feature delivery.
190
+
191
+ Thank you!
@@ -0,0 +1,61 @@
1
+ # Junos::Ez::IPports::Provider
2
+
3
+ Manages IPv4 ports. For now, ports recognized are:
4
+
5
+ - Fast Ethernet: `fe-*`
6
+ - Gigabit Ethernet: `ge-*`
7
+ - 10 Gigabit Ethernet: `xe-*`
8
+
9
+ IPv6 ports are a different provider (comming soon...)
10
+
11
+ # USAGE
12
+
13
+ The provider *name* selector is the interface. If the *name* does not include the ".0" unit, the framework will default to this.
14
+
15
+ ```ruby
16
+ Junos::Ez::IPports::Provider( ndev, :ip_ports )
17
+
18
+ port = ndev.ip_ports["ge-0/0/8"]
19
+
20
+ puts "IPv4 port #{port.name} does not exist!" unless port.exists?
21
+ ```
22
+
23
+ # PROPERTIES
24
+
25
+ - `:admin` - [:up, :down] - administrative control of the port
26
+ - `:description` - String, description assigned at the interface unit level
27
+ - `:tag_id` - Fixnum, used if the phyiscal port is vlan-tagging (but not L2port)
28
+ - `:mtu` - Fixnum, MTU value assigned for IP packets (but not L1port MTU)
29
+ - `:address` - String in "ip/prefix" format. For example "192.168.10.12/24"
30
+ - `:acl_in` - Name of input ACL (firewall-filter)
31
+ - `:acl_out` - Name of output ACL
32
+
33
+ # METHODS
34
+
35
+ ## status
36
+
37
+ Returns a Hash of status information about the IP unit interface.
38
+ ```ruby
39
+ port = ndev.ip_ports["ge-0/0/8.0"]
40
+
41
+ # display the configuration information
42
+ pp port.to_h
43
+ ->
44
+ {"ge-0/0/8.0"=>
45
+ {:_active=>true,
46
+ :_exist=>true,
47
+ :admin=>:up,
48
+ :description=>"this is port8",
49
+ :address=>"192.168.100.1/24",
50
+ :acl_in=>"foo",
51
+ :acl_out=>"bar"}}
52
+
53
+ # display the status information
54
+ pp port.status
55
+ ->
56
+ {:l1_oper_status=>:up,
57
+ :oper_status=>:up,
58
+ :snmp_index=>522,
59
+ :packets_rx=>0,
60
+ :packets_tx=>18}
61
+ ```
@@ -0,0 +1,29 @@
1
+ # Junos::Ez::L1ports::Provider
2
+
3
+ Manages the physical properties of interfaces.
4
+
5
+ # USAGE
6
+
7
+ The provider *name* selector is the interface name.
8
+
9
+ ```ruby
10
+ Junos::Ez::L1ports::Provider( ndev, :l1_ports )
11
+
12
+ port = ndev.l1_ports["ge-0/0/12"]
13
+
14
+ port[:admin] = :down
15
+ port.write!
16
+ ```
17
+
18
+ # PROPERTIES
19
+
20
+ - `:admin` - [:up, :down] - administratively controls the port
21
+ - `:description` - String, description applied at the physical port
22
+ - `:mtu` - Fixnum, MTU value applied at the physical port
23
+ - `:speed` - Link Speed, [:auto, '10m', '100m', '1g', 10g']
24
+ - `:duplex` - Link Duplex, [:auto, :half, :full]
25
+ - `:unit_count` - **READ-ONLY** indicates the number of logical ports (units) configured
26
+
27
+ # METHODS
28
+
29
+ No additional methods at this time ...
@@ -0,0 +1,43 @@
1
+ # Junos::Ez::L2ports::Provider
2
+
3
+ Manages the ethernet switch ports. The primary function is to associate switching ports to VLANs.
4
+
5
+ Currently the association of VLANS to ports is read/write under the interfaces stanza. Junos OS also supports
6
+ the association under the VLAN resource stanza (vlans/bridge-domains).
7
+
8
+ _NOTE: this provider does not use the VLAN resource stanza at this time. Under review now. If you have an opionin on this, please let us know, thank you!_
9
+
10
+ # USAGE
11
+
12
+ The provider *name* is the interface. The framework will assume unit 0 if the name does not indicate one.
13
+
14
+ ```ruby
15
+ Junos::Ez::L2ports::Provider( ndev, l2_ports )
16
+
17
+ port = ndev.l2_ports["ge-0/0/12"]
18
+
19
+ puts "port #{port.name} is not a switch-port!" unless port.exists?
20
+ ```
21
+
22
+ # PROPERTIES
23
+
24
+ - `:description` - String description at the logical interface level
25
+ - `:untagged_vlan` - String, VLAN-name for packets without VLAN tags
26
+ - `:tagged_vlans` - Array of VLAN-names for packets with VLAN tags
27
+ - `:vlan_tagging` - [true | false] - indicates if this port accepts packets with VLAN tags
28
+
29
+ # METHODS
30
+
31
+ No additional methods at this time ...
32
+
33
+ # SUPPORTED PLATFORMS
34
+
35
+ - EX2200, EX3200, EX3300, EX4200, EX4500, EX4550, EX6100, EX8200
36
+ - SRX branch: **entire product line, but not vSRX**
37
+ - QFX3500, QFX3600
38
+
39
+ Comming soon:
40
+
41
+ - EX platforms released in 2013
42
+ - MX5, MX10, MX40, MX80, MX240, MX480, MX960
43
+
@@ -0,0 +1,26 @@
1
+ # Junos::Ez::StaticHosts::Provider
2
+
3
+ Manages locally configured host-name to IPv4 & IPv6 address mapping
4
+
5
+ # USAGE
6
+
7
+ The provider *name* is the host-name as it would have been configured under `[edit system static-host-mapping]`
8
+
9
+ ```ruby
10
+ Junos::Ez::StaticHosts::Provider( ndev, :etc_hosts )
11
+
12
+ host = ndev.etc_hosts["ex4.jeremylab.net"]
13
+ host[:ip] = "192.168.10.24"
14
+ host.write!
15
+ ```
16
+
17
+ # PROPERITES
18
+
19
+ - `:ip` - The IPv4 address
20
+ - `:ip6` - The IPv6 address
21
+
22
+ _NOTE: A host entry **can** have both IPv4 and IPv6 addresses assigned at the same time_
23
+
24
+ # METHODS
25
+
26
+ No additional methods at this time ...
@@ -0,0 +1,37 @@
1
+ # Junos::Ez::StaticRoutes::Provider
2
+
3
+ Manages static route entries.
4
+
5
+ _NOTE: for now, routing-instances are not supported, but under review for upcoming release..._
6
+
7
+ # USAGE
8
+
9
+ The provider *name* is the target-route. If you want to specify the default-route, you can either use "0.0.0.0/0" or the special name `:default`.
10
+
11
+ ```ruby
12
+ Junos::Ez::StaticRoutes::Provider( ndev, :route )
13
+
14
+ default = ndev.route[:default]
15
+
16
+ unless default.exists?
17
+ default[:gateway] = "192.168.1.1"
18
+ default.write!
19
+ end
20
+ ```
21
+
22
+ # PROPERTIES
23
+
24
+ - `:gateway` - The next-hop gateway. Could be single String or Array-of-Strings
25
+ - `:metic` - The metric assigned to this route, Fixnum
26
+ - `:action` - Configures the route action, [:reject, :discard, :receive]
27
+ - `:active` - Configures the route active, [true, false, nil]
28
+ - `:retain` - Configures the ratain/no-retain flag, [ nil, true, false ]
29
+ - `:install` - Configures the install/no-install flag, [nil, true, false ]
30
+ - `:readvertise` - Configures the readvertise/no-readvertise flag, [nil, true, false]
31
+ - `:resovlve` - Configures the resolve/no-resolve falg, [nil, true, false]
32
+
33
+ In the above "flag controls", assigning the values [true | false] configures if the flat is set or "no-" set respectively. To delete the flag from the configuration, set the property to `nil`.
34
+
35
+ # METHODS
36
+
37
+ No additional methods at this time ...
@@ -0,0 +1,32 @@
1
+ # Junos::Ez::UserAuths::Provider
2
+
3
+ Manages user account ssh-keys, RSA or DSA.
4
+
5
+ # USAGE
6
+
7
+ The provider *name* for accessing the provider is a Hash comprised of the following key/value pairs:
8
+
9
+ - `:user` - String, user-name
10
+ - `:keytype` - String, one of ['ssh-rsa', 'ssh-dsa']
11
+ - `:publickey` - String, the public key value
12
+
13
+ ```ruby
14
+
15
+ # bind :auths for managing ssh-keys directly
16
+
17
+ Junos::Ez::UserAuths::Provider( ndev, :auths )
18
+
19
+ # setup a name Hash to access this key
20
+
21
+ key_name = {}
22
+ key_name[:user] = "jeremy"
23
+ key_name[:keytype] = "ssh-rsa"
24
+ key_name[:publickey] = "ssh-rsa gibberishMagicSwingDeadCatoverHeadand_LetMeLoginFoo"
25
+
26
+ ssh_key = ndev.auths[ key_name ]
27
+
28
+ puts "Key does not exist" unless ssh_key.exists?
29
+ ```
30
+
31
+ Generally speaking, you probably won't be using this provider directly, but rather using a
32
+ `Junos::Ez::Users::Provider` resource and the `load_ssh_key!` method. This method makes use of the `Junos::Ez::UserAuths::Provider` internally.
@@ -2,6 +2,21 @@
2
2
 
3
3
  Manages the on-target configured users, located under Junos `[edit system login]` stanza.
4
4
 
5
+ # USAGE
6
+
7
+ The provider *name* selector is the user-name String.
8
+
9
+ ```ruby
10
+
11
+ # bind :users to provide access to the local login configuration
12
+
13
+ Junos::Ez::Users::Provider( ndev, :users )
14
+
15
+ user = ndev.users["jeremy"]
16
+
17
+ puts "#{user.name} does not exist!" unless user.exists?
18
+ ```
19
+
5
20
  # PROPERTIES
6
21
 
7
22
  - `:class` - String, The user priviledge class (like "read-only", or "super-user")
@@ -12,6 +27,8 @@ Manages the on-target configured users, located under Junos `[edit system login]
12
27
 
13
28
  If you need to modify the user's ssh-keys, see the `load_ssh_key!` method in the next section.
14
29
 
30
+
31
+
15
32
  # RESOURCE METHODS
16
33
 
17
34
  ## password=
@@ -0,0 +1,43 @@
1
+ # Junos::Ez::Vlans::Provider
2
+
3
+ Manages Ethernet VLANs.
4
+
5
+ If you are looking for associating ethernet-ports to VLANs, please refer to the `Junos::Ez::L2ports::Provider` documentation.
6
+
7
+ # USAGE
8
+
9
+ The provider *name* selector is the vlan-name, String.
10
+
11
+ ```ruby
12
+ Junos::Ez::Vlans::Provider( ndev, :vlans )
13
+
14
+ vlan = ndev.vlans["Blue"]
15
+
16
+ puts "VLAN: #{vlan.name} does not exists!" unless vlan.exists?
17
+ ```
18
+
19
+ # PROPERTIES
20
+
21
+ - `:vlan_id` - The VLAN tag-id, Fixnum [ 1 .. 4094]
22
+ - `:description` - String description for this VLAN
23
+ - `:no_mac_learning` - If `true` this VLAN will not learn MAC addresses
24
+
25
+ # RESOURCE METHODS
26
+
27
+ ## interfaces
28
+
29
+ This method will return a Hash structure of interfaces bound to this VLAN.
30
+ ```ruby
31
+ ndev.vlans["Green"].interfaces
32
+ ->
33
+ {"ge-0/0/22"=>{:mode=>:trunk},
34
+ "ge-0/0/0"=>{:mode=>:trunk, :native=>true},
35
+ "ge-0/0/1"=>{:mode=>:trunk, :native=>true},
36
+ "ge-0/0/2"=>{:mode=>:trunk, :native=>true},
37
+ "ge-0/0/3"=>{:mode=>:trunk, :native=>true},
38
+ "ge-0/0/5"=>{:mode=>:trunk, :native=>true},
39
+ "ge-0/0/6"=>{:mode=>:trunk, :native=>true},
40
+ "ge-0/0/7"=>{:mode=>:trunk, :native=>true},
41
+ "ge-0/0/20"=>{:mode=>:access},
42
+ "ge-0/0/21"=>{:mode=>:access}}
43
+ ```
@@ -288,6 +288,17 @@ end
288
288
  The above example will also return the new resource object. So you could use the Ruby
289
289
  block as a default initializer, and then continue to make changes to the resource.
290
290
 
291
+ The `create` method takes an optional 2nd argument, a Hash of the resource properties. So you could do the following equivalent:
292
+
293
+ ```ruby
294
+ data = {:description => "I am port 20", :untagged_vlan => "Blue" }
295
+
296
+ ndev.l2_ports.create('ge-0/0/20', data) do |port|
297
+ port.write!
298
+ port.deactivate!
299
+ end
300
+ ```
301
+
291
302
  The second way is to simply select a resource by name that doesn't exist. So let's
292
303
  say you want to create a new L2port for `ge-0/0/20`. It would look something like this:
293
304
 
@@ -300,3 +311,16 @@ port[:description] = "I am port 20"
300
311
  port[:untagged_vlan] = "Storage"
301
312
  port.write!
302
313
  ```
314
+
315
+ ### Interating Resources
316
+
317
+ You can use the `each` method to interate through each managed resource. For example:
318
+
319
+ ```ruby
320
+ ndev.l1_ports.each do |port|
321
+ status = port.status
322
+ if (port[:admin] == :up) and (status[:oper_status] != :up)
323
+ puts "Port #{port.name} should be up, and isn't!
324
+ end
325
+ end
326
+ ```
@@ -0,0 +1,27 @@
1
+ # CODE EXAMPLES
2
+
3
+ Much of the documentation include small code "snippets". These are not complete programs, but rather meant to show specific functionality.
4
+
5
+ The following libraries are assumed to be in scope:
6
+
7
+ - `require 'pp'` : for pretty-printing Ruby objects
8
+ - `require 'pry'` : for setting code break-points
9
+
10
+ These examples use the `->` symbol to indicate screen output. For example:
11
+
12
+ ```ruby
13
+
14
+ port = ndev.l2_ports["ge-0/0/8"]
15
+ pp port.to_h
16
+ ->
17
+ {"ge-0/0/0"=>
18
+ {:_active=>true,
19
+ :_exist=>true,
20
+ :description=>"Jeremy port for testing",
21
+ :vlan_tagging=>true,
22
+ :untagged_vlan=>"Green",
23
+ :tagged_vlans=>["Red"]}}
24
+
25
+ ```
26
+
27
+ Here the Hash structure following the `->` is the output of the prior "pretty-print", `pp port.to_h`, instruction.
@@ -0,0 +1,161 @@
1
+ # Junos::Ez::Config::Utils
2
+
3
+ A collection of methods to perform file / template based configuration, and configuration control functions, like "commit", "show | compare", "rollback", etc.
4
+
5
+ These methods return data in Hash / Array structures so the information can be programmatically accessible, rather than scraping CLI or navigating Junos XML.
6
+
7
+ # USAGE
8
+
9
+ ```ruby
10
+ # bind :cu to give us access to the config utilities
11
+ Junos::Ez::Config::Utils( ndev, :cu )
12
+
13
+ # load a Junos configuration file on our local filesys
14
+
15
+ ndev.cu.load! :filename => 'basic-setup.conf'
16
+
17
+ # check to see if these changes will commit ok. if not, display the errors, rollback the config,
18
+ # close the netconf session, and exit the program.
19
+
20
+ unless (result = ndev.cu.commit?) == true
21
+ puts "There are commit errors, dumping result ..."
22
+ pp result
23
+ ndev.cu.rollback!
24
+ ndev.close
25
+ exit 1
26
+ end
27
+
28
+ # commit the confguration and close the netconf session
29
+
30
+ ndev.cu.commit!
31
+ ndev.close
32
+ ```
33
+
34
+ # METHODS
35
+
36
+ - `lock!` - attempt exclusive config, returns true or raises Netconf::LockError
37
+ - `load!` - loads configuration snippets or templates (ERB)
38
+ - `diff?` - returns String of "show | compare" as String
39
+ - `commit?` - checks the candidate config for validation, returns true or Hash of errors
40
+ - `commit!` - performs commit, returns true or raises Netconf::CommitError
41
+ - `unlock!` - releases exclusive lock on config
42
+ - `rollback!` - performs rollback of config
43
+ - `get_config` - returns text-format of configuration
44
+
45
+ # GORY DETAILS
46
+
47
+ ## lock!
48
+ Attempt exclusive config, returns `true` if you now have the lock, or raises `Netconf::LockError` exception if the lock is not available
49
+
50
+ ## load!( opts = {} )
51
+
52
+ Loads configuration snippets or templates (ERB). This method does **not** commit the change, only loads the contents into the candidate configuration. If the load was successful, this method will return `true`. Otherwise it will raise a `Netconf::EditError` exception.
53
+
54
+ The options Hash enables the following controls:
55
+
56
+
57
+ ```
58
+ :filename => String
59
+ ```
60
+ Identifies filename on local-system. File can contain either static config or template in ERB format. The framework will identify the format-style of the content by the filename extension. You can override this behavior using the `:format` option. By default, the framework will map extensions to `:format` as follow:
61
+
62
+ - `:text` when *.{conf,text,txt}
63
+ - `:set` when *.set
64
+ - `:xml` when *.xml
65
+
66
+ ```
67
+ :content => String
68
+ ```
69
+ Ccontent of configuration, rather than loading it from a file. Handy if you are loading the same content on many devices, and you don't want to keep re-reading it from a file
70
+
71
+ ```
72
+ :format => Symbol
73
+ ```
74
+
75
+ Identifies the format-style of the configuration. The default is `:text`. Setting this option will override the `:filename` extension style mapping.
76
+
77
+ `:text` - indcates "text" or "curly-brace" style
78
+
79
+ `:set` - "set" commands, one per line
80
+
81
+ `:xml` - native Junos XML
82
+
83
+ ```
84
+ :binding => Object | Binding
85
+ ```
86
+ Required when the configuration content is a Ruby ERB template. If `:binding` is an Object, then that object becomes the scope of the variables available to the template. If you want to use the *current scope*, then using the `binding` variable that is availble (it is always there)
87
+
88
+ ```
89
+ :overwrite!
90
+ ```
91
+ When `true` the provided configuraiton will **COMPLETELY OVERWRITE** any existing configuration. This is useful when writing an entire configuration from scratch.
92
+
93
+ ```
94
+ :replace!
95
+ ```
96
+ When `true` enables the Junos *replace* option. This is required if your configuration changes utilize either the `replace:` statement in text-format style or the `replace="replace"` attribute in XML-format style. You do not need to set this option if you are using the set-format style.
97
+
98
+ ## diff?
99
+ Returns String of "show | compare" as String. If there is no diff, then this method returns `nil`.
100
+
101
+ ## commit?
102
+
103
+ Checks the candidate config for validation, returns `true` or Array of errors.
104
+
105
+ The following is an example errors:
106
+ ```ruby
107
+ ndev.cu.commit?
108
+ ->
109
+ [{:severity=>"error",
110
+ :message=>"Referenced filter 'foo' is not defined",
111
+ :edit_path=>"[edit interfaces ge-0/0/8 unit 0 family inet]",
112
+ :bad_identifier=>"filter"},
113
+ {:severity=>"error", :message=>"configuration check-out failed"}]
114
+ ```
115
+
116
+ ## commit!( opts = {} )
117
+
118
+ Performs commit, returns `true` or raises `Netconf::CommitError`. Available options are:
119
+
120
+ :comment => String
121
+ A commit log comment that is available when retrieving the commit log.
122
+
123
+ :confirm => Fixnum-Minutes
124
+ Identifies a timeout in minutes to automatically rollback the configuration unless you explicitly issue another commit action. This is very useful if you think your configuration changes may lock you out of the device.
125
+
126
+ ## unlock!
127
+
128
+ Releases exclusive lock on config. If you do not posses the lock, this method will raise an `Netconf::RpcError` exception.
129
+
130
+ ## rollback!( rollback_id = 0 )
131
+
132
+ Loads a rollback of config, does not commit.
133
+
134
+ ## get_config( scope = nil )
135
+
136
+ Returns the text-style format of the request config. If `scope` is `nil` then the entire configuration is returned. If the `scope` is invalid (asking for the "foo" stanza for example), then a string with "ERROR!" is returned. If the requested config is non-existant (asking for non-existant interface), then `nil` is returned.
137
+
138
+ Successful request:
139
+ ```ruby
140
+ puts ndev.cu.get_config "interfaces ge-0/0/0"
141
+ ->
142
+ unit 0 {
143
+ family inet {
144
+ address 192.168.56.2/24;
145
+ }
146
+ }
147
+ ```
148
+
149
+ Valid request, but not config:
150
+ ```ruby
151
+ puts ndev.cu.get_config "interfaces ge-0/0/3"
152
+ ->
153
+ nil
154
+ ```
155
+
156
+ Invalid request:
157
+ ```ruby
158
+ puts ndev.cu.get_config "foober jazzbot"
159
+ ->
160
+ ERROR! syntax error: foober
161
+ ```