rbeapi 0.2.0 → 0.3.0
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/.gitignore +1 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +4 -0
- data/README.md +9 -9
- data/Rakefile +20 -0
- data/lib/rbeapi/api/bgp.rb +770 -0
- data/lib/rbeapi/api/dns.rb +32 -31
- data/lib/rbeapi/api/interfaces.rb +106 -87
- data/lib/rbeapi/api/ipinterfaces.rb +27 -42
- data/lib/rbeapi/api/logging.rb +9 -19
- data/lib/rbeapi/api/mlag.rb +60 -90
- data/lib/rbeapi/api/ntp.rb +12 -17
- data/lib/rbeapi/api/ospf.rb +9 -26
- data/lib/rbeapi/api/radius.rb +29 -43
- data/lib/rbeapi/api/snmp.rb +54 -83
- data/lib/rbeapi/api/staticroutes.rb +68 -21
- data/lib/rbeapi/api/stp.rb +41 -49
- data/lib/rbeapi/api/switchports.rb +41 -68
- data/lib/rbeapi/api/system.rb +6 -12
- data/lib/rbeapi/api/tacacs.rb +12 -21
- data/lib/rbeapi/api/varp.rb +25 -26
- data/lib/rbeapi/api/vlans.rb +19 -28
- data/lib/rbeapi/api.rb +30 -21
- data/lib/rbeapi/client.rb +3 -1
- data/lib/rbeapi/version.rb +1 -1
- data/rbeapi.spec.tmpl +4 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/system/api_ospf_interfaces_spec.rb +16 -0
- data/spec/system/api_ospf_spec.rb +14 -0
- data/spec/system/api_varp_interfaces_spec.rb +16 -0
- data/spec/system/rbeapi/api/dns_spec.rb +66 -0
- data/spec/system/rbeapi/api/interfaces_base_spec.rb +4 -4
- data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +6 -6
- data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +6 -6
- data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +4 -4
- data/spec/system/rbeapi/api/ipinterfaces_spec.rb +44 -0
- data/spec/system/rbeapi/api/logging_spec.rb +18 -2
- data/spec/system/rbeapi/api/mlag_spec.rb +94 -2
- data/spec/system/rbeapi/api/ntp_spec.rb +14 -0
- data/spec/system/rbeapi/api/snmp_spec.rb +105 -0
- data/spec/system/rbeapi/api/stp_interfaces_spec.rb +43 -6
- data/spec/system/rbeapi/api/stp_spec.rb +18 -6
- data/spec/system/rbeapi/api/switchports_spec.rb +75 -3
- data/spec/system/rbeapi/api/system_spec.rb +16 -0
- data/spec/system/rbeapi/api/vlans_spec.rb +28 -0
- data/spec/unit/rbeapi/api/bgp/bgp_neighbors_spec.rb +289 -0
- data/spec/unit/rbeapi/api/bgp/bgp_spec.rb +192 -0
- data/spec/unit/rbeapi/api/bgp/fixture_bgp.text +101 -0
- data/spec/unit/rbeapi/api/interfaces/base_spec.rb +7 -13
- data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +3 -3
- data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +11 -16
- data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +15 -21
- data/spec/unit/rbeapi/api/mlag/default_spec.rb +13 -19
- data/spec/unit/rbeapi/api/staticroutes/default_spec.rb +138 -0
- data/spec/unit/rbeapi/api/staticroutes/fixture_staticroutes.text +5 -0
- data/spec/unit/rbeapi/api/vlans/default_spec.rb +4 -4
- metadata +15 -4
data/lib/rbeapi/api/stp.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2014, Arista Networks, Inc.
|
2
|
+
# Copyright (c) 2014,2015, Arista Networks, Inc.
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -67,7 +67,7 @@ module Rbeapi
|
|
67
67
|
##
|
68
68
|
# parse_mode scans the nodes running configuration and extracts the
|
69
69
|
# value of the spanning-tree mode. The spanning tree mode is
|
70
|
-
# expected to be always be
|
70
|
+
# expected to be always be available in the running config. The return
|
71
71
|
# value is intended to be merged into the stp resource hash
|
72
72
|
#
|
73
73
|
# @api private
|
@@ -90,7 +90,7 @@ module Rbeapi
|
|
90
90
|
end
|
91
91
|
|
92
92
|
##
|
93
|
-
# interfaces
|
93
|
+
# interfaces returns a memoized instance of StpInterfaces for
|
94
94
|
# configuring individual stp interfaces
|
95
95
|
#
|
96
96
|
# @return [StpInterfaces] an instance of StpInterfaces class
|
@@ -102,10 +102,10 @@ module Rbeapi
|
|
102
102
|
|
103
103
|
##
|
104
104
|
# set_mode configures the stp mode in the global nodes running
|
105
|
-
# configuration. If the
|
105
|
+
# configuration. If the enable option is false, then the stp
|
106
106
|
# mode is configured with the no keyword argument. If the default option
|
107
107
|
# is specified then the mode is configured with the default keyword
|
108
|
-
# argument. The default keyword argument takes precedence over the
|
108
|
+
# argument. The default keyword argument takes precedence over the enable
|
109
109
|
# option if both are provided
|
110
110
|
#
|
111
111
|
# @eos_version 4.13.7M
|
@@ -120,25 +120,16 @@ module Rbeapi
|
|
120
120
|
# @option :opts [String] :value The value to configure the stp mode to
|
121
121
|
# in the nodes current running configuration
|
122
122
|
#
|
123
|
-
# @option :opts [Boolean] :
|
123
|
+
# @option :opts [Boolean] :enable If false then the command is
|
124
|
+
# negated. Default is true.
|
125
|
+
#
|
126
|
+
# @option :opts [Boolean] :default Configure the stp mode value using
|
124
127
|
# the default keyword
|
125
128
|
#
|
126
129
|
# @return [Boolean] returns true if the command completed successfully
|
127
130
|
#
|
128
131
|
def set_mode(opts = {})
|
129
|
-
|
130
|
-
default = opts[:default] || false
|
131
|
-
|
132
|
-
case default
|
133
|
-
when true
|
134
|
-
cmd = 'default spanning-tree mode'
|
135
|
-
when false
|
136
|
-
if value
|
137
|
-
cmd = "spanning-tree mode #{value}"
|
138
|
-
else
|
139
|
-
cmd = 'no spanning-tree mode'
|
140
|
-
end
|
141
|
-
end
|
132
|
+
cmd = command_builder('spanning-tree mode', opts)
|
142
133
|
configure cmd
|
143
134
|
end
|
144
135
|
end
|
@@ -151,7 +142,7 @@ module Rbeapi
|
|
151
142
|
DEFAULT_STP_PRIORITY = '32768'
|
152
143
|
|
153
144
|
##
|
154
|
-
# get returns the specified stp
|
145
|
+
# get returns the specified stp instance config parsed from the nodes
|
155
146
|
# current running configuration.
|
156
147
|
#
|
157
148
|
# @example
|
@@ -207,7 +198,7 @@ module Rbeapi
|
|
207
198
|
##
|
208
199
|
# parse_priority will scan the nodes current configuration and extract
|
209
200
|
# the stp priority value for the given stp instance. If the stp
|
210
|
-
# instance
|
201
|
+
# instance priority is not configured, the priority value will be set
|
211
202
|
# using DEFAULT_STP_PRIORITY. The returned hash is intended to be merged
|
212
203
|
# into the resource hash
|
213
204
|
#
|
@@ -238,18 +229,21 @@ module Rbeapi
|
|
238
229
|
# @param [String] inst The MST instance to configure
|
239
230
|
# @param [Hash] opts The configuration parameters for the priority
|
240
231
|
# @option opts [string] :value The value to set the priority to
|
232
|
+
# @option :opts [Boolean] :enable If false then the command is
|
233
|
+
# negated. Default is true.
|
241
234
|
# @option opts [Boolean] :default The value should be set to default
|
242
235
|
#
|
243
236
|
# @return [Boolean] True if the commands succeed otherwise False
|
244
237
|
def set_priority(inst, opts = {})
|
245
238
|
value = opts[:value]
|
239
|
+
enable = opts.fetch(:enable, true)
|
246
240
|
default = opts[:default] || false
|
247
241
|
|
248
242
|
case default
|
249
243
|
when true
|
250
244
|
cmd = "default spanning-tree mst #{inst} priority"
|
251
245
|
when false
|
252
|
-
if
|
246
|
+
if enable
|
253
247
|
cmd = "spanning-tree mst #{inst} priority #{value}"
|
254
248
|
else
|
255
249
|
cmd = "no spanning-tree mst #{inst} priority"
|
@@ -261,7 +255,7 @@ module Rbeapi
|
|
261
255
|
|
262
256
|
##
|
263
257
|
# The StpInterfaces class provides a class instance for working with
|
264
|
-
# spanning-tree
|
258
|
+
# spanning-tree interfaces in EOS
|
265
259
|
#
|
266
260
|
class StpInterfaces < Entity
|
267
261
|
##
|
@@ -365,25 +359,14 @@ module Rbeapi
|
|
365
359
|
# @param [String] name The name of the interface to configure
|
366
360
|
# @param [Hash] opts The configuration parameters for portfast
|
367
361
|
# @option opts [Boolean] :value The value to set portfast
|
362
|
+
# @option :opts [Boolean] :enable If false then the command is
|
363
|
+
# negated. Default is true.
|
368
364
|
# @option opts [Boolean] :default The value should be set to default
|
369
365
|
#
|
370
366
|
# @return [Boolean] True if the commands succeed otherwise False
|
371
367
|
def set_portfast(name, opts = {})
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
cmds = ["interface #{name}"]
|
376
|
-
case default
|
377
|
-
when true
|
378
|
-
cmds << 'default spanning-tree portfast'
|
379
|
-
when false
|
380
|
-
if value
|
381
|
-
cmds << 'spanning-tree portfast'
|
382
|
-
else
|
383
|
-
cmds << 'no spanning-tree portfast'
|
384
|
-
end
|
385
|
-
end
|
386
|
-
configure(cmds)
|
368
|
+
cmd = command_builder('spanning-tree portfast', opts)
|
369
|
+
configure_interface(name, cmd)
|
387
370
|
end
|
388
371
|
|
389
372
|
##
|
@@ -392,21 +375,29 @@ module Rbeapi
|
|
392
375
|
# @param [String] name The name of the interface to configure
|
393
376
|
# @param [Hash] opts The configuration parameters for portfast type
|
394
377
|
# @option opts [String] :value The value to set portfast type to.
|
378
|
+
# The value must be set for calls to this method.
|
379
|
+
# @option opts [Boolean] :enable If false then the command is
|
380
|
+
# negated. Default is true.
|
395
381
|
# @option opts [Boolean] :default The value should be set to default
|
396
382
|
#
|
397
383
|
# @return [Boolean] True if the commands succeed otherwise False
|
398
384
|
def set_portfast_type(name, opts = {})
|
399
385
|
value = opts[:value]
|
386
|
+
fail ArgumentError, 'value must be set' unless value
|
387
|
+
enable = opts.fetch(:enable, true)
|
400
388
|
default = opts[:default] || false
|
401
389
|
|
402
|
-
cmds = ["interface #{name}"]
|
403
390
|
case default
|
404
391
|
when true
|
405
|
-
cmds
|
392
|
+
cmds = "default spanning-tree portfast #{value}"
|
406
393
|
when false
|
407
|
-
|
394
|
+
if enable
|
395
|
+
cmds = "spanning-tree portfast #{value}"
|
396
|
+
else
|
397
|
+
cmds = "no spanning-tree portfast #{value}"
|
398
|
+
end
|
408
399
|
end
|
409
|
-
|
400
|
+
configure_interface(name, cmds)
|
410
401
|
end
|
411
402
|
|
412
403
|
##
|
@@ -415,25 +406,26 @@ module Rbeapi
|
|
415
406
|
# @param [String] name The name of the interface to configure
|
416
407
|
# @param [Hash] opts The configuration parameters for bpduguard
|
417
408
|
# @option opts [Boolean] :value The value to set bpduguard
|
409
|
+
# @option opts [Boolean] :enable If false then the bpduguard is
|
410
|
+
# disabled. If true then the bpduguard is enabled. Default is true.
|
418
411
|
# @option opts [Boolean] :default The value should be set to default
|
419
412
|
#
|
420
413
|
# @return [Boolean] True if the commands succeed otherwise False
|
421
414
|
def set_bpduguard(name, opts = {})
|
422
|
-
|
415
|
+
enable = opts.fetch(:enable, true)
|
423
416
|
default = opts[:default] || false
|
424
417
|
|
425
|
-
cmds = ["interface #{name}"]
|
426
418
|
case default
|
427
419
|
when true
|
428
|
-
cmds
|
420
|
+
cmds = 'default spanning-tree bpduguard'
|
429
421
|
when false
|
430
|
-
if
|
431
|
-
cmds
|
422
|
+
if enable
|
423
|
+
cmds = 'spanning-tree bpduguard enable'
|
432
424
|
else
|
433
|
-
cmds
|
425
|
+
cmds = 'spanning-tree bpduguard disable'
|
434
426
|
end
|
435
427
|
end
|
436
|
-
|
428
|
+
configure_interface(name, cmds)
|
437
429
|
end
|
438
430
|
end
|
439
431
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2014, Arista Networks, Inc.
|
2
|
+
# Copyright (c) 2014,2015 Arista Networks, Inc.
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -43,7 +43,7 @@ module Rbeapi
|
|
43
43
|
#
|
44
44
|
class Switchports < Entity
|
45
45
|
##
|
46
|
-
# Retrieves the
|
46
|
+
# Retrieves the properties for a logical switchport from the
|
47
47
|
# running-config using eAPI
|
48
48
|
#
|
49
49
|
# Example
|
@@ -145,40 +145,28 @@ module Rbeapi
|
|
145
145
|
end
|
146
146
|
|
147
147
|
##
|
148
|
-
# Configures the switchport mode for the specified
|
149
|
-
# modes are access (default) or trunk
|
148
|
+
# Configures the switchport mode for the specified interface.
|
150
149
|
#
|
151
150
|
# @param [String] name The name of the interface to configure
|
152
151
|
# @param [Hash] opts The configuration parameters for the interface
|
153
152
|
# @option opts [string] :value The value to set the mode to
|
153
|
+
# @option opts [Boolean] :enable If false then the command is
|
154
|
+
# negated. Default is true.
|
154
155
|
# @option opts [Boolean] :default The value should be set to default
|
155
156
|
#
|
156
157
|
# @return [Boolean] True if the commands succeed otherwise False
|
157
158
|
def set_mode(name, opts = {})
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
cmds = ["interface #{name}"]
|
162
|
-
case default
|
163
|
-
when true
|
164
|
-
cmds << 'default switchport mode'
|
165
|
-
when false
|
166
|
-
if value.nil?
|
167
|
-
cmds << 'no switchport mode'
|
168
|
-
else
|
169
|
-
cmds << "switchport mode #{value}"
|
170
|
-
end
|
171
|
-
end
|
172
|
-
configure(cmds)
|
159
|
+
cmd = command_builder('switchport mode', opts)
|
160
|
+
configure_interface(name, cmd)
|
173
161
|
end
|
174
162
|
|
175
163
|
##
|
176
164
|
# set_trunk_allowed_vlans configures the list of vlan ids that are
|
177
|
-
# allowed on the specified trunk port. If the
|
178
|
-
#
|
179
|
-
# If the default keyword is
|
180
|
-
# using the default
|
181
|
-
#
|
165
|
+
# allowed on the specified trunk port. If the enable option is set to
|
166
|
+
# false, then the allowed trunks is configured using the no keyword.
|
167
|
+
# If the default keyword is provided then the allowed trunks is configured
|
168
|
+
# using the default keyword The default option takes precedence over the
|
169
|
+
# enable option if both are specified
|
182
170
|
#
|
183
171
|
# @eos_version 4.13.7M
|
184
172
|
#
|
@@ -187,35 +175,40 @@ module Rbeapi
|
|
187
175
|
# no switchport trunk allowed vlan
|
188
176
|
# default switchport trunk allowed vlan
|
189
177
|
#
|
190
|
-
# @
|
178
|
+
# @param [String] name The name of the interface to configure
|
179
|
+
# @param [Hash] opts The configuration parameters for the interface
|
180
|
+
# @option pts [Array] :value The list of vlan ids to configure on the
|
191
181
|
# switchport to be allowed. This value must be an array of valid vlan
|
192
182
|
# ids
|
193
|
-
#
|
183
|
+
# @option opts [Boolean] :enable If false then the command is
|
184
|
+
# negated. Default is true.
|
194
185
|
# @option [Boolean] :default Configures the switchport trunk allowed
|
195
|
-
# vlans command using the default keyword
|
186
|
+
# vlans command using the default keyword. Default takes precedence
|
187
|
+
# over enable.
|
196
188
|
#
|
197
189
|
# @return [Boolean] returns true if the commands complete successfully
|
198
190
|
def set_trunk_allowed_vlans(name, opts = {})
|
199
191
|
value = opts[:value]
|
192
|
+
enable = opts.fetch(:enable, true)
|
200
193
|
default = opts[:default] || false
|
201
194
|
|
202
|
-
|
203
|
-
|
204
|
-
|
195
|
+
if value
|
196
|
+
fail ArgumentError, 'value must be an Array' unless value.is_a?(Array)
|
197
|
+
value = value.map(&:inspect).join(',')
|
198
|
+
end
|
205
199
|
|
206
|
-
cmds = ["interface #{name}"]
|
207
200
|
case default
|
208
201
|
when true
|
209
|
-
cmds
|
202
|
+
cmds = 'default switchport trunk allowed vlan'
|
210
203
|
when false
|
211
|
-
if
|
212
|
-
cmds
|
204
|
+
if !enable
|
205
|
+
cmds = 'no switchport trunk allowed vlan'
|
213
206
|
else
|
214
|
-
cmds
|
215
|
-
|
207
|
+
cmds = ['switchport trunk allowed vlan none',
|
208
|
+
"switchport trunk allowed vlan #{value}"]
|
216
209
|
end
|
217
210
|
end
|
218
|
-
|
211
|
+
configure_interface(name, cmds)
|
219
212
|
end
|
220
213
|
|
221
214
|
##
|
@@ -226,25 +219,15 @@ module Rbeapi
|
|
226
219
|
# @param [String] name The name of the interface to configure
|
227
220
|
# @param [Hash] opts The configuration parameters for the interface
|
228
221
|
# @option opts [string] :value The value of the trunk native vlan
|
229
|
-
# @option opts [Boolean] :
|
222
|
+
# @option :opts [Boolean] :enable If false then the command is
|
223
|
+
# negated. Default is true.
|
224
|
+
# @option opts [Boolean] :default The value should be set to default.
|
225
|
+
# Default takes precedence over enable.
|
230
226
|
#
|
231
227
|
# @return [Boolean] True if the commands succeed otherwise False
|
232
228
|
def set_trunk_native_vlan(name, opts = {})
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
cmds = ["interface #{name}"]
|
237
|
-
case default
|
238
|
-
when true
|
239
|
-
cmds << 'default switchport trunk native vlan'
|
240
|
-
when false
|
241
|
-
if value.nil?
|
242
|
-
cmds << 'no switchport trunk native vlan'
|
243
|
-
else
|
244
|
-
cmds << "switchport trunk native vlan #{value}"
|
245
|
-
end
|
246
|
-
end
|
247
|
-
configure(cmds)
|
229
|
+
cmd = command_builder('switchport trunk native vlan', opts)
|
230
|
+
configure_interface(name, cmd)
|
248
231
|
end
|
249
232
|
|
250
233
|
##
|
@@ -255,25 +238,15 @@ module Rbeapi
|
|
255
238
|
# @param [String] name The name of the interface to configure
|
256
239
|
# @param [Hash] opts The configuration parameters for the interface
|
257
240
|
# @option opts [string] :value The value of the access vlan
|
241
|
+
# @option opts [Boolean] :enable If false then the command is
|
242
|
+
# negated. Default is true.
|
258
243
|
# @option opts [Boolean] :default The value should be set to default
|
244
|
+
# Default takes precedence over enable.
|
259
245
|
#
|
260
246
|
# @return [Boolean] True if the commands succeed otherwise False
|
261
247
|
def set_access_vlan(name, opts = {})
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
cmds = ["interface #{name}"]
|
266
|
-
case default
|
267
|
-
when true
|
268
|
-
cmds << 'default switchport access vlan'
|
269
|
-
when false
|
270
|
-
if value.nil?
|
271
|
-
cmds << 'no switchport access vlan'
|
272
|
-
else
|
273
|
-
cmds << "switchport access vlan #{value}"
|
274
|
-
end
|
275
|
-
end
|
276
|
-
configure(cmds)
|
248
|
+
cmd = command_builder('switchport access vlan', opts)
|
249
|
+
configure_interface(name, cmd)
|
277
250
|
end
|
278
251
|
end
|
279
252
|
end
|
data/lib/rbeapi/api/system.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2014, Arista Networks, Inc.
|
2
|
+
# Copyright (c) 2014,2015, Arista Networks, Inc.
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -49,7 +49,7 @@ module Rbeapi
|
|
49
49
|
# hostname: <string>
|
50
50
|
# }
|
51
51
|
#
|
52
|
-
# @return [Hash] A Ruby hash
|
52
|
+
# @return [Hash] A Ruby hash object that provides the system settings as
|
53
53
|
# key/value pairs.
|
54
54
|
def get
|
55
55
|
response = {}
|
@@ -67,20 +67,14 @@ module Rbeapi
|
|
67
67
|
#
|
68
68
|
# @param [Hash] opts The configuration parameters
|
69
69
|
# @option opts [string] :value The value to set the hostname to
|
70
|
+
# @option :opts [Boolean] :enable If false then the command is
|
71
|
+
# negated. Default is true.
|
70
72
|
# @option opts [Boolean] :default The value should be set to default
|
71
73
|
#
|
72
74
|
# @return [Boolean] returns true if the command completed successfully
|
73
75
|
def set_hostname(opts = {})
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
case default
|
78
|
-
when true
|
79
|
-
cmds = ['default hostname']
|
80
|
-
when false
|
81
|
-
cmds = (value.nil? ? 'no hostname' : "hostname #{value}")
|
82
|
-
end
|
83
|
-
configure(cmds)
|
76
|
+
cmd = command_builder('hostname', opts)
|
77
|
+
configure(cmd)
|
84
78
|
end
|
85
79
|
end
|
86
80
|
end
|
data/lib/rbeapi/api/tacacs.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2014, Arista Networks, Inc.
|
2
|
+
# Copyright (c) 2014,2015, Arista Networks, Inc.
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -46,7 +46,7 @@ module Rbeapi
|
|
46
46
|
|
47
47
|
# Regular expression to extract a tacacs server's attributes from the
|
48
48
|
# running-configuration text. The explicit [ ] spaces enable line
|
49
|
-
#
|
49
|
+
# wrapping and indentation with the /x flag.
|
50
50
|
SERVER_REGEXP = /tacacs-server[ ]host[ ]([^\s]+)
|
51
51
|
(?:[ ](single-connection))?
|
52
52
|
(?:[ ]vrf[ ]([^\s]+))?
|
@@ -67,7 +67,7 @@ module Rbeapi
|
|
67
67
|
# * name: ('settings')
|
68
68
|
# * enable: (true | false) if tacacs functionality is enabled. This is
|
69
69
|
# always true for EOS.
|
70
|
-
# * key: (String) the key either in
|
70
|
+
# * key: (String) the key either in plain text or hashed format
|
71
71
|
# * key_format: (Integer) e.g. 0 or 7
|
72
72
|
# * timeout: (Integer) seconds before the timeout period ends
|
73
73
|
#
|
@@ -130,7 +130,7 @@ module Rbeapi
|
|
130
130
|
#
|
131
131
|
# * hostname: hostname or ip address, part of the identifier
|
132
132
|
# * port: (Fixnum) TCP port of the server, part of the identifier
|
133
|
-
# * key: (String) the key either in
|
133
|
+
# * key: (String) the key either in plain text or hashed format
|
134
134
|
# * key_format: (Fixnum) e.g. 0 or 7
|
135
135
|
# * timeout: (Fixnum) seconds before the timeout period ends
|
136
136
|
# * multiplex: (Boolean) true when configured to make requests through a
|
@@ -161,7 +161,7 @@ module Rbeapi
|
|
161
161
|
#
|
162
162
|
# @option opts [String] :key ('070E234F1F5B4A') The key value
|
163
163
|
#
|
164
|
-
# @option opts [Fixnum] :key_format (7) The key format, 0 for
|
164
|
+
# @option opts [Fixnum] :key_format (7) The key format, 0 for plain text
|
165
165
|
# and 7 for a hashed value. 7 will be assumed if this option is not
|
166
166
|
# provided.
|
167
167
|
#
|
@@ -180,27 +180,18 @@ module Rbeapi
|
|
180
180
|
# set_timeout configures the tacacs default timeout. This method maps to
|
181
181
|
# the `tacacs-server timeout` setting.
|
182
182
|
#
|
183
|
-
# @
|
184
|
-
#
|
183
|
+
# @param [Hash] opts The configuration parameters
|
184
|
+
# @option opts [string] :value The value to set the timeout to
|
185
|
+
# @option :opts [Boolean] :enable If false then the command is
|
186
|
+
# negated. Default is true.
|
187
|
+
# @option opts [Boolean] :default The value should be set to default
|
185
188
|
#
|
186
189
|
# @api public
|
187
190
|
#
|
188
191
|
# @return [Boolean] true if no errors
|
189
192
|
def set_global_timeout(opts = {})
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
case default
|
194
|
-
when true
|
195
|
-
cmds = 'default tacacs-server timeout'
|
196
|
-
when false
|
197
|
-
if value
|
198
|
-
cmds = "tacacs-server timeout #{value}"
|
199
|
-
else
|
200
|
-
cmds = 'no tacacs-server timeout'
|
201
|
-
end
|
202
|
-
end
|
203
|
-
configure cmds
|
193
|
+
cmd = command_builder('tacacs-server timeout', opts)
|
194
|
+
configure cmd
|
204
195
|
end
|
205
196
|
|
206
197
|
##
|
data/lib/rbeapi/api/varp.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2014, Arista Networks, Inc.
|
2
|
+
# Copyright (c) 2014,2015, Arista Networks, Inc.
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -75,24 +75,14 @@ module Rbeapi
|
|
75
75
|
#
|
76
76
|
# @param [Hash] opts The configuration parameters
|
77
77
|
# @option opts [string] :value The value to set the mac-address to
|
78
|
+
# @option opts [Boolean] :enable If false then the command is
|
79
|
+
# negated. Default is true.
|
78
80
|
# @option opts [Boolean] :default The value should be set to default
|
79
81
|
#
|
80
82
|
# @return [Boolean] returns true if the command completed successfully
|
81
83
|
def set_mac_address(opts = {})
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
case default
|
86
|
-
when true
|
87
|
-
cmds = ['default ip virtual-router mac-address']
|
88
|
-
when false
|
89
|
-
if value
|
90
|
-
cmds = "ip virtual-router mac-address #{value}"
|
91
|
-
else
|
92
|
-
cmds = 'no ip virtual-router mac-address'
|
93
|
-
end
|
94
|
-
end
|
95
|
-
configure(cmds)
|
84
|
+
cmd = command_builder('ip virtual-router mac-address', opts)
|
85
|
+
configure(cmd)
|
96
86
|
end
|
97
87
|
end
|
98
88
|
|
@@ -113,7 +103,7 @@ module Rbeapi
|
|
113
103
|
# values for. This must be the full interface identifier.
|
114
104
|
#
|
115
105
|
# @return [nil, Hash<String, String>] A Ruby hash that represents the
|
116
|
-
# VARP interface
|
106
|
+
# VARP interface configuration. A nil object is returned if the
|
117
107
|
# specified interface is not configured
|
118
108
|
def get(name)
|
119
109
|
config = get_block("^interface #{name}")
|
@@ -133,7 +123,7 @@ module Rbeapi
|
|
133
123
|
# }
|
134
124
|
#
|
135
125
|
# @return [nil, Hash<String, String>] A Ruby hash that represents the
|
136
|
-
# MLAG interface
|
126
|
+
# MLAG interface configuration. A nil object is returned if no
|
137
127
|
# interfaces are configured.
|
138
128
|
def getall
|
139
129
|
interfaces = config.scan(/(?<=^interface\s)(Vl.+)$/)
|
@@ -144,30 +134,39 @@ module Rbeapi
|
|
144
134
|
end
|
145
135
|
|
146
136
|
##
|
147
|
-
#
|
137
|
+
# The set_addresses method assigns one or more virtual IPv4 address
|
138
|
+
# to the specified VLAN interface. All existing addresses are
|
139
|
+
# removed before the ones in value are added.
|
148
140
|
#
|
149
|
-
# @param [String] :name The name of the interface
|
141
|
+
# @param [String] :name The name of the interface. The
|
150
142
|
# name argument must be the full interface name. Valid interfaces
|
151
|
-
# are restricted to
|
152
|
-
# @param [
|
153
|
-
#
|
143
|
+
# are restricted to VLAN interfaces
|
144
|
+
# @param [Hash] opts The configuration parameters
|
145
|
+
# @option opts [Array] :value Array of IPv4 addresses to add to
|
146
|
+
# the virtual router.
|
147
|
+
# @option opts [Boolean] :enable If false then the command is
|
148
|
+
# negated. Default is true.
|
149
|
+
# @option opts [Boolean] :default The value should be set to default
|
154
150
|
#
|
155
151
|
# @return [Boolean] True if the commands succeeds otherwise False
|
156
152
|
def set_addresses(name, opts = {})
|
157
153
|
value = opts[:value]
|
154
|
+
enable = opts.fetch(:enable, true)
|
158
155
|
default = opts[:default] || false
|
159
156
|
|
160
157
|
case default
|
161
158
|
when true
|
162
|
-
|
159
|
+
configure(["interface #{name}", 'default ip virtual-router address'])
|
163
160
|
when false
|
164
161
|
get(name)['addresses'].each do |addr|
|
165
162
|
result = remove_address(name, addr)
|
166
163
|
return result unless result
|
167
164
|
end
|
168
|
-
|
169
|
-
|
170
|
-
|
165
|
+
if enable
|
166
|
+
value.each do |addr|
|
167
|
+
result = add_address(name, addr)
|
168
|
+
return result unless result
|
169
|
+
end
|
171
170
|
end
|
172
171
|
end
|
173
172
|
true
|