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.
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +17 -12
- data/guide/.gitignore +2 -0
- data/guide/api.rst +5894 -0
- data/guide/conf.py +5 -5
- data/guide/contributing.rst +6 -0
- data/guide/getting-started.rst +134 -0
- data/guide/index.rst +3 -5
- data/guide/installation.rst +56 -1
- data/guide/license.rst +13 -2
- data/guide/overview.rst +2 -5
- data/guide/testing.rst +5 -1
- data/guide/upgrading.rst +10 -0
- data/lib/rbeapi/api.rb +37 -36
- data/lib/rbeapi/api/aaa.rb +90 -90
- data/lib/rbeapi/api/acl.rb +70 -53
- data/lib/rbeapi/api/bgp.rb +186 -163
- data/lib/rbeapi/api/dns.rb +51 -45
- data/lib/rbeapi/api/interfaces.rb +344 -328
- data/lib/rbeapi/api/ipinterfaces.rb +92 -92
- data/lib/rbeapi/api/logging.rb +32 -32
- data/lib/rbeapi/api/mlag.rb +97 -97
- data/lib/rbeapi/api/ntp.rb +39 -39
- data/lib/rbeapi/api/ospf.rb +58 -58
- data/lib/rbeapi/api/prefixlists.rb +22 -22
- data/lib/rbeapi/api/radius.rb +77 -49
- data/lib/rbeapi/api/routemaps.rb +110 -64
- data/lib/rbeapi/api/snmp.rb +104 -100
- data/lib/rbeapi/api/staticroutes.rb +27 -20
- data/lib/rbeapi/api/stp.rb +100 -84
- data/lib/rbeapi/api/switchports.rb +98 -77
- data/lib/rbeapi/api/system.rb +93 -25
- data/lib/rbeapi/api/tacacs.rb +54 -35
- data/lib/rbeapi/api/users.rb +68 -68
- data/lib/rbeapi/api/varp.rb +56 -47
- data/lib/rbeapi/api/vlans.rb +86 -86
- data/lib/rbeapi/api/vrrp.rb +210 -173
- data/lib/rbeapi/client.rb +142 -108
- data/lib/rbeapi/eapilib.rb +73 -62
- data/lib/rbeapi/utils.rb +8 -8
- data/lib/rbeapi/version.rb +2 -2
- data/spec/fixtures/test.conf +3 -3
- data/spec/system/rbeapi/api/system_spec.rb +46 -2
- data/spec/system/rbeapi/api/vlans_spec.rb +5 -2
- data/spec/system/rbeapi/client_spec.rb +4 -4
- data/spec/unit/rbeapi/api/system/default_spec.rb +40 -4
- data/spec/unit/rbeapi/api/system/fixture_system.text +14 -0
- data/spec/unit/rbeapi/api/vlans/default_spec.rb +1 -1
- data/spec/unit/rbeapi/api/vlans/fixture_vlans.text +2 -0
- data/spec/unit/rbeapi/client_spec.rb +1 -0
- metadata +9 -9
- data/guide/cookbook.rst +0 -4
- data/guide/developing.rst +0 -4
- data/guide/faq.rst +0 -4
- data/guide/quickstart.rst +0 -4
- data/guide/troubleshooting.rst +0 -1
data/lib/rbeapi/api/routemaps.rb
CHANGED
@@ -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 Routemaps class manages routemaps. A route map is a list of rules
|
@@ -47,7 +47,7 @@ module Rbeapi
|
|
47
47
|
#
|
48
48
|
class Routemaps < Entity
|
49
49
|
##
|
50
|
-
# get returns a hash of routemap configurations for the given name
|
50
|
+
# get returns a hash of routemap configurations for the given name.
|
51
51
|
#
|
52
52
|
# @example
|
53
53
|
# {
|
@@ -81,12 +81,12 @@ module Rbeapi
|
|
81
81
|
# }
|
82
82
|
# }
|
83
83
|
#
|
84
|
-
# @param [String]
|
85
|
-
# the nodes configuration
|
84
|
+
# @param name [String] The routemap name to return a resource for from
|
85
|
+
# the nodes configuration.
|
86
86
|
#
|
87
87
|
# @return [nil, Hash<Symbol, Object>] Returns the routemap resource as a
|
88
88
|
# Hash. If the specified name is not found in the nodes current
|
89
|
-
# configuration a nil object is returned
|
89
|
+
# configuration a nil object is returned.
|
90
90
|
def get(name)
|
91
91
|
parse_entries(name)
|
92
92
|
end
|
@@ -160,8 +160,8 @@ module Rbeapi
|
|
160
160
|
# }
|
161
161
|
# }
|
162
162
|
#
|
163
|
-
# @return [nil, Hash<Symbol, Object>]
|
164
|
-
# entire routemap collection from the nodes running configuration.
|
163
|
+
# @return [nil, Hash<Symbol, Object>] Returns a hash that represents the
|
164
|
+
# entire routemap collection from the nodes running configuration. If
|
165
165
|
# there are no routemap names configured, this method will return nil.
|
166
166
|
def getall
|
167
167
|
routemaps = config.scan(/(?<=^route-map\s)[^\s]+/)
|
@@ -176,8 +176,10 @@ module Rbeapi
|
|
176
176
|
#
|
177
177
|
# @api private
|
178
178
|
#
|
179
|
-
# @
|
180
|
-
#
|
179
|
+
# @param name [String] The routemap name.
|
180
|
+
#
|
181
|
+
# @return [nil, Hash<Symbol, Object>] Returns a hash that represents the
|
182
|
+
# rules for routemaps from the nodes running configuration. If
|
181
183
|
# there are no routemaps configured, this method will return nil.
|
182
184
|
def parse_entries(name)
|
183
185
|
entries = config.scan(/^route-map\s#{name}\s.+$/)
|
@@ -199,10 +201,20 @@ module Rbeapi
|
|
199
201
|
#
|
200
202
|
# @api private
|
201
203
|
#
|
202
|
-
# @
|
203
|
-
#
|
204
|
+
# @param rules [Hash] Rules configuration options.
|
205
|
+
#
|
206
|
+
# @option rules match [Array] The match options.
|
207
|
+
#
|
208
|
+
# @option rules set [Array] The set options.
|
209
|
+
#
|
210
|
+
# @option rules continue [String] The continue value.
|
211
|
+
#
|
212
|
+
# @option rules description [String] The description value.
|
213
|
+
#
|
214
|
+
# @return [Hash<Symbol, Object>] Returns a hash that represents the
|
215
|
+
# rules for routemaps from the nodes running configuration. If
|
204
216
|
# there are no routemaps configured, this method will return an empty
|
205
|
-
#
|
217
|
+
# hash.
|
206
218
|
def parse_rules(rules)
|
207
219
|
rules.split("\n").each_with_object({}) do |rule, rule_hsh|
|
208
220
|
mdata = /\s{3}(\w+)\s/.match(rule)
|
@@ -225,7 +237,21 @@ module Rbeapi
|
|
225
237
|
private :parse_rules
|
226
238
|
|
227
239
|
##
|
228
|
-
# name_commands is utilized to initially prepare the routemap
|
240
|
+
# name_commands is utilized to initially prepare the routemap.
|
241
|
+
#
|
242
|
+
# @param name [String] The routemap name.
|
243
|
+
#
|
244
|
+
# @param action [String] The action value.
|
245
|
+
#
|
246
|
+
# @param seqno [String] The seqno value.
|
247
|
+
#
|
248
|
+
# @param opts [Hash] The configuration options.
|
249
|
+
#
|
250
|
+
# @option opts default [Boolean] The default value.
|
251
|
+
#
|
252
|
+
# @option opts enable [Boolean] The enable value.
|
253
|
+
#
|
254
|
+
# @return [Array] Returns the prepared eos command.
|
229
255
|
def name_commands(name, action, seqno, opts = {})
|
230
256
|
if opts[:default] == true
|
231
257
|
cmd = "default route-map #{name}"
|
@@ -245,35 +271,35 @@ module Rbeapi
|
|
245
271
|
#
|
246
272
|
# rubocop:disable Metrics/MethodLength
|
247
273
|
#
|
248
|
-
#
|
274
|
+
# ===Commands
|
249
275
|
# route-map <name> action <value> seqno <value> description <value>
|
250
276
|
# match <value> set <value> continue <value>
|
251
277
|
#
|
252
|
-
# @param [String]
|
278
|
+
# @param name [String] The name of the routemap to create.
|
253
279
|
#
|
254
|
-
# @param [String]
|
280
|
+
# @param action [String] Either permit or deny.
|
255
281
|
#
|
256
|
-
# @param [Integer]
|
282
|
+
# @param seqno [Integer] The sequence number value.
|
257
283
|
#
|
258
|
-
# @param [hash]
|
284
|
+
# @param opts [hash] Optional keyword arguments.
|
259
285
|
#
|
260
|
-
# @option
|
286
|
+
# @option opts default [Boolean] Set routemap to default.
|
261
287
|
#
|
262
|
-
# @option
|
288
|
+
# @option opts description [String] A description for the routemap.
|
263
289
|
#
|
264
|
-
# @option
|
290
|
+
# @option opts match [Array] routemap match rule.
|
265
291
|
#
|
266
|
-
# @option
|
292
|
+
# @option opts set [String] Sets route attribute.
|
267
293
|
#
|
268
|
-
# @option
|
294
|
+
# @option opts continue [String] The routemap sequence number to
|
269
295
|
# continue on.
|
270
296
|
#
|
271
|
-
# @option
|
297
|
+
# @option opts enable [Boolean] If false then the command is
|
272
298
|
# negated. Default is true.
|
273
299
|
#
|
274
|
-
# @option
|
300
|
+
# @option opts default [Boolean] Configure the routemap to default.
|
275
301
|
#
|
276
|
-
# @return [Boolean]
|
302
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
277
303
|
def create(name, action, seqno, opts = {})
|
278
304
|
if opts.empty?
|
279
305
|
cmds = name_commands(name, action, seqno)
|
@@ -306,6 +332,16 @@ module Rbeapi
|
|
306
332
|
##
|
307
333
|
# remove_match_statemements removes all match rules for the
|
308
334
|
# specified routemap
|
335
|
+
#
|
336
|
+
# @param name [String] The routemap name.
|
337
|
+
#
|
338
|
+
# @param action [String] The action value.
|
339
|
+
#
|
340
|
+
# @param seqno [String] The seqno value.
|
341
|
+
#
|
342
|
+
# @param cmds [Array] Array of eos commands.
|
343
|
+
#
|
344
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
309
345
|
def remove_match_statements(name, action, seqno, cmds)
|
310
346
|
entries = parse_entries(name)
|
311
347
|
return nil unless entries
|
@@ -322,6 +358,16 @@ module Rbeapi
|
|
322
358
|
##
|
323
359
|
# remove_set_statemements removes all set rules for the
|
324
360
|
# specified routemap
|
361
|
+
#
|
362
|
+
# @param name [String] The routemap name.
|
363
|
+
#
|
364
|
+
# @param action [String] The action value.
|
365
|
+
#
|
366
|
+
# @param seqno [String] The seqno value.
|
367
|
+
#
|
368
|
+
# @param cmds [Array] Array of eos commands.
|
369
|
+
#
|
370
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
325
371
|
def remove_set_statements(name, action, seqno, cmds)
|
326
372
|
entries = parse_entries(name)
|
327
373
|
return nil unless entries
|
@@ -340,16 +386,16 @@ module Rbeapi
|
|
340
386
|
# running configuration. If the delete method is called and the
|
341
387
|
# routemap name does not exist, this method will succeed.
|
342
388
|
#
|
343
|
-
#
|
389
|
+
# ===Commands
|
344
390
|
# no route-map <name> <action> <seqno>
|
345
391
|
#
|
346
|
-
# @param [String]
|
392
|
+
# @param name [String] The routemap name to delete from the node.
|
347
393
|
#
|
348
|
-
# @param [String]
|
394
|
+
# @param action [String] Either permit or deny.
|
349
395
|
#
|
350
|
-
# @param [Integer]
|
396
|
+
# @param seqno [Integer] The sequence number.
|
351
397
|
#
|
352
|
-
# @return [Boolean]
|
398
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
353
399
|
def delete(name, action, seqno)
|
354
400
|
configure(["no route-map #{name} #{action} #{seqno}"])
|
355
401
|
end
|
@@ -358,20 +404,20 @@ module Rbeapi
|
|
358
404
|
# This method will attempt to default the routemap from the nodes
|
359
405
|
# operational config. Since routemaps do not exist by default,
|
360
406
|
# the default action is essentially a negation and the result will
|
361
|
-
# be the removal of the routemap clause.
|
362
|
-
#
|
363
|
-
#
|
407
|
+
# be the removal of the routemap clause. If the routemap does not
|
408
|
+
# exist then this method will not perform any changes but still
|
409
|
+
# return True.
|
364
410
|
#
|
365
|
-
#
|
411
|
+
# ===Commands
|
366
412
|
# no route-map <name>
|
367
413
|
#
|
368
|
-
# @param [String]
|
414
|
+
# @param name [String] The routemap name to set to default.
|
369
415
|
#
|
370
|
-
# @param [String]
|
416
|
+
# @param action [String] Either permit or deny.
|
371
417
|
#
|
372
|
-
# @param [Integer]
|
418
|
+
# @param seqno [Integer] The sequence number.
|
373
419
|
#
|
374
|
-
# @return [Boolean]
|
420
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
375
421
|
def default(name, action, seqno)
|
376
422
|
configure(["default route-map #{name} #{action} #{seqno}"])
|
377
423
|
end
|
@@ -380,18 +426,18 @@ module Rbeapi
|
|
380
426
|
# set_match_statements will set the match values for a specified routemap.
|
381
427
|
# If the specified routemap does not exist, it will be created.
|
382
428
|
#
|
383
|
-
#
|
429
|
+
# ===Commands
|
384
430
|
# route-map <name> action <value> seqno <value> match <value>
|
385
431
|
#
|
386
|
-
# @param [String]
|
432
|
+
# @param name [String] The name of the routemap to create.
|
387
433
|
#
|
388
|
-
# @param [String]
|
434
|
+
# @param action [String] Either permit or deny.
|
389
435
|
#
|
390
|
-
# @param [Integer]
|
436
|
+
# @param seqno [Integer] The sequence number.
|
391
437
|
#
|
392
|
-
# @param [Array]
|
438
|
+
# @param value [Array] The routemap match rules.
|
393
439
|
#
|
394
|
-
# @return [Boolean]
|
440
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
395
441
|
def set_match_statements(name, action, seqno, value)
|
396
442
|
cmds = ["route-map #{name} #{action} #{seqno}"]
|
397
443
|
remove_match_statements(name, action, seqno, cmds)
|
@@ -405,18 +451,18 @@ module Rbeapi
|
|
405
451
|
# set_set_statements will set the set values for a specified routemap.
|
406
452
|
# If the specified routemap does not exist, it will be created.
|
407
453
|
#
|
408
|
-
#
|
454
|
+
# ===Commands
|
409
455
|
# route-map <name> action <value> seqno <value> set <value>
|
410
456
|
#
|
411
|
-
# @param [String]
|
457
|
+
# @param name [String] The name of the routemap to create.
|
412
458
|
#
|
413
|
-
# @param [String]
|
459
|
+
# @param action [String] Either permit or deny.
|
414
460
|
#
|
415
|
-
# @param [Integer]
|
461
|
+
# @param seqno [Integer] The sequence number.
|
416
462
|
#
|
417
|
-
# @param [Array]
|
463
|
+
# @param value [Array] The routemap set rules.
|
418
464
|
#
|
419
|
-
# @return [Boolean]
|
465
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
420
466
|
def set_set_statements(name, action, seqno, value)
|
421
467
|
cmds = ["route-map #{name} #{action} #{seqno}"]
|
422
468
|
remove_set_statements(name, action, seqno, cmds)
|
@@ -430,18 +476,18 @@ module Rbeapi
|
|
430
476
|
# set_continue will set the continue value for a specified routemap.
|
431
477
|
# If the specified routemap does not exist, it will be created.
|
432
478
|
#
|
433
|
-
#
|
479
|
+
# ===Commands
|
434
480
|
# route-map <name> action <value> seqno <value> continue <value>
|
435
481
|
#
|
436
|
-
# @param [String]
|
482
|
+
# @param name [String] The name of the routemap to create.
|
437
483
|
#
|
438
|
-
# @param [String]
|
484
|
+
# @param action [String] Either permit or deny.
|
439
485
|
#
|
440
|
-
# @param [Integer]
|
486
|
+
# @param seqno [Integer] The sequence number.
|
441
487
|
#
|
442
|
-
# @param [Integer]
|
488
|
+
# @param value [Integer] The continue value.
|
443
489
|
#
|
444
|
-
# @return [Boolean]
|
490
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
445
491
|
def set_continue(name, action, seqno, value)
|
446
492
|
cmds = ["route-map #{name} #{action} #{seqno}"]
|
447
493
|
cmds << 'no continue'
|
@@ -453,18 +499,18 @@ module Rbeapi
|
|
453
499
|
# set_description will set the description for a specified routemap.
|
454
500
|
# If the specified routemap does not exist, it will be created.
|
455
501
|
#
|
456
|
-
#
|
502
|
+
# ===Commands
|
457
503
|
# route-map <name> action <value> seqno <value> description <value>
|
458
504
|
#
|
459
|
-
# @param [String]
|
505
|
+
# @param name [String] The name of the routemap to create.
|
460
506
|
#
|
461
|
-
# @param [String]
|
507
|
+
# @param action [String] Either permit or deny.
|
462
508
|
#
|
463
|
-
# @param [Integer]
|
509
|
+
# @param seqno [Integer] The sequence number.
|
464
510
|
#
|
465
|
-
# @param [String]
|
511
|
+
# @param value [String] The description value.
|
466
512
|
#
|
467
|
-
# @return [Boolean]
|
513
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
468
514
|
def set_description(name, action, seqno, value)
|
469
515
|
cmds = ["route-map #{name} #{action} #{seqno}"]
|
470
516
|
cmds << 'no description'
|
data/lib/rbeapi/api/snmp.rb
CHANGED
@@ -32,17 +32,17 @@
|
|
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 Snmp class provides a class implementation for working with the
|
42
|
-
# nodes SNMP configuration entity.
|
42
|
+
# nodes SNMP configuration entity. This class presents an abstraction
|
43
43
|
# of the node's snmp configuration from the running config.
|
44
44
|
#
|
45
|
-
# @eos_version 4.13.7M
|
45
|
+
# @since eos_version 4.13.7M
|
46
46
|
class Snmp < Entity
|
47
47
|
DEFAULT_SNMP_LOCATION = ''
|
48
48
|
DEFAULT_SNMP_CONTACT = ''
|
@@ -63,7 +63,7 @@ module Rbeapi
|
|
63
63
|
# source_interface: <string>
|
64
64
|
# }
|
65
65
|
#
|
66
|
-
# @return[Hash<Symbol, Object>] Returns the snmp resource as a Hash
|
66
|
+
# @return[Hash<Symbol, Object>] Returns the snmp resource as a Hash.
|
67
67
|
def get
|
68
68
|
response = {}
|
69
69
|
response.merge!(parse_location)
|
@@ -77,14 +77,14 @@ module Rbeapi
|
|
77
77
|
|
78
78
|
##
|
79
79
|
# parse_location scans the running config from the node and parses
|
80
|
-
# the snmp location value if it exists in the configuration.
|
80
|
+
# the snmp location value if it exists in the configuration. If the
|
81
81
|
# snmp location is not configure, then the DEFAULT_SNMP_LOCATION string
|
82
|
-
# is returned.
|
82
|
+
# is returned. The Hash returned by this method is merged into the
|
83
83
|
# snmp resource Hash returned by the get method.
|
84
84
|
#
|
85
85
|
# @api private
|
86
86
|
#
|
87
|
-
# @return [Hash<Symbol,Object>] resource Hash attribute
|
87
|
+
# @return [Hash<Symbol,Object>] Returns the resource Hash attribute.
|
88
88
|
def parse_location
|
89
89
|
mdata = /snmp-server location (.+)$/.match(config)
|
90
90
|
{ location: mdata.nil? ? DEFAULT_SNMP_LOCATION : mdata[1] }
|
@@ -93,14 +93,14 @@ module Rbeapi
|
|
93
93
|
|
94
94
|
##
|
95
95
|
# parse_contact scans the running config form the node and parses
|
96
|
-
# the snmp contact value if it exists in the configuration.
|
96
|
+
# the snmp contact value if it exists in the configuration. If the
|
97
97
|
# snmp contact is not configured, then the DEFAULT_SNMP_CONTACT value
|
98
|
-
# is returned.
|
98
|
+
# is returned. The Hash returned by this method is merged into the
|
99
99
|
# snmp resource Hash returned by the get method.
|
100
100
|
#
|
101
101
|
# @api private
|
102
102
|
#
|
103
|
-
# @return [Hash<Symbol,Object] resource Hash attribute
|
103
|
+
# @return [Hash<Symbol,Object] Returns the resource Hash attribute.
|
104
104
|
def parse_contact
|
105
105
|
mdata = /snmp-server contact (.+)$/.match(config)
|
106
106
|
{ contact: mdata.nil? ? DEFAULT_SNMP_CONTACT : mdata[1] }
|
@@ -109,14 +109,14 @@ module Rbeapi
|
|
109
109
|
|
110
110
|
##
|
111
111
|
# parse_chassis_id scans the running config from the node and parses
|
112
|
-
# the snmp chassis id value if it exists in the configuration.
|
112
|
+
# the snmp chassis id value if it exists in the configuration. If the
|
113
113
|
# snmp chassis id is not configured, then the DEFAULT_SNMP_CHASSIS_ID
|
114
|
-
# value is returned.
|
115
|
-
# be merged into the snmp resource Hash
|
114
|
+
# value is returned. The Hash returned by this method is intended to
|
115
|
+
# be merged into the snmp resource Hash.
|
116
116
|
#
|
117
117
|
# @api private
|
118
118
|
#
|
119
|
-
# @return [Hash<Symbol,Object>] resource Hash attribute
|
119
|
+
# @return [Hash<Symbol,Object>] Returns the resource Hash attribute.
|
120
120
|
def parse_chassis_id
|
121
121
|
mdata = /snmp-server chassis-id (.+)$/.match(config)
|
122
122
|
{ chassis_id: mdata.nil? ? DEFAULT_SNMP_CHASSIS_ID : mdata[1] }
|
@@ -126,14 +126,14 @@ module Rbeapi
|
|
126
126
|
##
|
127
127
|
# parse_source_interface scans the running config from the node and
|
128
128
|
# parses the snmp source interface value if it exists in the
|
129
|
-
# configuration.
|
130
|
-
# the DEFAULT_SNMP_SOURCE_INTERFACE value is returned.
|
129
|
+
# configuration. If the snmp source interface is not configured, then
|
130
|
+
# the DEFAULT_SNMP_SOURCE_INTERFACE value is returned. The Hash
|
131
131
|
# returned by this method is intended to be merged into the snmmp
|
132
|
-
# resource Hash
|
132
|
+
# resource Hash.
|
133
133
|
#
|
134
134
|
# @api private
|
135
135
|
#
|
136
|
-
# @return [Hash<Symbol, Object>] resource Hash attribute
|
136
|
+
# @return [Hash<Symbol, Object>] Returns the resource Hash attribute.
|
137
137
|
def parse_source_interface
|
138
138
|
mdata = /snmp-server source-interface (.+)$/.match(config)
|
139
139
|
{ source_interface: mdata.nil? ? '' : mdata[1] }
|
@@ -142,14 +142,14 @@ module Rbeapi
|
|
142
142
|
|
143
143
|
##
|
144
144
|
# parse_communities scans the running config from the node and parses all
|
145
|
-
# of the configure snmp community strings.
|
145
|
+
# of the configure snmp community strings. If there are no configured
|
146
146
|
# snmp community strings, the community value is set to an empty array.
|
147
147
|
# The returned hash is intended to be merged into the global snmp
|
148
|
-
# resource hash
|
148
|
+
# resource hash.
|
149
149
|
#
|
150
150
|
# @api private
|
151
151
|
#
|
152
|
-
# @return [Hash<Hash>] resource hash attribute
|
152
|
+
# @return [Hash<Hash>] Returns the resource hash attribute.
|
153
153
|
def parse_communities
|
154
154
|
values = config.scan(/snmp-server community (\w+) (ro|rw)[ ]?(.+)?$/)
|
155
155
|
communities = values.each_with_object({}) do |value, hsh|
|
@@ -162,9 +162,9 @@ module Rbeapi
|
|
162
162
|
|
163
163
|
##
|
164
164
|
# parse_notifications scans the running configuration and parses all of
|
165
|
-
# the snmp trap notifications configuration.
|
166
|
-
# configuration is in the running config.
|
167
|
-
# to be merged into the resource hash
|
165
|
+
# the snmp trap notifications configuration. It is expected the trap
|
166
|
+
# configuration is in the running config. The returned hash is intended
|
167
|
+
# to be merged into the resource hash.
|
168
168
|
def parse_notifications
|
169
169
|
traps = config.scan(/(default|no)?[ ]?snmp-server enable traps (.+)$/)
|
170
170
|
all = config.scan(/(default|no)?[ ]?snmp-server enable traps$/).first
|
@@ -180,24 +180,26 @@ module Rbeapi
|
|
180
180
|
|
181
181
|
##
|
182
182
|
# set_notification configures the snmp trap notification for the
|
183
|
-
# specified trap.
|
183
|
+
# specified trap. The name option accepts the snmp trap name to
|
184
184
|
# configure or the keyword all to globally enable or disable
|
185
|
-
# notifications.
|
185
|
+
# notifications. If the optional state argument is not provided then the
|
186
186
|
# default state is default.
|
187
187
|
#
|
188
|
-
# @eos_version 4.13.7M
|
188
|
+
# @since eos_version 4.13.7M
|
189
189
|
#
|
190
|
-
#
|
190
|
+
# ===Commands
|
191
191
|
# snmp-server enable traps <name>
|
192
192
|
# no snmp-server enable traps <name>
|
193
193
|
# default snmp-server enable traps <name>
|
194
194
|
#
|
195
|
-
# @param [
|
196
|
-
# all. If this option is not specified, then the value of 'all' is
|
197
|
-
# used as the default.
|
195
|
+
# @param opts [Hash] The configuration parameters.
|
198
196
|
#
|
199
|
-
# @
|
200
|
-
#
|
197
|
+
# @option opts name [String] The name of the trap to configure or the
|
198
|
+
# keyword all. If this option is not specified, then the value of
|
199
|
+
# 'all' is used as the default.
|
200
|
+
#
|
201
|
+
# @option opts state [String] The state to configure the trap
|
202
|
+
# notification. Valid values include 'on', 'off' or 'default'.
|
201
203
|
def set_notification(opts = {})
|
202
204
|
name = opts[:name]
|
203
205
|
name = nil if name == 'all'
|
@@ -208,29 +210,29 @@ module Rbeapi
|
|
208
210
|
|
209
211
|
##
|
210
212
|
# set_location updates the snmp location value in the nodes running
|
211
|
-
# configuration.
|
212
|
-
# negated using the no keyword.
|
213
|
+
# configuration. If enable is false, then the snmp location value is
|
214
|
+
# negated using the no keyword. If the default keyword is set to true,
|
213
215
|
# then the snmp location value is defaulted using the default keyword.
|
214
216
|
# The default parameter takes precedence over the enable keyword.
|
215
217
|
#
|
216
|
-
# @eos_version 4.13.7M
|
218
|
+
# @since eos_version 4.13.7M
|
217
219
|
#
|
218
|
-
#
|
220
|
+
# ===Commands
|
219
221
|
# snmp-server location <value>
|
220
222
|
# no snmp-server location
|
221
223
|
# default snmp-server location
|
222
224
|
#
|
223
|
-
# @param [Hash]
|
225
|
+
# @param opts [Hash] The configuration parameters.
|
224
226
|
#
|
225
|
-
# @option opts [string]
|
227
|
+
# @option opts value [string] The snmp location value to configure.
|
226
228
|
#
|
227
|
-
# @option
|
229
|
+
# @option opts enable [Boolean] If false then the command is
|
228
230
|
# negated. Default is true.
|
229
231
|
#
|
230
|
-
# @option opts [Boolean]
|
231
|
-
# using the default keyword
|
232
|
+
# @option opts default [Boolean] Configure the snmp location value
|
233
|
+
# using the default keyword.
|
232
234
|
#
|
233
|
-
# @return [Boolean]
|
235
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
234
236
|
def set_location(opts = {})
|
235
237
|
cmd = command_builder('snmp-server location', opts)
|
236
238
|
configure(cmd)
|
@@ -238,30 +240,30 @@ module Rbeapi
|
|
238
240
|
|
239
241
|
##
|
240
242
|
# set_contact updates the snmp contact value in the nodes running
|
241
|
-
# configuration.
|
242
|
-
# the snmp contact value is negated using the no keyword.
|
243
|
+
# configuration. If enable is false in the opts Hash then
|
244
|
+
# the snmp contact value is negated using the no keyword. If the
|
243
245
|
# default keyword is set to true, then the snmp contact value is
|
244
|
-
# defaulted using the default keyword.
|
246
|
+
# defaulted using the default keyword. The default parameter takes
|
245
247
|
# precedence over the enable keyword.
|
246
248
|
#
|
247
|
-
# @eos_version 4.13.7M
|
249
|
+
# @since eos_version 4.13.7M
|
248
250
|
#
|
249
|
-
#
|
251
|
+
# ===Commands
|
250
252
|
# snmp-server contact <value>
|
251
253
|
# no snmp-server contact
|
252
254
|
# default snmp-server contact
|
253
255
|
#
|
254
|
-
# @param [Hash]
|
256
|
+
# @param opts [Hash] The configuration parameters.
|
255
257
|
#
|
256
|
-
# @option opts [string]
|
258
|
+
# @option opts value [string] The snmp contact value to configure.
|
257
259
|
#
|
258
|
-
# @option
|
260
|
+
# @option opts enable [Boolean] If false then the command is
|
259
261
|
# negated. Default is true.
|
260
262
|
#
|
261
|
-
# @option opts [Boolean]
|
262
|
-
# using the default keyword
|
263
|
+
# @option opts default [Boolean] Configures the snmp contact value
|
264
|
+
# using the default keyword.
|
263
265
|
#
|
264
|
-
# @return [Boolean]
|
266
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
265
267
|
def set_contact(opts = {})
|
266
268
|
cmd = command_builder('snmp-server contact', opts)
|
267
269
|
configure(cmd)
|
@@ -269,30 +271,30 @@ module Rbeapi
|
|
269
271
|
|
270
272
|
##
|
271
273
|
# set_chassis_id updates the snmp chassis id value in the nodes
|
272
|
-
# running configuration.
|
274
|
+
# running configuration. If enable is false in the opts
|
273
275
|
# Hash then the snmp chassis id value is negated using the no
|
274
|
-
# keyword.
|
275
|
-
# chassis id value is defaulted using the default keyword.
|
276
|
+
# keyword. If the default keyword is set to true, then the snmp
|
277
|
+
# chassis id value is defaulted using the default keyword. The default
|
276
278
|
# keyword takes precedence over the enable keyword.
|
277
279
|
#
|
278
|
-
# @eos_version 4.13.7M
|
280
|
+
# @since eos_version 4.13.7M
|
279
281
|
#
|
280
|
-
#
|
282
|
+
# ===Commands
|
281
283
|
# snmp-server chassis-id <value>
|
282
284
|
# no snmp-server chassis-id
|
283
285
|
# default snmp-server chassis-id
|
284
286
|
#
|
285
|
-
# @param [Hash]
|
287
|
+
# @param opts [Hash] The configuration parameters
|
286
288
|
#
|
287
|
-
# @option opts [string]
|
289
|
+
# @option opts value [string] The snmp chassis id value to configure
|
288
290
|
#
|
289
|
-
# @option
|
291
|
+
# @option opts enable [Boolean] If false then the command is
|
290
292
|
# negated. Default is true.
|
291
293
|
#
|
292
|
-
# @option opts [Boolean]
|
293
|
-
# using the default keyword
|
294
|
+
# @option opts default [Boolean] Configures the snmp chassis id value
|
295
|
+
# using the default keyword.
|
294
296
|
#
|
295
|
-
# @return [Boolean]
|
297
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
296
298
|
def set_chassis_id(opts = {})
|
297
299
|
cmd = command_builder('snmp-server chassis-id', opts)
|
298
300
|
configure(cmd)
|
@@ -300,30 +302,30 @@ module Rbeapi
|
|
300
302
|
|
301
303
|
##
|
302
304
|
# set_source_interface updates the snmp source interface value in the
|
303
|
-
# nodes running configuration.
|
305
|
+
# nodes running configuration. If enable is false in the opts
|
304
306
|
# Hash then the snmp source interface is negated using the no keyword.
|
305
307
|
# If the default keyword is set to true, then the snmp source interface
|
306
|
-
# value is defaulted using the default keyword.
|
308
|
+
# value is defaulted using the default keyword. The default keyword
|
307
309
|
# takes precedence over the enable keyword.
|
308
310
|
#
|
309
|
-
# @eos_version 4.13.7M
|
311
|
+
# @since eos_version 4.13.7M
|
310
312
|
#
|
311
|
-
#
|
313
|
+
# ===Commands
|
312
314
|
# snmp-server source-interface <value>
|
313
315
|
# no snmp-server source-interface
|
314
316
|
# default snmp-server source-interface
|
315
317
|
#
|
316
|
-
# @param [Hash]
|
318
|
+
# @param opts [Hash] The configuration parameters.
|
317
319
|
#
|
318
|
-
# @option opts [string]
|
319
|
-
# configure.
|
320
|
-
# in the configuration
|
321
|
-
# @option
|
320
|
+
# @option opts value [string] The snmp source interface value to
|
321
|
+
# configure. This method will not ensure the interface is present
|
322
|
+
# in the configuration.
|
323
|
+
# @option opts enable [Boolean] If false then the command is
|
322
324
|
# negated. Default is true.
|
323
|
-
# @option opts [Boolean]
|
324
|
-
# value using the default keyword
|
325
|
+
# @option opts default [Boolean] Configures the snmp source interface
|
326
|
+
# value using the default keyword.
|
325
327
|
#
|
326
|
-
# @return [Boolean]
|
328
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
327
329
|
def set_source_interface(opts = {})
|
328
330
|
cmd = command_builder('snmp-server source-interface', opts)
|
329
331
|
configure(cmd)
|
@@ -331,65 +333,67 @@ module Rbeapi
|
|
331
333
|
|
332
334
|
##
|
333
335
|
# add_community adds a new snmp community to the nodes running
|
334
|
-
# configuration.
|
336
|
+
# configuration. This function is a convenience function that passes the
|
335
337
|
# message to set_community_access.
|
336
338
|
#
|
337
339
|
# @see set_community_access
|
338
340
|
#
|
339
|
-
# @param [String]
|
341
|
+
# @param name [String] The name of the snmp community to add to the
|
340
342
|
# nodes running configuration.
|
341
343
|
#
|
342
|
-
# @param [String]
|
343
|
-
# new snmp community.
|
344
|
+
# @param access [String] Specifies the access level to assign to the
|
345
|
+
# new snmp community. Valid values are 'rw' or 'ro'.
|
344
346
|
#
|
345
|
-
# @return [Boolean]
|
347
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
346
348
|
def add_community(name, access = 'ro')
|
347
349
|
set_community_access(name, access)
|
348
350
|
end
|
349
351
|
|
350
352
|
##
|
351
353
|
# remove_community removes the specified community from the nodes running
|
352
|
-
# configuration.
|
354
|
+
# configuration. If the specified name is not configured, this method
|
353
355
|
# will still return successfully.
|
354
356
|
#
|
355
|
-
# @eos_version 4.13.7M
|
357
|
+
# @since eos_version 4.13.7M
|
356
358
|
#
|
357
|
-
#
|
359
|
+
# ===Commands
|
358
360
|
# no snmp-server community <name>
|
359
361
|
#
|
360
|
-
# @param [String]
|
362
|
+
# @param name [String] The name of the snmp community to add to the
|
361
363
|
# nodes running configuration.
|
362
364
|
#
|
363
|
-
# @return [Boolean]
|
365
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
364
366
|
def remove_community(name)
|
365
367
|
configure "no snmp-server community #{name}"
|
366
368
|
end
|
367
369
|
|
368
370
|
##
|
369
371
|
# set_community_acl configures the acl to apply to the specified
|
370
|
-
# community name.
|
372
|
+
# community name. When enable is true, it will remove the
|
371
373
|
# the named community and then add the new acl entry.
|
372
374
|
#
|
373
|
-
# @eos_version 4.13.7M
|
375
|
+
# @since eos_version 4.13.7M
|
374
376
|
#
|
375
|
-
#
|
377
|
+
# ===Commands
|
376
378
|
# no snmp-server <name> [ro|rw] <value>
|
377
379
|
# snmp-server <name> [ro|rw] <value>
|
378
380
|
#
|
379
|
-
# @param [String]
|
381
|
+
# @param name [String] The name of the snmp community to add to the
|
380
382
|
# nodes running configuration.
|
381
383
|
#
|
382
|
-
# @param [Hash]
|
384
|
+
# @param opts [Hash] The configuration parameters.
|
383
385
|
#
|
384
|
-
# @option opts [String]
|
386
|
+
# @option opts value [String] The name of the acl to apply to the snmp
|
385
387
|
# community in the nodes config. If nil, then the community name
|
386
388
|
# allows access to all objects.
|
387
|
-
#
|
389
|
+
#
|
390
|
+
# @option opts enable [Boolean] If false then the command is
|
388
391
|
# negated. Default is true.
|
389
|
-
#
|
392
|
+
#
|
393
|
+
# @option opts default [Boolean] Configure the snmp community name
|
390
394
|
# using the default keyword. Default takes precedence over enable.
|
391
395
|
#
|
392
|
-
# @return [Boolean]
|
396
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
393
397
|
def set_community_acl(name, opts = {})
|
394
398
|
value = opts[:value]
|
395
399
|
enable = opts.fetch(:enable, true)
|
@@ -407,11 +411,11 @@ module Rbeapi
|
|
407
411
|
# set_community_access configures snmp-server community with designated
|
408
412
|
# name and access values.
|
409
413
|
#
|
410
|
-
# @param [String]
|
414
|
+
# @param name [String] The snmp-server community name value.
|
411
415
|
#
|
412
|
-
# @param [String]
|
416
|
+
# @param access [String] The snmp-server community access value.
|
413
417
|
#
|
414
|
-
# @return [Boolean]
|
418
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
415
419
|
def set_community_access(name, access)
|
416
420
|
configure "snmp-server community #{name} #{access}"
|
417
421
|
end
|