rbeapi 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile +3 -1
- data/Guardfile +3 -3
- data/README.md +92 -17
- data/Rakefile +99 -4
- data/gems/README.rst +4 -0
- data/gems/inifile/.gitignore +2 -0
- data/gems/inifile/README.rst +5 -0
- data/gems/inifile/inifile.spec.tmpl +84 -0
- data/gems/net_http_unix/.gitignore +2 -0
- data/gems/net_http_unix/README.rst +5 -0
- data/gems/net_http_unix/net_http_unix.spec.tmpl +54 -0
- data/gems/netaddr/README.rst +5 -0
- data/gems/netaddr/netaddr.spec.tmpl +50 -0
- data/lib/rbeapi/api/aaa.rb +14 -17
- data/lib/rbeapi/api/acl.rb +276 -0
- data/lib/rbeapi/api/dns.rb +7 -4
- data/lib/rbeapi/api/interfaces.rb +239 -239
- data/lib/rbeapi/api/ipinterfaces.rb +5 -3
- data/lib/rbeapi/api/logging.rb +8 -5
- data/lib/rbeapi/api/mlag.rb +45 -127
- data/lib/rbeapi/api/ntp.rb +1 -4
- data/lib/rbeapi/api/ospf.rb +16 -13
- data/lib/rbeapi/api/prefixlists.rb +4 -4
- data/lib/rbeapi/api/radius.rb +34 -25
- data/lib/rbeapi/api/routemaps.rb +16 -10
- data/lib/rbeapi/api/snmp.rb +26 -13
- data/lib/rbeapi/api/staticroutes.rb +6 -5
- data/lib/rbeapi/api/stp.rb +77 -18
- data/lib/rbeapi/api/switchports.rb +20 -12
- data/lib/rbeapi/api/system.rb +6 -6
- data/lib/rbeapi/api/tacacs.rb +9 -6
- data/lib/rbeapi/api/varp.rb +15 -10
- data/lib/rbeapi/api/vlans.rb +5 -6
- data/lib/rbeapi/api.rb +56 -16
- data/lib/rbeapi/client.rb +85 -50
- data/lib/rbeapi/eapilib.rb +95 -56
- data/lib/rbeapi/netdev/snmp.rb +7 -16
- data/lib/rbeapi/utils.rb +3 -5
- data/lib/rbeapi/version.rb +1 -1
- data/rbeapi.gemspec +4 -2
- data/rbeapi.spec.tmpl +72 -0
- data/spec/support/fixtures.rb +6 -4
- data/spec/support/shared_examples_for_api_modules.rb +3 -18
- data/spec/system/api_acl_spec.rb +128 -0
- data/spec/system/api_ospf_interfaces_spec.rb +17 -14
- data/spec/system/api_ospf_spec.rb +8 -8
- data/spec/system/api_varp_interfaces_spec.rb +22 -13
- data/spec/system/api_varp_spec.rb +1 -4
- data/spec/system/rbeapi/api/interfaces_base_spec.rb +3 -4
- data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +13 -9
- data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +43 -26
- data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +7 -6
- data/spec/system/rbeapi/api/ipinterfaces_spec.rb +34 -21
- data/spec/system/rbeapi/api/mlag_interfaces_spec.rb +15 -38
- data/spec/system/rbeapi/api/mlag_spec.rb +26 -30
- data/spec/system/rbeapi/api/snmp_spec.rb +0 -3
- data/spec/system/rbeapi/api/stp_instances_spec.rb +20 -12
- data/spec/system/rbeapi/api/stp_interfaces_spec.rb +1 -3
- data/spec/system/rbeapi/api/switchports_spec.rb +14 -12
- data/spec/system/rbeapi/api/system_spec.rb +0 -3
- data/spec/system/rbeapi/api/vlans_spec.rb +19 -9
- data/spec/unit/rbeapi/api/acl/default_spec.rb +158 -0
- data/spec/unit/rbeapi/api/acl/fixture_acl_standard.text +22 -0
- data/spec/unit/rbeapi/api/interfaces/base_spec.rb +123 -0
- data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +89 -0
- data/spec/unit/rbeapi/api/interfaces/fixture_interfaces.text +219 -0
- data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +149 -0
- data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +243 -0
- data/spec/unit/rbeapi/api/mlag/default_spec.rb +218 -0
- data/spec/unit/rbeapi/api/mlag/fixture_mlag.text +238 -0
- data/spec/unit/rbeapi/api/vlans/default_spec.rb +135 -0
- data/spec/unit/rbeapi/api/vlans/fixture_vlans.text +5 -0
- metadata +79 -4
- data/lib/rbeapi/api/radius.rb.old +0 -399
@@ -31,14 +31,16 @@
|
|
31
31
|
#
|
32
32
|
require 'rbeapi/api'
|
33
33
|
|
34
|
+
##
|
35
|
+
# Rbeapi toplevel namespace
|
34
36
|
module Rbeapi
|
35
|
-
|
37
|
+
##
|
38
|
+
# Rbeapi::Api
|
36
39
|
module Api
|
37
40
|
#
|
38
41
|
# The Ipinterface class provides an instance for managing logical
|
39
42
|
# IP interfaces configured using eAPI.
|
40
43
|
class Ipinterfaces < Entity
|
41
|
-
|
42
44
|
DEFAULT_ADDRESS = ''
|
43
45
|
|
44
46
|
##
|
@@ -125,7 +127,7 @@ module Rbeapi
|
|
125
127
|
# @return [Hash<Symbol, Object>] resource hash attribute
|
126
128
|
def parse_mtu(config)
|
127
129
|
mdata = /(?<=mtu\s)(\d+)$/.match(config)
|
128
|
-
{ mtu: mdata.nil? ? '': mdata[1] }
|
130
|
+
{ mtu: mdata.nil? ? '' : mdata[1] }
|
129
131
|
end
|
130
132
|
private :parse_mtu
|
131
133
|
|
data/lib/rbeapi/api/logging.rb
CHANGED
@@ -31,12 +31,15 @@
|
|
31
31
|
#
|
32
32
|
require 'rbeapi/api'
|
33
33
|
|
34
|
+
##
|
35
|
+
# Rbeapi toplevel namespace
|
34
36
|
module Rbeapi
|
35
|
-
|
37
|
+
##
|
38
|
+
# Rbeapi::Api
|
36
39
|
module Api
|
37
|
-
|
40
|
+
##
|
41
|
+
# The Logging class manages logging settings on an EOS node.
|
38
42
|
class Logging < Entity
|
39
|
-
|
40
43
|
##
|
41
44
|
# get returns the current logging configuration hash extracted from the
|
42
45
|
# nodes running configuration.
|
@@ -97,8 +100,8 @@ module Rbeapi
|
|
97
100
|
#
|
98
101
|
# @param [Hash] :opts Optional keyword arguments
|
99
102
|
#
|
100
|
-
# @option :opts [Boolean] :value Enables logging globally if value is true
|
101
|
-
# disabled logging glboally if value is false
|
103
|
+
# @option :opts [Boolean] :value Enables logging globally if value is true
|
104
|
+
# or disabled logging glboally if value is false
|
102
105
|
#
|
103
106
|
# @option :opts [Boolean] :default Configure the ip address value using
|
104
107
|
# the default keyword
|
data/lib/rbeapi/api/mlag.rb
CHANGED
@@ -31,48 +31,51 @@
|
|
31
31
|
#
|
32
32
|
require 'rbeapi/api'
|
33
33
|
|
34
|
+
##
|
35
|
+
# Rbeapi toplevel namespace
|
34
36
|
module Rbeapi
|
35
|
-
|
37
|
+
##
|
38
|
+
# Rbeapi::Api
|
36
39
|
module Api
|
37
|
-
|
38
40
|
##
|
39
41
|
# The Mlag class provides a configuration instance for working with
|
40
42
|
# the global MLAG configuration of the node
|
41
43
|
class Mlag < Entity
|
42
|
-
|
43
44
|
DEFAULT_DOMAIN_ID = ''
|
44
45
|
DEFAULT_LOCAL_INTF = ''
|
45
46
|
DEFAULT_PEER_ADDR = ''
|
46
47
|
DEFAULT_PEER_LINK = ''
|
47
48
|
|
48
49
|
##
|
49
|
-
# get
|
50
|
+
# get scans the current nodes configuration and returns the values as
|
51
|
+
# a Hash descriping the current state.
|
50
52
|
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
53
|
+
# The resource hash returned contains the following:
|
54
|
+
# * domain_id: (String) The MLAG domain-id value
|
55
|
+
# * local_interface: (String) The MLAG local-interface value
|
56
|
+
# * peer_address: (String) The IP address of the MLAG peer
|
57
|
+
# * peer_link: (String) The MLAG transit peer-link value
|
58
|
+
# * shutdown: (Boolean) The administrative staet of the mlag
|
59
|
+
# configuration
|
60
|
+
# * interfaces: (Hash) The list of configured MLAG interfaces. (See
|
61
|
+
# parse_interfaces for the Hash details)
|
60
62
|
#
|
61
|
-
# @see
|
63
|
+
# @see parse_interfaces
|
62
64
|
#
|
63
65
|
# @return [nil, Hash<Symbol, Object] returns the nodes current running
|
64
66
|
# configuration as a Hash. If mlag is not configured on the node this
|
65
67
|
# method will return nil
|
66
|
-
def get
|
68
|
+
def get
|
67
69
|
config = get_block('mlag configuration')
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
|
71
|
+
global = {}
|
72
|
+
global.merge!(parse_domain_id(config))
|
73
|
+
global.merge!(parse_local_interface(config))
|
74
|
+
global.merge!(parse_peer_address(config))
|
75
|
+
global.merge!(parse_peer_link(config))
|
76
|
+
global.merge!(parse_shutdown(config))
|
77
|
+
|
78
|
+
{ global: global, interfaces: parse_interfaces }
|
76
79
|
end
|
77
80
|
|
78
81
|
##
|
@@ -166,18 +169,27 @@ module Rbeapi
|
|
166
169
|
private :parse_shutdown
|
167
170
|
|
168
171
|
##
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
+
# parse_interfaces scans the global configuraiton and returns all of the
|
173
|
+
# configured MLAG interfaces. Each interface returns the configured MLAG
|
174
|
+
# identifier for establishing a MLAG peer. The return value is intended
|
175
|
+
# to be merged into the resource Hash
|
172
176
|
#
|
173
|
-
#
|
177
|
+
# The resource Hash attribute returned contains:
|
178
|
+
# * mlag_id: (Fixnum) The configured MLAG identifier
|
174
179
|
#
|
175
|
-
# @
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
+
# @api private
|
181
|
+
#
|
182
|
+
# @return [Hash<Symbol, Object>] resource Hash attribute
|
183
|
+
def parse_interfaces
|
184
|
+
names = config.scan(/(?<=^interface\s)Po.+/)
|
185
|
+
names.each_with_object({}) do |name, hsh|
|
186
|
+
config = get_block("^interface #{name}")
|
187
|
+
next unless config
|
188
|
+
id = config.scan(/(?<=mlag )\d+/)
|
189
|
+
hsh[name] = { mlag_id: id.first.to_i } unless id.empty?
|
190
|
+
end
|
180
191
|
end
|
192
|
+
private :parse_interfaces
|
181
193
|
|
182
194
|
##
|
183
195
|
# set_domain_id configures the mlag domain-id value in the current nodes
|
@@ -377,100 +389,6 @@ module Rbeapi
|
|
377
389
|
end
|
378
390
|
configure(cmds)
|
379
391
|
end
|
380
|
-
end
|
381
|
-
|
382
|
-
class MlagInterfaces < Entity
|
383
|
-
|
384
|
-
##
|
385
|
-
# get returns the mlag interface configuration as a hash object. If the
|
386
|
-
# specified interface name is not configured as an mlag interface this
|
387
|
-
# method will return nil
|
388
|
-
#
|
389
|
-
# @example
|
390
|
-
# {
|
391
|
-
# mlag_id: <string>
|
392
|
-
# }
|
393
|
-
#
|
394
|
-
# @param [String] :name The full interface name of the interface to
|
395
|
-
# return the mlag interface hash for.
|
396
|
-
#
|
397
|
-
# @return [nil, Hash<Symbol, Object>] returns the interface configuration
|
398
|
-
# as a resource hash. If the interface is not configured as an mlag
|
399
|
-
# interface nil is returned.
|
400
|
-
def get(name)
|
401
|
-
config = get_block("^interface #{name}")
|
402
|
-
return nil unless config
|
403
|
-
mdata = /(?<=\s{3}mlag\s)(.+)$/.match(config)
|
404
|
-
return nil unless mdata
|
405
|
-
{ mlag_id: mdata[1] }
|
406
|
-
end
|
407
|
-
|
408
|
-
##
|
409
|
-
# getall scans the nodes current running configuration and returns a
|
410
|
-
# hash of all mlag interfaces keyed by the interface name. If no
|
411
|
-
# interfaces are configured, an empty hash object is returned
|
412
|
-
#
|
413
|
-
# @see get Interface resource example
|
414
|
-
#
|
415
|
-
# @return [Hash<String, Hash>] returns the nodes mlag interface
|
416
|
-
# configurations as a hash
|
417
|
-
def getall
|
418
|
-
names = config.scan(/(?<=^interface\s)Po.+/)
|
419
|
-
names.each_with_object({}) do |name, response|
|
420
|
-
data = get name
|
421
|
-
response[name] = data if data
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
##
|
426
|
-
# create adds a new mlag interface to the nodes current running
|
427
|
-
# configuration. If the specified interface already exists, then this
|
428
|
-
# method will return successfully with the updated mlag id.
|
429
|
-
#
|
430
|
-
# @see set_mlag_id
|
431
|
-
#
|
432
|
-
# @param [String] :name The name of of the interface to create. The name
|
433
|
-
# must be the full interface name. The value of name is expected to
|
434
|
-
# be a Port-Channel interface.
|
435
|
-
#
|
436
|
-
# @param [String, Integer] :id The value of the mlag id to configure for
|
437
|
-
# the specified interface. Valid mlag ids are in the range of 1 to
|
438
|
-
# 2000.
|
439
|
-
#
|
440
|
-
# @return [Boolean] returns true if the command completed successfully
|
441
|
-
def create(name, id)
|
442
|
-
set_mlag_id(name, value: id)
|
443
|
-
end
|
444
|
-
|
445
|
-
##
|
446
|
-
# delete removes a mlag interface from the nodes current running
|
447
|
-
# configuration. If the specified interface does not exist as a mlag
|
448
|
-
# interface this method will return successfully
|
449
|
-
#
|
450
|
-
# @see set_mlag_id
|
451
|
-
#
|
452
|
-
# @param [String] :name The name of of the interface to remove. The name
|
453
|
-
# must be the full interface name.
|
454
|
-
#
|
455
|
-
# @return [Boolean] returns true if the command completed successfully
|
456
|
-
def delete(name)
|
457
|
-
set_mlag_id(name)
|
458
|
-
end
|
459
|
-
|
460
|
-
##
|
461
|
-
# default configures a mlag interface using the default keyword. If the
|
462
|
-
# specified interface does not exist as a mlag interface this method
|
463
|
-
# will return successfully
|
464
|
-
#
|
465
|
-
# @see set_mlag_id
|
466
|
-
#
|
467
|
-
# @param [String] :name The name of of the interface to create. The name
|
468
|
-
# must be the full interface name.
|
469
|
-
#
|
470
|
-
# @return [Boolean] returns true if the command completed successfully
|
471
|
-
def default(name)
|
472
|
-
set_mlag_id(name, default: true)
|
473
|
-
end
|
474
392
|
|
475
393
|
##
|
476
394
|
# set_mlag_id configures the mlag id on the interface in the nodes
|
@@ -510,7 +428,7 @@ module Rbeapi
|
|
510
428
|
when true
|
511
429
|
cmds << 'default mlag'
|
512
430
|
when false
|
513
|
-
cmds << (value ? "mlag #{value}"
|
431
|
+
cmds << (value ? "mlag #{value}" : 'no mlag')
|
514
432
|
end
|
515
433
|
configure(cmds)
|
516
434
|
end
|
data/lib/rbeapi/api/ntp.rb
CHANGED
@@ -37,12 +37,10 @@ module Rbeapi
|
|
37
37
|
##
|
38
38
|
# Api is module namesapce for working with the EOS command API
|
39
39
|
module Api
|
40
|
-
|
41
40
|
##
|
42
41
|
# The Ntp class provides an intstance for working with the nodes
|
43
42
|
# NTP configuraiton.
|
44
43
|
class Ntp < Entity
|
45
|
-
|
46
44
|
DEFAULT_SRC_INTF = ''
|
47
45
|
|
48
46
|
##
|
@@ -130,8 +128,7 @@ module Rbeapi
|
|
130
128
|
when true
|
131
129
|
cmds = 'default ntp source'
|
132
130
|
when false
|
133
|
-
cmds = (value ? "ntp source #{value}" :
|
134
|
-
'no ntp source')
|
131
|
+
cmds = (value ? "ntp source #{value}" : 'no ntp source')
|
135
132
|
end
|
136
133
|
configure(cmds)
|
137
134
|
end
|
data/lib/rbeapi/api/ospf.rb
CHANGED
@@ -31,18 +31,21 @@
|
|
31
31
|
#
|
32
32
|
require 'rbeapi/api'
|
33
33
|
|
34
|
+
##
|
35
|
+
# Rbeapi toplevel namespace
|
34
36
|
module Rbeapi
|
35
|
-
|
37
|
+
##
|
38
|
+
# Rbeapi::Api
|
36
39
|
module Api
|
37
|
-
|
38
40
|
##
|
39
41
|
# The Ospf class is a global class that provides an instance for working
|
40
42
|
# with the node's OSPF configuration
|
41
43
|
class Ospf < Entity
|
42
|
-
|
43
44
|
##
|
44
45
|
# Returns the global OSPF configuration from the node
|
45
46
|
#
|
47
|
+
# rubocop:disable Metrics/MethodLength
|
48
|
+
#
|
46
49
|
# @example
|
47
50
|
# {
|
48
51
|
# "router_id": <string>
|
@@ -58,11 +61,10 @@ module Rbeapi
|
|
58
61
|
config = get_block("router ospf #{inst}")
|
59
62
|
return nil unless config
|
60
63
|
|
61
|
-
|
64
|
+
response = {}
|
62
65
|
mdata = /(?<=^\s{3}router-id\s)(.+)$/.match(config)
|
63
|
-
|
66
|
+
response['router_id'] = mdata.nil? ? '' : mdata[0]
|
64
67
|
|
65
|
-
mdata = /^\s{3}network\s(.+)\sarea\s(.+)$/.match(config)
|
66
68
|
networks = config.scan(/^\s{3}network\s(.+)\sarea\s(.+)$/)
|
67
69
|
areas = networks.each_with_object({}) do |cfg, hsh|
|
68
70
|
net, area = cfg
|
@@ -72,14 +74,15 @@ module Rbeapi
|
|
72
74
|
hsh[area] = [net]
|
73
75
|
end
|
74
76
|
end
|
75
|
-
|
77
|
+
response['areas'] = areas
|
76
78
|
|
77
|
-
values =
|
79
|
+
values = \
|
80
|
+
config.scan(/(?<=^\s{3}redistribute\s)(\w+)[\s|$]*(route-map\s(.+))?/)
|
78
81
|
|
79
|
-
|
82
|
+
response['redistribute'] = values.each_with_object({}) do |value, hsh|
|
80
83
|
hsh[value[0]] = { 'route_map' => value[2] }
|
81
84
|
end
|
82
|
-
|
85
|
+
response
|
83
86
|
end
|
84
87
|
|
85
88
|
##
|
@@ -91,8 +94,6 @@ module Rbeapi
|
|
91
94
|
# "interfaces": {...}
|
92
95
|
# }
|
93
96
|
def getall
|
94
|
-
response = {}
|
95
|
-
|
96
97
|
instances = config.scan(/(?<=^router\sospf\s)\d+$/)
|
97
98
|
response = instances.each_with_object({}) do |inst, hsh|
|
98
99
|
hsh[inst] = get inst
|
@@ -145,8 +146,10 @@ module Rbeapi
|
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
149
|
+
##
|
150
|
+
# The OspfInterfaces class is a global class that provides an instance
|
151
|
+
# for working with the node's OSPF interface configuration
|
148
152
|
class OspfInterfaces < Entity
|
149
|
-
|
150
153
|
##
|
151
154
|
# Returns a single MLAG interface configuration
|
152
155
|
#
|
@@ -31,16 +31,17 @@
|
|
31
31
|
#
|
32
32
|
require 'rbeapi/api'
|
33
33
|
|
34
|
+
##
|
35
|
+
# Rbeapi toplevel namespace
|
34
36
|
module Rbeapi
|
35
|
-
|
37
|
+
##
|
38
|
+
# Rbeapi::Api
|
36
39
|
module Api
|
37
|
-
|
38
40
|
##
|
39
41
|
# The Prefixlists class provides a configuration instance for working
|
40
42
|
# with static routes in EOS.
|
41
43
|
#
|
42
44
|
class Prefixlists < Entity
|
43
|
-
|
44
45
|
##
|
45
46
|
# Returns the static routes configured on the node
|
46
47
|
#
|
@@ -92,7 +93,6 @@ module Rbeapi
|
|
92
93
|
cmd << " seq #{seq}" if seq
|
93
94
|
configure cmd
|
94
95
|
end
|
95
|
-
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
data/lib/rbeapi/api/radius.rb
CHANGED
@@ -31,16 +31,16 @@
|
|
31
31
|
#
|
32
32
|
require 'rbeapi/api'
|
33
33
|
|
34
|
-
|
34
|
+
##
|
35
|
+
# Rbeapi toplevel namespace
|
35
36
|
module Rbeapi
|
36
37
|
##
|
37
|
-
#
|
38
|
+
# Rbeapi::Api
|
38
39
|
module Api
|
39
40
|
##
|
40
41
|
# Radius provides instance methods to retrieve and set radius configuration
|
41
42
|
# values.
|
42
43
|
class Radius < Entity
|
43
|
-
|
44
44
|
DEFAULT_KEY_FORMAT = 0
|
45
45
|
DEFAULT_KEY = nil
|
46
46
|
|
@@ -164,11 +164,11 @@ module Rbeapi
|
|
164
164
|
private :parse_servers
|
165
165
|
|
166
166
|
##
|
167
|
-
# set_global_key configures the global radius-server key. If the value
|
168
|
-
# is not specified, radius-server key is configured using the no
|
169
|
-
# If the default option is specified, radius-server key is
|
170
|
-
# using the default keyword.
|
171
|
-
# keyword option takes precedence.
|
167
|
+
# set_global_key configures the global radius-server key. If the value
|
168
|
+
# option is not specified, radius-server key is configured using the no
|
169
|
+
# keyword. If the default option is specified, radius-server key is
|
170
|
+
# configured using the default keyword. If both options are specified,
|
171
|
+
# the default keyword option takes precedence.
|
172
172
|
#
|
173
173
|
# @eos_version 4.13.7M
|
174
174
|
#
|
@@ -197,18 +197,21 @@ module Rbeapi
|
|
197
197
|
when true
|
198
198
|
cmds = 'default radius-server key'
|
199
199
|
when false
|
200
|
-
|
201
|
-
|
200
|
+
if value
|
201
|
+
cmds = "radius-server key #{key_format} #{value}"
|
202
|
+
else
|
203
|
+
cmds = 'no radius-server key'
|
204
|
+
end
|
202
205
|
end
|
203
206
|
configure cmds
|
204
207
|
end
|
205
208
|
|
206
209
|
##
|
207
|
-
# set_global_timeout configures the radius-server timeout value. If the
|
208
|
-
# options is not specified, radius-server timeout is configured
|
209
|
-
# no keyword. If the default option is specified, radius-server
|
210
|
-
# is configured using the default keyword. If both options are
|
211
|
-
# then the default keyword takes precedence.
|
210
|
+
# set_global_timeout configures the radius-server timeout value. If the
|
211
|
+
# value # options is not specified, radius-server timeout is configured
|
212
|
+
# using the no keyword. If the default option is specified, radius-server
|
213
|
+
# timeout is configured using the default keyword. If both options are
|
214
|
+
# specified then the default keyword takes precedence.
|
212
215
|
#
|
213
216
|
# @eos_version 4.13.7M
|
214
217
|
#
|
@@ -233,19 +236,22 @@ module Rbeapi
|
|
233
236
|
when true
|
234
237
|
cmds = 'default radius-server timeout'
|
235
238
|
when false
|
236
|
-
|
237
|
-
|
239
|
+
if value
|
240
|
+
cmds = "radius-server timeout #{value}"
|
241
|
+
else
|
242
|
+
cmds = 'no radius-server timeout'
|
243
|
+
end
|
238
244
|
end
|
239
245
|
configure cmds
|
240
246
|
end
|
241
247
|
|
242
248
|
##
|
243
|
-
# set_global_retransmit configures the global radius-server restransmit
|
244
|
-
# If the value is not specified, the radius-server retransmist
|
245
|
-
# configured using the no keyword. If the default option is
|
246
|
-
# the radius-server retransmit value is configured using the
|
247
|
-
# keyword.
|
248
|
-
# precedence
|
249
|
+
# set_global_retransmit configures the global radius-server restransmit
|
250
|
+
# value. If the value is not specified, the radius-server retransmist
|
251
|
+
# value is configured using the no keyword. If the default option is
|
252
|
+
# specified, the radius-server retransmit value is configured using the
|
253
|
+
# default keyword. If both options are specified then the default keyword
|
254
|
+
# takes precedence
|
249
255
|
#
|
250
256
|
# @eos_version 4.13.7M
|
251
257
|
#
|
@@ -270,8 +276,11 @@ module Rbeapi
|
|
270
276
|
when true
|
271
277
|
cmds = 'default radius-server retransmit'
|
272
278
|
when false
|
273
|
-
|
274
|
-
|
279
|
+
if value
|
280
|
+
cmds = "radius-server retransmit #{value}"
|
281
|
+
else
|
282
|
+
cmds = 'no radius-server retransmit'
|
283
|
+
end
|
275
284
|
end
|
276
285
|
configure cmds
|
277
286
|
end
|
data/lib/rbeapi/api/routemaps.rb
CHANGED
@@ -31,12 +31,21 @@
|
|
31
31
|
#
|
32
32
|
require 'rbeapi/api'
|
33
33
|
|
34
|
+
##
|
35
|
+
# Rbeapi toplevel namespace
|
34
36
|
module Rbeapi
|
35
|
-
|
37
|
+
##
|
38
|
+
# Rbeapi::Api
|
36
39
|
module Api
|
37
|
-
|
40
|
+
##
|
41
|
+
# The Routemaps class manages routemaps. A route map is a list of rules
|
42
|
+
# that control the redistribution of IP routes into a protocol domain on
|
43
|
+
# the basis of such criteria as route metrics, access control lists, next
|
44
|
+
# hop addresses, and route tags.
|
45
|
+
#
|
46
|
+
# rubocop:disable Metrics/MethodLength
|
47
|
+
#
|
38
48
|
class Routemaps < Entity
|
39
|
-
|
40
49
|
def get(name)
|
41
50
|
entries = config.scan(/^route-map\s#{name}\s.+$/)
|
42
51
|
|
@@ -52,13 +61,13 @@ module Rbeapi
|
|
52
61
|
case mdata.nil? ? nil : mdata[1]
|
53
62
|
when 'match'
|
54
63
|
hsh['match_rules'] = [] unless hsh.include?('match')
|
55
|
-
hsh['match_rules'] << rule.strip
|
64
|
+
hsh['match_rules'] << rule.strip
|
56
65
|
when 'set'
|
57
66
|
hsh['set_rules'] = [] unless hsh.include?('set')
|
58
|
-
hsh['set_rules'] << rule.strip
|
67
|
+
hsh['set_rules'] << rule.strip
|
59
68
|
when 'continue'
|
60
69
|
hsh['continue_rules'] = [] unless hsh.include?('continue')
|
61
|
-
hsh['continue_rules'] << rule.strip
|
70
|
+
hsh['continue_rules'] << rule.strip
|
62
71
|
end
|
63
72
|
end
|
64
73
|
rule_hsh.update(parsed)
|
@@ -69,9 +78,7 @@ module Rbeapi
|
|
69
78
|
def getall
|
70
79
|
maps = config.scan(/(?<=^route-map\s)[^\s]+/)
|
71
80
|
maps.each_with_object({}) do |name, hsh|
|
72
|
-
|
73
|
-
hsh[name] = get name
|
74
|
-
end
|
81
|
+
hsh[name] = get name unless hsh.include?(name)
|
75
82
|
end
|
76
83
|
end
|
77
84
|
|
@@ -94,7 +101,6 @@ module Rbeapi
|
|
94
101
|
def remove_rule(name, action, seqno)
|
95
102
|
configure "no route-map #{name} #{action} #{seqno}"
|
96
103
|
end
|
97
|
-
|
98
104
|
end
|
99
105
|
end
|
100
106
|
end
|
data/lib/rbeapi/api/snmp.rb
CHANGED
@@ -31,20 +31,21 @@
|
|
31
31
|
#
|
32
32
|
require 'rbeapi/api'
|
33
33
|
|
34
|
+
##
|
35
|
+
# Rbeapi toplevel namespace
|
34
36
|
module Rbeapi
|
35
|
-
|
36
37
|
##
|
37
38
|
# Api is module namespace for working with eAPI abstractions
|
38
39
|
module Api
|
39
|
-
|
40
40
|
##
|
41
41
|
# The Snmp class provides a class implementation for working with the
|
42
42
|
# nodes SNMP conifguration entity. This class presents an abstraction
|
43
43
|
# of the node's snmp configuration from the running config.
|
44
44
|
#
|
45
|
+
# rubocop:disable Metrics/ClassLength
|
46
|
+
#
|
45
47
|
# @eos_version 4.13.7M
|
46
48
|
class Snmp < Entity
|
47
|
-
|
48
49
|
DEFAULT_SNMP_LOCATION = ''
|
49
50
|
DEFAULT_SNMP_CONTACT = ''
|
50
51
|
DEFAULT_SNMP_CHASSIS_ID = ''
|
@@ -172,7 +173,7 @@ module Rbeapi
|
|
172
173
|
|
173
174
|
notifications = traps.map do |trap|
|
174
175
|
state, name = trap
|
175
|
-
{ name: name, state: CFG_TO_STATE[state]}
|
176
|
+
{ name: name, state: CFG_TO_STATE[state] }
|
176
177
|
end
|
177
178
|
notifications << { name: 'all', state: CFG_TO_STATE[all.first] }
|
178
179
|
{ notifications: notifications }
|
@@ -238,8 +239,11 @@ module Rbeapi
|
|
238
239
|
when true
|
239
240
|
cmds = ['default snmp-server location']
|
240
241
|
when false
|
241
|
-
|
242
|
-
|
242
|
+
if value.nil?
|
243
|
+
cmds = 'no snmp-server location'
|
244
|
+
else
|
245
|
+
cmds = "snmp-server location #{value}"
|
246
|
+
end
|
243
247
|
end
|
244
248
|
configure(cmds)
|
245
249
|
end
|
@@ -275,8 +279,11 @@ module Rbeapi
|
|
275
279
|
when true
|
276
280
|
cmds = ['default snmp-server contact']
|
277
281
|
when false
|
278
|
-
|
279
|
-
|
282
|
+
if value.nil?
|
283
|
+
cmds = 'no snmp-server contact'
|
284
|
+
else
|
285
|
+
cmds = "snmp-server contact #{value}"
|
286
|
+
end
|
280
287
|
end
|
281
288
|
configure(cmds)
|
282
289
|
end
|
@@ -312,8 +319,11 @@ module Rbeapi
|
|
312
319
|
when true
|
313
320
|
cmds = 'default snmp-server chassis-id'
|
314
321
|
when false
|
315
|
-
|
316
|
-
|
322
|
+
if value.nil?
|
323
|
+
cmds = 'no snmp-server chassis-id'
|
324
|
+
else
|
325
|
+
cmds = "snmp-server chassis-id #{value}"
|
326
|
+
end
|
317
327
|
end
|
318
328
|
configure(cmds)
|
319
329
|
end
|
@@ -350,10 +360,13 @@ module Rbeapi
|
|
350
360
|
when true
|
351
361
|
cmds = ['default snmp-server source-interface']
|
352
362
|
when false
|
353
|
-
|
354
|
-
|
363
|
+
if value.nil?
|
364
|
+
cmds = 'no snmp-server source-interface'
|
365
|
+
else
|
366
|
+
cmds = "snmp-server source-interface #{value}"
|
367
|
+
end
|
355
368
|
end
|
356
|
-
|
369
|
+
configure(cmds)
|
357
370
|
end
|
358
371
|
|
359
372
|
##
|