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 Switchport class provides a base class instance for working with
@@ -44,7 +44,7 @@ module Rbeapi
44
44
  class Switchports < Entity
45
45
  ##
46
46
  # Retrieves the properties for a logical switchport from the
47
- # running-config using eAPI
47
+ # running-config using eAPI.
48
48
  #
49
49
  # Example
50
50
  # {
@@ -52,13 +52,14 @@ module Rbeapi
52
52
  # "mode": [access, trunk],
53
53
  # "trunk_allowed_vlans": array<strings>
54
54
  # "trunk_native_vlan": <Integer>,
55
- # "access_vlan": <Integer>
55
+ # "access_vlan": <Integer>,
56
+ # "trunk_groups": array<strings>
56
57
  # }
57
58
  #
58
- # @param [String] :name The full name of the interface to get. The
59
- # interface name must be the full interface (ie Ethernet, not Et)
59
+ # @param name [String] The full name of the interface to get. The
60
+ # interface name must be the full interface (ie Ethernet, not Et).
60
61
  #
61
- # @return [Hash] a hash that includes the switchport properties
62
+ # @return [Hash] Returns a hash that includes the switchport properties.
62
63
  def get(name)
63
64
  config = get_block("interface #{name}")
64
65
  return nil unless config
@@ -74,14 +75,14 @@ module Rbeapi
74
75
  end
75
76
 
76
77
  ##
77
- # parse_mode parses switchport mode from the provided config
78
+ # parse_mode parses switchport mode from the provided config.
78
79
  #
79
80
  # @api private
80
81
  #
81
- # @param [String] :config The configuration block returned
82
- # from the node's running configuration
82
+ # @param config [String] The configuration block returned
83
+ # from the node's running configuration.
83
84
  #
84
- # @return [Hash<Symbol, Object>] resource hash attribute
85
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
85
86
  def parse_mode(config)
86
87
  mdata = /(?<=\s{3}switchport\smode\s)(.+)$/.match(config)
87
88
  { mode: mdata[1] }
@@ -90,14 +91,14 @@ module Rbeapi
90
91
 
91
92
  ##
92
93
  # parse_access_vlan parses access vlan from the provided
93
- # config
94
+ # config.
94
95
  #
95
96
  # @api private
96
97
  #
97
- # @param [String] :config The configuration block returned
98
- # from the node's running configuration
98
+ # @param config [String] The configuration block returned
99
+ # from the node's running configuration.
99
100
  #
100
- # @return [Hash<Symbol, Object>] resource hash attribute
101
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
101
102
  def parse_access_vlan(config)
102
103
  mdata = /(?<=access\svlan\s)(.+)$/.match(config)
103
104
  { access_vlan: mdata[1] }
@@ -106,14 +107,14 @@ module Rbeapi
106
107
 
107
108
  ##
108
109
  # parse_trunk_native_vlan parses trunk native vlan from
109
- # the provided config
110
+ # the provided config.
110
111
  #
111
112
  # @api private
112
113
  #
113
- # @param [String] :config The configuration block returned
114
- # from the node's running configuration
114
+ # @param config [String] The configuration block returned
115
+ # from the node's running configuration.
115
116
  #
116
- # @return [Hash<Symbol, Object>] resource hash attribute
117
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
117
118
  def parse_trunk_native_vlan(config)
118
119
  mdata = /(?<=trunk\snative\svlan\s)(.+)$/.match(config)
119
120
  { trunk_native_vlan: mdata[1] }
@@ -122,14 +123,14 @@ module Rbeapi
122
123
 
123
124
  ##
124
125
  # parse_trunk_allowed_vlans parses trunk allowed vlan from
125
- # the provided config
126
+ # the provided config.
126
127
  #
127
128
  # @api private
128
129
  #
129
- # @param [String] :config The configuration block returned
130
- # from the node's running configuration
130
+ # @param config [String] The configuration block returned
131
+ # from the node's running configuration.
131
132
  #
132
- # @return [Hash<Symbol, Object>] resource hash attribute
133
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
133
134
  def parse_trunk_allowed_vlans(config)
134
135
  mdata = /(?<=trunk\sallowed\svlan\s)(.+)$/.match(config)
135
136
  return { trunk_allowed_vlans: [] } unless mdata[1] != 'none'
@@ -148,14 +149,14 @@ module Rbeapi
148
149
 
149
150
  ##
150
151
  # parse_trunk_groups parses trunk group values from the
151
- # provided config
152
+ # provided config.
152
153
  #
153
154
  # @api private
154
155
  #
155
- # @param [String] :config The configuration block returned
156
- # from the node's running configuration
156
+ # @param config [String] The configuration block returned
157
+ # from the node's running configuration.
157
158
  #
158
- # @return [Hash<Symbol, Object>] resource hash attribute
159
+ # @return [Hash<Symbol, Object>] Returns the resource hash attribute.
159
160
  def parse_trunk_groups(config)
160
161
  mdata = config.scan(/(?<=trunk\sgroup\s)(.+)$/)
161
162
  mdata = mdata.flatten if mdata.length > 0
@@ -164,7 +165,7 @@ module Rbeapi
164
165
  private :parse_trunk_groups
165
166
 
166
167
  ##
167
- # Retrieves all switchport interfaces from the running-config
168
+ # Retrieves all switchport interfaces from the running-config.
168
169
  #
169
170
  # @example
170
171
  # {
@@ -185,7 +186,7 @@ module Rbeapi
185
186
  # ...
186
187
  # }
187
188
  #
188
- # @return [Array] an array of switchport hashes
189
+ # @return [Array] Returns an array of switchport hashes.
189
190
  def getall
190
191
  interfaces = config.scan(/(?<=^interface\s)([Et|Po].+)$/)
191
192
  interfaces.each_with_object({}) do |port, hsh|
@@ -195,31 +196,31 @@ module Rbeapi
195
196
  end
196
197
 
197
198
  ##
198
- # Creates a new logical switchport interface in EOS
199
+ # Creates a new logical switchport interface in EOS.
199
200
  #
200
- # @param [String] name The name of the logical interface
201
+ # @param name [String] The name of the logical interface.
201
202
  #
202
- # @return [Boolean] True if it succeeds otherwise False
203
+ # @return [Boolean] Returns True if it succeeds otherwise False.
203
204
  def create(name)
204
205
  configure ["interface #{name}", 'no ip address', 'switchport']
205
206
  end
206
207
 
207
208
  ##
208
- # Deletes a logical switchport interface from the running-config
209
+ # Deletes a logical switchport interface from the running-config.
209
210
  #
210
- # @param [String] name The name of the logical interface
211
+ # @param name [String] The name of the logical interface.
211
212
  #
212
- # @return [Boolean] True if it succeeds otherwise False
213
+ # @return [Boolean] Returns True if it succeeds otherwise False.
213
214
  def delete(name)
214
215
  configure ["interface #{name}", 'no switchport']
215
216
  end
216
217
 
217
218
  ##
218
- # Defaults a logical switchport interface in the running-config
219
+ # Defaults a logical switchport interface in the running-config.
219
220
  #
220
- # @param [String] name The name of the logical interface
221
+ # @param name [String] The name of the logical interface.
221
222
  #
222
- # @return [Boolean] True if it succeeds otherwise False
223
+ # @return [Boolean] Returns True if it succeeds otherwise False.
223
224
  def default(name)
224
225
  configure ["interface #{name}", 'default switchport']
225
226
  end
@@ -227,14 +228,18 @@ module Rbeapi
227
228
  ##
228
229
  # Configures the switchport mode for the specified interface.
229
230
  #
230
- # @param [String] name The name of the interface to configure
231
- # @param [Hash] opts The configuration parameters for the interface
232
- # @option opts [string] :value The value to set the mode to
233
- # @option opts [Boolean] :enable If false then the command is
231
+ # @param name [String] The name of the interface to configure.
232
+ #
233
+ # @param opts [Hash] The configuration parameters for the interface.
234
+ #
235
+ # @option opts value [string] The value to set the mode to.
236
+ #
237
+ # @option opts enable [Boolean] If false then the command is
234
238
  # negated. Default is true.
235
- # @option opts [Boolean] :default The value should be set to default
236
239
  #
237
- # @return [Boolean] True if the commands succeed otherwise False
240
+ # @option opts default [Boolean] The value should be set to default.
241
+ #
242
+ # @return [Boolean] Returns True if the commands succeed otherwise False.
238
243
  def set_mode(name, opts = {})
239
244
  cmd = command_builder('switchport mode', opts)
240
245
  configure_interface(name, cmd)
@@ -242,31 +247,35 @@ module Rbeapi
242
247
 
243
248
  ##
244
249
  # set_trunk_allowed_vlans configures the list of vlan ids that are
245
- # allowed on the specified trunk port. If the enable option is set to
250
+ # allowed on the specified trunk port. If the enable option is set to
246
251
  # false, then the allowed trunks is configured using the no keyword.
247
252
  # If the default keyword is provided then the allowed trunks is configured
248
- # using the default keyword The default option takes precedence over the
249
- # enable option if both are specified
253
+ # using the default keyword. The default option takes precedence over the
254
+ # enable option if both are specified.
250
255
  #
251
- # @eos_version 4.13.7M
256
+ # @since eos_version 4.13.7M
252
257
  #
253
- # @commands
258
+ # ===Commands
254
259
  # switchport trunk allowed vlan add <value>
255
260
  # no switchport trunk allowed vlan
256
261
  # default switchport trunk allowed vlan
257
262
  #
258
- # @param [String] name The name of the interface to configure
259
- # @param [Hash] opts The configuration parameters for the interface
260
- # @option pts [Array] :value The list of vlan ids to configure on the
261
- # switchport to be allowed. This value must be an array of valid vlan
262
- # ids
263
- # @option opts [Boolean] :enable If false then the command is
263
+ # @param name [String] The name of the interface to configure.
264
+ #
265
+ # @param opts [Hash] The configuration parameters for the interface.
266
+ #
267
+ # @option ots value [Array] The list of vlan ids to configure on the
268
+ # switchport to be allowed. This value must be an array of valid vlan
269
+ # ids.
270
+ #
271
+ # @option opts enable [Boolean] If false then the command is
264
272
  # negated. Default is true.
265
- # @option [Boolean] :default Configures the switchport trunk allowed
273
+ #
274
+ # @option default [Boolean] Configures the switchport trunk allowed
266
275
  # vlans command using the default keyword. Default takes precedence
267
276
  # over enable.
268
277
  #
269
- # @return [Boolean] returns true if the commands complete successfully
278
+ # @return [Boolean] Returns true if the commands complete successfully.
270
279
  def set_trunk_allowed_vlans(name, opts = {})
271
280
  value = opts[:value]
272
281
  enable = opts.fetch(:enable, true)
@@ -296,15 +305,19 @@ module Rbeapi
296
305
  # This value is only valid if the switchport mode is configure as
297
306
  # trunk.
298
307
  #
299
- # @param [String] name The name of the interface to configure
300
- # @param [Hash] opts The configuration parameters for the interface
301
- # @option opts [string] :value The value of the trunk native vlan
302
- # @option :opts [Boolean] :enable If false then the command is
308
+ # @param name [String] The name of the interface to configure.
309
+ #
310
+ # @param opts [Hash] The configuration parameters for the interface.
311
+ #
312
+ # @option opts value [string] The value of the trunk native vlan.
313
+ #
314
+ # @option opts enable [Boolean] If false then the command is
303
315
  # negated. Default is true.
304
- # @option opts [Boolean] :default The value should be set to default.
316
+ #
317
+ # @option opts default [Boolean] The value should be set to default.
305
318
  # Default takes precedence over enable.
306
319
  #
307
- # @return [Boolean] True if the commands succeed otherwise False
320
+ # @return [Boolean] Returns True if the commands succeed otherwise False.
308
321
  def set_trunk_native_vlan(name, opts = {})
309
322
  cmd = command_builder('switchport trunk native vlan', opts)
310
323
  configure_interface(name, cmd)
@@ -315,15 +328,19 @@ module Rbeapi
315
328
  # This value is only valid if the switchport mode is configure
316
329
  # in access mode.
317
330
  #
318
- # @param [String] name The name of the interface to configure
319
- # @param [Hash] opts The configuration parameters for the interface
320
- # @option opts [string] :value The value of the access vlan
321
- # @option opts [Boolean] :enable If false then the command is
331
+ # @param name [String] The name of the interface to configure.
332
+ #
333
+ # @param opts [Hash] The configuration parameters for the interface.
334
+ #
335
+ # @option opts value [string] The value of the access vlan.
336
+ #
337
+ # @option opts enable [Boolean] If false then the command is
322
338
  # negated. Default is true.
323
- # @option opts [Boolean] :default The value should be set to default
339
+ #
340
+ # @option opts default [Boolean] The value should be set to default
324
341
  # Default takes precedence over enable.
325
342
  #
326
- # @return [Boolean] True if the commands succeed otherwise False
343
+ # @return [Boolean] Returns True if the commands succeed otherwise False.
327
344
  def set_access_vlan(name, opts = {})
328
345
  cmd = command_builder('switchport access vlan', opts)
329
346
  configure_interface(name, cmd)
@@ -334,15 +351,19 @@ module Rbeapi
334
351
  # Trunk groups not currently set are added and trunk groups
335
352
  # currently configured but not in the passed in value array are removed.
336
353
  #
337
- # @param [String] name The name of the interface to configure
338
- # @param [Hash] opts The configuration parameters for the interface
339
- # @option opts [string] :value Set of values to configure the trunk group
340
- # @option opts [Boolean] :enable If false then the command is
354
+ # @param name [String] The name of the interface to configure.
355
+ #
356
+ # @param opts [Hash] The configuration parameters for the interface.
357
+ #
358
+ # @option opts value [string] Set of values to configure the trunk group.
359
+ #
360
+ # @option opts enable [Boolean] If false then the command is
341
361
  # negated. Default is true.
342
- # @option opts [Boolean] :default The value should be set to default
362
+ #
363
+ # @option opts default [Boolean] The value should be set to default
343
364
  # Default takes precedence over enable.
344
365
  #
345
- # @return [Boolean] True if the commands succeed otherwise False
366
+ # @return [Boolean] Returns True if the commands succeed otherwise False.
346
367
  def set_trunk_groups(name, opts = {})
347
368
  default = opts.fetch(:default, false)
348
369
  if default
@@ -361,12 +382,12 @@ module Rbeapi
361
382
  current_value = Set.new get(name)[:trunk_groups]
362
383
 
363
384
  cmds = []
364
- # Add trunk groups that are not currently in the list
385
+ # Add trunk groups that are not currently in the list.
365
386
  value.difference(current_value).each do |group|
366
387
  cmds << "switchport trunk group #{group}"
367
388
  end
368
389
 
369
- # Remove trunk groups that are not in the new list
390
+ # Remove trunk groups that are not in the new list.
370
391
  current_value.difference(value).each do |group|
371
392
  cmds << "no switchport trunk group #{group}"
372
393
  end
@@ -35,39 +35,47 @@ require 'rbeapi/api'
35
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 System class configures the node system services such as
42
- # hostname and domain name
42
+ # hostname and domain name.
43
43
  class System < Entity
44
+ def initialize(node)
45
+ super(node)
46
+ @banners_re = Regexp.new(/^banner\s+(login|motd)\s?$\n(.*?)$\nEOF$\n/m)
47
+ end
48
+
44
49
  ##
45
- # Returns the system settings for hostname and iprouting
50
+ # Returns the system settings for hostname, iprouting, and banners.
46
51
  #
47
52
  # @example
48
53
  # {
49
54
  # hostname: <string>,
50
- # iprouting: <boolean>
55
+ # iprouting: <boolean>,
56
+ # banner_motd: <string>,
57
+ # banner_login: <string>
51
58
  # }
52
59
  #
53
- # @return [Hash] A Ruby hash object that provides the system settings as
60
+ # @return [Hash] A Ruby hash object that provides the system settings as
54
61
  # key/value pairs.
55
62
  def get
56
63
  response = {}
57
64
  response.merge!(parse_hostname(config))
58
65
  response.merge!(parse_iprouting(config))
66
+ response.merge!(parse_banners(config))
59
67
  response
60
68
  end
61
69
 
62
70
  ##
63
- # parse_hostname parses hostname values from the provided config
71
+ # parse_hostname parses hostname values from the provided config.
64
72
  #
65
73
  # @api private
66
74
  #
67
- # @param [String] :config The configuration block returned
68
- # from the node's running configuration
75
+ # @param config [String] The configuration block returned
76
+ # from the node's running configuration.
69
77
  #
70
- # @return [Hash<Symbol, Object>] resource hash attribute
78
+ # @return [Hash<Symbol, Object>] The resource hash attribute.
71
79
  def parse_hostname(config)
72
80
  mdata = /(?<=^hostname\s)(.+)$/.match(config)
73
81
  { hostname: mdata.nil? ? '' : mdata[1] }
@@ -75,14 +83,14 @@ module Rbeapi
75
83
  private :parse_hostname
76
84
 
77
85
  ##
78
- # parse_iprouting parses ip routing from the provided config
86
+ # parse_iprouting parses ip routing from the provided config.
79
87
  #
80
88
  # @api private
81
89
  #
82
- # @param [String] :config The configuration block returned
83
- # from the node's running configuration
90
+ # @param config [String] The configuration block returned
91
+ # from the node's running configuration.
84
92
  #
85
- # @return [Hash<Symbol, Object>] resource hash attribute
93
+ # @return [Hash<Symbol, Object>] The resource hash attribute.
86
94
  def parse_iprouting(config)
87
95
  mdata = /no\sip\srouting/.match(config)
88
96
  { iprouting: mdata.nil? ? true : false }
@@ -90,34 +98,94 @@ module Rbeapi
90
98
  private :parse_iprouting
91
99
 
92
100
  ##
93
- # Configures the system hostname value in the running-config
101
+ # Parses the global config and returns the value for both motd
102
+ # and login banners.
103
+ #
104
+ # @api private
94
105
  #
95
- # @param [Hash] opts The configuration parameters
96
- # @option opts [string] :value The value to set the hostname to
97
- # @option :opts [Boolean] :enable If false then the command is
106
+ # @param config [String] The configuration block returned
107
+ # from the node's running configuration.
108
+ #
109
+ # @return [Hash<Symbol, Object>] The resource hash attribute. If the
110
+ # banner is not set it will return a value of None for that key.
111
+ def parse_banners(config)
112
+ motd_value = login_value = ''
113
+ entries = config.scan(@banners_re)
114
+ entries.each do |type, value|
115
+ if type == 'motd'
116
+ motd_value = value
117
+ elsif type == 'login'
118
+ login_value = value
119
+ end
120
+ end
121
+ { banner_motd: motd_value, banner_login: login_value }
122
+ end
123
+ private :parse_banners
124
+
125
+ ##
126
+ # Configures the system hostname value in the running-config.
127
+ #
128
+ # @param opts [Hash] The configuration parameters.
129
+ #
130
+ # @option opts value [string] The value to set the hostname to.
131
+ #
132
+ # @option opts enable [Boolean] If false then the command is
98
133
  # negated. Default is true.
99
- # @option opts [Boolean] :default The value should be set to default
100
134
  #
101
- # @return [Boolean] returns true if the command completed successfully
135
+ # @option opts default [Boolean] If true configure the command using
136
+ # the default keyword. Default is false.
137
+ #
138
+ # @return [Boolean] Returns true if the command completed successfully.
102
139
  def set_hostname(opts = {})
103
140
  cmd = command_builder('hostname', opts)
104
141
  configure(cmd)
105
142
  end
106
143
 
107
144
  ##
108
- # Configures the state of global ip routing
145
+ # Configures the state of global ip routing.
146
+ #
147
+ # @param opts [Hash] The configuration parameters.
109
148
  #
110
- # @param [Hash] opts The configuration parameters
111
- # @option :opts [Boolean] :enable True if ip routing should be enabled
149
+ # @option opts enable [Boolean] True if ip routing should be enabled
112
150
  # or False if ip routing should be disabled. Default is true.
113
- # @option opts [Boolean] :default Controls the use of the default
114
- # keyword. Default is false.
115
151
  #
116
- # @return [Boolean] returns true if the command completed successfully
152
+ # @option opts default [Boolean] If true configure the command using
153
+ # the default keyword. Default is false.
154
+ #
155
+ # @return [Boolean] Returns true if the command completed successfully.
117
156
  def set_iprouting(opts = {})
118
157
  cmd = command_builder('ip routing', opts)
119
158
  configure(cmd)
120
159
  end
160
+
161
+ ##
162
+ # Configures system banners.
163
+ #
164
+ # @param banner_type [String] Banner to be changed (likely either
165
+ # login or motd).
166
+ #
167
+ # @param opts [Hash] The configuration parameters.
168
+ #
169
+ # @option opts value [string] The value to set for the banner.
170
+ #
171
+ # @option opts enable [Boolean] If false then the command is
172
+ # negated. Default is true.
173
+ #
174
+ # @option opts default [Boolean] If true configure the command using
175
+ # the default keyword. Default is false.
176
+ #
177
+ # @return [Boolean] Returns true if the command completed successfully.
178
+ def set_banner(banner_type, opts = {})
179
+ value = opts[:value]
180
+ cmd_string = "banner #{banner_type}"
181
+ if value
182
+ value += "\n" if value[-1, 1] != "\n"
183
+ cmd = [{ cmd: cmd_string, input: value }]
184
+ else
185
+ cmd = command_builder(cmd_string, opts)
186
+ end
187
+ configure(cmd)
188
+ end
121
189
  end
122
190
  end
123
191
  end