rbeapi 0.5.0 → 0.5.1

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.
Files changed (57) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/Gemfile +1 -1
  3. data/README.md +17 -12
  4. data/guide/.gitignore +2 -0
  5. data/guide/api.rst +5894 -0
  6. data/guide/conf.py +5 -5
  7. data/guide/contributing.rst +6 -0
  8. data/guide/getting-started.rst +134 -0
  9. data/guide/index.rst +3 -5
  10. data/guide/installation.rst +56 -1
  11. data/guide/license.rst +13 -2
  12. data/guide/overview.rst +2 -5
  13. data/guide/testing.rst +5 -1
  14. data/guide/upgrading.rst +10 -0
  15. data/lib/rbeapi/api.rb +37 -36
  16. data/lib/rbeapi/api/aaa.rb +90 -90
  17. data/lib/rbeapi/api/acl.rb +70 -53
  18. data/lib/rbeapi/api/bgp.rb +186 -163
  19. data/lib/rbeapi/api/dns.rb +51 -45
  20. data/lib/rbeapi/api/interfaces.rb +344 -328
  21. data/lib/rbeapi/api/ipinterfaces.rb +92 -92
  22. data/lib/rbeapi/api/logging.rb +32 -32
  23. data/lib/rbeapi/api/mlag.rb +97 -97
  24. data/lib/rbeapi/api/ntp.rb +39 -39
  25. data/lib/rbeapi/api/ospf.rb +58 -58
  26. data/lib/rbeapi/api/prefixlists.rb +22 -22
  27. data/lib/rbeapi/api/radius.rb +77 -49
  28. data/lib/rbeapi/api/routemaps.rb +110 -64
  29. data/lib/rbeapi/api/snmp.rb +104 -100
  30. data/lib/rbeapi/api/staticroutes.rb +27 -20
  31. data/lib/rbeapi/api/stp.rb +100 -84
  32. data/lib/rbeapi/api/switchports.rb +98 -77
  33. data/lib/rbeapi/api/system.rb +93 -25
  34. data/lib/rbeapi/api/tacacs.rb +54 -35
  35. data/lib/rbeapi/api/users.rb +68 -68
  36. data/lib/rbeapi/api/varp.rb +56 -47
  37. data/lib/rbeapi/api/vlans.rb +86 -86
  38. data/lib/rbeapi/api/vrrp.rb +210 -173
  39. data/lib/rbeapi/client.rb +142 -108
  40. data/lib/rbeapi/eapilib.rb +73 -62
  41. data/lib/rbeapi/utils.rb +8 -8
  42. data/lib/rbeapi/version.rb +2 -2
  43. data/spec/fixtures/test.conf +3 -3
  44. data/spec/system/rbeapi/api/system_spec.rb +46 -2
  45. data/spec/system/rbeapi/api/vlans_spec.rb +5 -2
  46. data/spec/system/rbeapi/client_spec.rb +4 -4
  47. data/spec/unit/rbeapi/api/system/default_spec.rb +40 -4
  48. data/spec/unit/rbeapi/api/system/fixture_system.text +14 -0
  49. data/spec/unit/rbeapi/api/vlans/default_spec.rb +1 -1
  50. data/spec/unit/rbeapi/api/vlans/fixture_vlans.text +2 -0
  51. data/spec/unit/rbeapi/client_spec.rb +1 -0
  52. metadata +9 -9
  53. data/guide/cookbook.rst +0 -4
  54. data/guide/developing.rst +0 -4
  55. data/guide/faq.rst +0 -4
  56. data/guide/quickstart.rst +0 -4
  57. data/guide/troubleshooting.rst +0 -1
@@ -32,10 +32,10 @@
32
32
  require 'rbeapi/api'
33
33
 
34
34
  ##
35
- # Rbeapi toplevel namespace
35
+ # Rbeapi toplevel namespace.
36
36
  module Rbeapi
37
37
  ##
38
- # Api is module namespace for working with the EOS command API
38
+ # Api is module namespace for working with the EOS command API.
39
39
  module Api
40
40
  #
41
41
  # The Ipinterface class provides an instance for managing logical
@@ -49,17 +49,17 @@ module Rbeapi
49
49
  #
50
50
  # @example
51
51
  # {
52
- # address: <string>
53
- # mtu: <string>
52
+ # address: <string>,
53
+ # mtu: <string>,
54
54
  # helper_addresses: array<strings>
55
55
  # }
56
56
  #
57
- # @param [String] :name The full interface identifier of the interface to
58
- # return the resource configuration hash for. The name must be the
59
- # full name (Ethernet, not Et)
57
+ # @param name [String] The full interface identifier of the interface to
58
+ # return the resource configuration hash for. The name must be the
59
+ # full name (Ethernet, not Et).
60
60
  #
61
- # @return [nil, Hash<Symbol, Object>] returns the ip interface
62
- # configuration as a hash. If the provided interface name is not a
61
+ # @return [nil, Hash<Symbol, Object>] Returns the ip interface
62
+ # configuration as a hash. If the provided interface name is not a
63
63
  # configured ip address, nil is returned.
64
64
  def get(name)
65
65
  config = get_block("interface #{name}")
@@ -80,13 +80,13 @@ module Rbeapi
80
80
  # @example
81
81
  # {
82
82
  # <name>: {
83
- # address: <string>
84
- # mtu: <string>
83
+ # address: <string>,
84
+ # mtu: <string>,
85
85
  # helper_addresses: array<strings>
86
86
  # },
87
87
  # <name>: {
88
- # address: <string>
89
- # mtu: <string>
88
+ # address: <string>,
89
+ # mtu: <string>,
90
90
  # helper_addresses: array<strings>
91
91
  # },
92
92
  # ...
@@ -94,9 +94,9 @@ module Rbeapi
94
94
  #
95
95
  # @see get Ipaddress resource example
96
96
  #
97
- # @return [Hash<Symbol, Object>] returns a hash object that
98
- # represents all of the configured IP addresses found. If no IP
99
- # addresses are configured, then an empty hash is returned
97
+ # @return [Hash<Symbol, Object>] Returns a hash object that
98
+ # represents all of the configured IP addresses found. If no IP
99
+ # addresses are configured, then an empty hash is returned.
100
100
  def getall
101
101
  interfaces = config.scan(/(?<=^interface\s).+/)
102
102
  interfaces.each_with_object({}) do |name, hsh|
@@ -107,17 +107,17 @@ module Rbeapi
107
107
 
108
108
  ##
109
109
  # parse_address scans the provided configuration block and extracts
110
- # the interface address, if configured, and returns it. If there is
110
+ # the interface address, if configured, and returns it. If there is
111
111
  # no IP address configured, then this method will return the
112
- # DEFAULT_ADDRESS. The return value is intended to be merged into the
112
+ # DEFAULT_ADDRESS. The return value is intended to be merged into the
113
113
  # ipaddress resource hash.
114
114
  #
115
115
  # @api private
116
116
  #
117
- # @param [String] :config The IP interface configuration block returned
118
- # from the node's running configuration
117
+ # @param config [String] The IP interface configuration block returned
118
+ # from the node's running configuration.
119
119
  #
120
- # @return [Hash<Symbol, Object>] resource hash attribute
120
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
121
121
  def parse_address(config)
122
122
  mdata = /(?<=^\s{3}ip\saddress\s)(.+)$/.match(config)
123
123
  { address: mdata.nil? ? DEFAULT_ADDRESS : mdata[1] }
@@ -126,16 +126,16 @@ module Rbeapi
126
126
 
127
127
  ##
128
128
  # parse_mtu scans the provided configuration block and extracts the IP
129
- # interface MTU value. The MTU value is expected to always be present in
130
- # the configuration blcok. The return value is intended to be merged
131
- # into the ipaddress resource hash
129
+ # interface MTU value. The MTU value is expected to always be present in
130
+ # the configuration blcok. The return value is intended to be merged
131
+ # into the ipaddress resource hash.
132
132
  #
133
133
  # @api private
134
134
  #
135
- # @param [String] :config The IP interface configuration block returned
136
- # from the node's running configuration
135
+ # @param config [String] The IP interface configuration block returned
136
+ # from the node's running configuration.
137
137
  #
138
- # @return [Hash<Symbol, Object>] resource hash attribute
138
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
139
139
  def parse_mtu(config)
140
140
  mdata = /(?<=mtu\s)(\d+)$/.match(config)
141
141
  { mtu: mdata.nil? ? '' : mdata[1] }
@@ -144,18 +144,18 @@ module Rbeapi
144
144
 
145
145
  ##
146
146
  # parse_helper_addresses scans the provided configuration block and
147
- # extracts any configured IP helper address values. The interface could
148
- # be configured with one or more helper addresses. If no helper
147
+ # extracts any configured IP helper address values. The interface could
148
+ # be configured with one or more helper addresses. If no helper
149
149
  # addresses are configured, then an empty array is set in the return
150
- # hash. The return value is intended to be merged into the ipaddress
151
- # resource hash
150
+ # hash. The return value is intended to be merged into the ipaddress
151
+ # resource hash.
152
152
  #
153
153
  # @api private
154
154
  #
155
- # @param [String] :config The IP interface configuration block returned
156
- # from the node's running configuration
155
+ # @param config [String] The IP interface configuration block returned
156
+ # from the node's running configuration.
157
157
  #
158
- # @return [Hash<Symbol, Object>] resource hash attribute
158
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
159
159
  def parse_helper_addresses(config)
160
160
  helpers = config.scan(/(?<=\s{3}ip\shelper-address\s).+$/)
161
161
  { helper_addresses: helpers }
@@ -163,80 +163,80 @@ module Rbeapi
163
163
  private :parse_helper_addresses
164
164
 
165
165
  ##
166
- # create will create a new IP interface on the node. If the ip interface
166
+ # create will create a new IP interface on the node. If the ip interface
167
167
  # already exists in the configuration, this method will still return
168
- # successful. This method will cause an existing layer 2 interface
168
+ # successful. This method will cause an existing layer 2 interface
169
169
  # (switchport) to be deleted if it exists in the node's configuration.
170
170
  #
171
- # @eos_version 4.13.7M
171
+ # @since eos_version 4.13.7M
172
172
  #
173
- # @commands
173
+ # ===Commands
174
174
  # interface <name>
175
175
  # no switchport
176
176
  #
177
- # @param [String] :name The full interface name of the port to create the
178
- # logical interface on. The name must be the full interface
179
- # identifier
177
+ # @param name [String] The full interface name of the port to create the
178
+ # logical interface on. The name must be the full interface
179
+ # identifier.
180
180
  #
181
- # @return [Boolean] returns true if the commands complete successfully
181
+ # @return [Boolean] Returns true if the commands complete successfully.
182
182
  def create(name)
183
183
  configure(["interface #{name}", 'no switchport'])
184
184
  end
185
185
 
186
186
  ##
187
187
  # delete will delete an existing IP interface in the node's current
188
- # configuration. If the IP interface does not exist on the specified
189
- # interface, this method will still return success. This command will
188
+ # configuration. If the IP interface does not exist on the specified
189
+ # interface, this method will still return success. This command will
190
190
  # default the interface back to being a switchport.
191
191
  #
192
- # @eos_version 4.13.7M
192
+ # @since eos_version 4.13.7M
193
193
  #
194
- # @commands
194
+ # ===Commands
195
195
  # interface <name>
196
196
  # no ip address
197
197
  # switchport
198
198
  #
199
- # @param [String] :name The full interface name of the port to delete the
200
- # logical interface from. The name must be the full interface name
199
+ # @param name [String] The full interface name of the port to delete the
200
+ # logical interface from. The name must be the full interface name
201
201
  #
202
- # @return [Boolean] returns true if the commands complete successfully
202
+ # @return [Boolean] Returns true if the commands complete successfully.
203
203
  def delete(name)
204
204
  configure(["interface #{name}", 'no ip address', 'switchport'])
205
205
  end
206
206
 
207
207
  ##
208
208
  # set_address configures a logical IP interface with an address.
209
- # The address value must be in the form of A.B.C.D/E. If the enable
209
+ # The address value must be in the form of A.B.C.D/E. If the enable
210
210
  # keyword is false, then the interface address is negated using the
211
- # config no keyword. If the default option is set to true, then the
212
- # ip address # value is defaulted using the default keyword. The
211
+ # config no keyword. If the default option is set to true, then the
212
+ # ip address # value is defaulted using the default keyword. The
213
213
  # default keyword has precedence over the enable keyword if both
214
- # options are specified
214
+ # options are specified.
215
215
  #
216
- # @eos_version 4.13.7M
216
+ # @since eos_version 4.13.7M
217
217
  #
218
- # @commands
218
+ # ===Commands
219
219
  # interface <name>
220
220
  # ip address <value>
221
221
  # no ip address
222
222
  # default ip address
223
223
  #
224
- # @param [String] :name The name of the interface to configure the
225
- # address in the node. The name must be the full interface name.
224
+ # @param name [String] The name of the interface to configure the
225
+ # address in the node. The name must be the full interface name.
226
226
  #
227
- # @param [Hash] :opts Optional keyword arguments
227
+ # @param opts [Hash] Optional keyword arguments.
228
228
  #
229
- # @option :opts [String] :value The value to configure the address to
230
- # for the specified interface name. The value must be in the form
231
- # of A.B.C.D/E
229
+ # @option opts value [String] The value to configure the address to
230
+ # for the specified interface name. The value must be in the form
231
+ # of A.B.C.D/E.
232
232
  #
233
- # @option :opts [Boolean] :enable If false then the command is
233
+ # @option opts enable [Boolean] If false then the command is
234
234
  # negated. Default is true.
235
235
  #
236
- # @option :opts [Boolean] :default Configure the ip address value using
237
- # the default keyword
236
+ # @option opts default [Boolean] Configure the ip address value using
237
+ # the default keyword.
238
238
  #
239
- # @return [Boolean] returns true if the command completed successfully
239
+ # @return [Boolean] Returns True if the command completed successfully.
240
240
  def set_address(name, opts = {})
241
241
  cmds = command_builder('ip address', opts)
242
242
  configure_interface(name, cmds)
@@ -244,36 +244,36 @@ module Rbeapi
244
244
 
245
245
  ##
246
246
  # set_mtu configures the IP mtu value of the ip interface in the nodes
247
- # configuration. If the enable option is false, then the ip mtu value is
248
- # configured using the no keyword. If the default keyword option is
247
+ # configuration. If the enable option is false, then the ip mtu value is
248
+ # configured using the no keyword. If the default keyword option is
249
249
  # provided and set to true then the ip mtu value is configured using the
250
- # default keyword. The default keyword has precedence over the enable
250
+ # default keyword. The default keyword has precedence over the enable
251
251
  # keyword if both options are specified.
252
252
  #
253
- # @eos_version 4.13.7M
253
+ # @since eos_version 4.13.7M
254
254
  #
255
- # @commands
255
+ # ===Commands
256
256
  # interface <name>
257
257
  # mtu <value>
258
258
  # no mtu
259
259
  # default mtu
260
260
  #
261
- # @param [String] :name The name of the interface to configure the
262
- # address in the node. The name must be the full interface name.
261
+ # @param name [String] The name of the interface to configure the
262
+ # address in the node. The name must be the full interface name.
263
263
  #
264
- # @param [Hash] :opts Optional keyword arguments
264
+ # @param opts [Hash] Optional keyword arguments.
265
265
  #
266
- # @option :opts [String] :value The value to configure the IP MTU to in
267
- # the nodes configuration. Valid values are in the range of 68 to 9214
268
- # bytes. The default is 1500 bytes
266
+ # @option opts value [String] The value to configure the IP MTU to in
267
+ # the nodes configuration. Valid values are in the range of 68 to 9214
268
+ # bytes. The default is 1500 bytes.
269
269
  #
270
- # @option :opts [Boolean] :enable If false then the command is
270
+ # @option opts enable [Boolean] If false then the command is
271
271
  # negated. Default is true.
272
272
  #
273
- # @option :opts [Boolean] :default Configure the ip mtu value using
274
- # the default keyword
273
+ # @option opts default [Boolean] Configure the ip mtu value using
274
+ # the default keyword.
275
275
  #
276
- # @return [Boolean] returns true if the command completed successfully
276
+ # @return [Boolean] Returns true if the command completed successfully.
277
277
  def set_mtu(name, opts = {})
278
278
  cmds = command_builder('mtu', opts)
279
279
  configure_interface(name, cmds)
@@ -281,31 +281,31 @@ module Rbeapi
281
281
 
282
282
  ##
283
283
  # set_helper_addresses configures the list of helper addresses on the ip
284
- # interface. An IP interface can have one or more helper addresses
285
- # configured. If no value is provided, the helper address configuration
286
- # is set using the no keyword. If the default option is specified and
284
+ # interface. An IP interface can have one or more helper addresses
285
+ # configured. If no value is provided, the helper address configuration
286
+ # is set using the no keyword. If the default option is specified and
287
287
  # set to true, then the helper address values are defaulted using the
288
288
  # default keyword.
289
289
  #
290
- # @eos_version 4.13.7M
290
+ # @since eos_version 4.13.7M
291
291
  #
292
- # @commands
292
+ # ===Commands
293
293
  # interface <name>
294
294
  # ip helper-address <value>
295
295
  # no ip helper-address
296
296
  # default ip helper-address
297
297
  #
298
- # @param [String] :name The name of the interface to configure the
299
- # address in the node. The name must be the full interface name.
298
+ # @param name [String] The name of the interface to configure the
299
+ # address in the node. The name must be the full interface name.
300
300
  #
301
- # @param [Hash] :opts Optional keyword arguments
301
+ # @param opts [Hash] Optional keyword arguments.
302
302
  #
303
- # @option :opts [Array] :value The list of IP addresses to configure as
304
- # helper address on the interface. The helper addresses must be valid
303
+ # @option opts value [Array] The list of IP addresses to configure as
304
+ # helper address on the interface. The helper addresses must be valid
305
305
  # addresses in the main interface's subnet.
306
306
  #
307
- # @option :opts [Boolean] :default Configure the ip helper address values
308
- # using the default keyword
307
+ # @option opts default [Boolean] Configure the ip helper address values
308
+ # using the default keyword.
309
309
  #
310
310
  def set_helper_addresses(name, opts = {})
311
311
  value = opts[:value]
@@ -32,10 +32,10 @@
32
32
  require 'rbeapi/api'
33
33
 
34
34
  ##
35
- # Rbeapi toplevel namespace
35
+ # Rbeapi toplevel namespace.
36
36
  module Rbeapi
37
37
  ##
38
- # Api is module namespace for working with the EOS command API
38
+ # Api is module namespace for working with the EOS command API.
39
39
  module Api
40
40
  ##
41
41
  # The Logging class manages logging settings on an EOS node.
@@ -50,8 +50,8 @@ module Rbeapi
50
50
  # hosts: array<strings>
51
51
  # }
52
52
  #
53
- # @return [Hash<Symbol, Object>] returns the logging resource as a hash
54
- # object from the nodes current configuration
53
+ # @return [Hash<Symbol, Object>] Returns the logging resource as a hash
54
+ # object from the nodes current configuration.
55
55
  def get
56
56
  response = {}
57
57
  response.merge!(parse_enable)
@@ -61,14 +61,14 @@ module Rbeapi
61
61
 
62
62
  ##
63
63
  # parse_enable scans the nodes current running configuration and extracts
64
- # the current enabled state of the logging facility. The logging enable
65
- # command is expected to always be in the node's configuration. This
64
+ # the current enabled state of the logging facility. The logging enable
65
+ # command is expected to always be in the node's configuration. This
66
66
  # methods return value is intended to be merged into the logging resource
67
67
  # hash.
68
68
  #
69
69
  # @api private
70
70
  #
71
- # @return [Hash<Symbol, Object>] resource hash attribute
71
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
72
72
  def parse_enable
73
73
  value = /no logging on/ !~ config
74
74
  { enable: value }
@@ -76,14 +76,14 @@ module Rbeapi
76
76
 
77
77
  ##
78
78
  # parse_hosts scans the nodes current running configuration and extracts
79
- # the configured logging host destinations if any are configured. If no
79
+ # the configured logging host destinations if any are configured. If no
80
80
  # logging hosts are configured, then the value for hosts will be an empty
81
- # array. The return value is intended to be merged into the logging
81
+ # array. The return value is intended to be merged into the logging
82
82
  # resource hash
83
83
  #
84
84
  # @api private
85
85
  #
86
- # @return [Hash<Symbol, Object>] resource hash attribute
86
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
87
87
  def parse_hosts
88
88
  hosts = config.scan(/(?<=^logging\shost\s)[^\s]+/)
89
89
  { hosts: hosts }
@@ -92,28 +92,28 @@ module Rbeapi
92
92
 
93
93
  ##
94
94
  # set_enable configures the global logging instance on the node as either
95
- # enabled or disabled. If the enable keyword is set to true then logging
96
- # is globally enabled and if set to false, it is globally disabled. If
95
+ # enabled or disabled. If the enable keyword is set to true then logging
96
+ # is globally enabled and if set to false, it is globally disabled. If
97
97
  # the default keyword is specified and set to true, then the configuration
98
- # is defaulted using the default keyword. The default keyword option
98
+ # is defaulted using the default keyword. The default keyword option
99
99
  # takes precedence over the enable keyword if both options are specified.
100
100
  #
101
- # @eos_version 4.13.7M
101
+ # @since eos_version 4.13.7M
102
102
  #
103
- # @commands
103
+ # ===Commands
104
104
  # logging on
105
105
  # no logging on
106
106
  # default logging on
107
107
  #
108
- # @param [Hash] :opts Optional keyword arguments
108
+ # @param opts [Hash] Optional keyword arguments
109
109
  #
110
- # @option :opts [Boolean] :enable Enables logging globally if value is
111
- # true or disabled logging globally if value is false
110
+ # @option opts enable [Boolean] Enables logging globally if value is
111
+ # true or disabled logging globally if value is false.
112
112
  #
113
- # @option :opts [Boolean] :default Configure the ip address value using
114
- # the default keyword
113
+ # @option opts default [Boolean] Configure the ip address value using
114
+ # the default keyword.
115
115
  #
116
- # @return [Boolean] returns true if the command completed successfully
116
+ # @return [Boolean] Returns true if the command completed successfully.
117
117
  def set_enable(opts = {})
118
118
  cmd = command_builder('logging on', opts)
119
119
  configure cmd
@@ -121,36 +121,36 @@ module Rbeapi
121
121
 
122
122
  ##
123
123
  # add_host configures a new logging destination host address or hostname
124
- # to the list of logging destinations. If the host is already configured
124
+ # to the list of logging destinations. If the host is already configured
125
125
  # in the list of destinations, this method will return successfully.
126
126
  #
127
- # @eos_version 4.13.7M
127
+ # @since eos_version 4.13.7M
128
128
  #
129
- # @commands
129
+ # ===Commands
130
130
  # logging host <name>
131
131
  #
132
- # @param [String] :name The host name or ip address of the destination
132
+ # @param name [String] The host name or ip address of the destination
133
133
  # node to send logging information to.
134
134
  #
135
- # @return [Boolean] returns true if the command completed successfully
135
+ # @return [Boolean] Returns true if the command completed successfully.
136
136
  def add_host(name)
137
137
  configure "logging host #{name}"
138
138
  end
139
139
 
140
140
  ##
141
141
  # remove_host deletes a logging destination host name or address form the
142
- # list of logging destinations. If the host is not in the list of
142
+ # list of logging destinations. If the host is not in the list of
143
143
  # configured hosts, this method will still return successfully.
144
144
  #
145
- # @eos_version 4.13.7M
145
+ # @since eos_version 4.13.7M
146
146
  #
147
- # @commands
147
+ # ===Commands
148
148
  # no logging host <name>
149
149
  #
150
- # @param [String] :name The host name or ip address of the destination
151
- # host to remove from the nodes current configuration
150
+ # @param name [String] The host name or ip address of the destination
151
+ # host to remove from the nodes current configuration.
152
152
  #
153
- # @return [Boolean] returns true if the commands completed successfully
153
+ # @return [Boolean] Returns true if the commands completed successfully.
154
154
  def remove_host(name)
155
155
  configure "no logging host #{name}"
156
156
  end