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
@@ -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
|
@@ -132,7 +132,7 @@ module Rbeapi
|
|
132
132
|
private :parse_mtu
|
133
133
|
|
134
134
|
##
|
135
|
-
# parse_helper_addresses scans the provided
|
135
|
+
# parse_helper_addresses scans the provided configuration block and
|
136
136
|
# extracts any configured IP helper address values. The interface could
|
137
137
|
# be configured with one or more helper addresses. If no helper
|
138
138
|
# addresses are configured, then an empty array is set in the return
|
@@ -194,12 +194,13 @@ module Rbeapi
|
|
194
194
|
end
|
195
195
|
|
196
196
|
##
|
197
|
-
# set_address configures a logical IP interface with an address.
|
198
|
-
# address value must be in the form of A.B.C.D/E. If
|
199
|
-
#
|
200
|
-
# keyword. If the default option is set to true, then the
|
201
|
-
# value is defaulted using the default keyword. The
|
202
|
-
# precedence over the
|
197
|
+
# set_address configures a logical IP interface with an address.
|
198
|
+
# The address value must be in the form of A.B.C.D/E. If the enable
|
199
|
+
# keyword is false, then the interface address is negated using the
|
200
|
+
# config no keyword. If the default option is set to true, then the
|
201
|
+
# ip address # value is defaulted using the default keyword. The
|
202
|
+
# default keyword has precedence over the enable keyword if both
|
203
|
+
# options are specified
|
203
204
|
#
|
204
205
|
# @eos_version 4.13.7M
|
205
206
|
#
|
@@ -218,30 +219,24 @@ module Rbeapi
|
|
218
219
|
# for the specified interface name. The value must be in the form
|
219
220
|
# of A.B.C.D/E
|
220
221
|
#
|
222
|
+
# @option :opts [Boolean] :enable If false then the command is
|
223
|
+
# negated. Default is true.
|
224
|
+
#
|
221
225
|
# @option :opts [Boolean] :default Configure the ip address value using
|
222
226
|
# the default keyword
|
223
227
|
#
|
224
228
|
# @return [Boolean] returns true if the command completed successfully
|
225
229
|
def set_address(name, opts = {})
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
cmds = ["interface #{name}"]
|
230
|
-
case default
|
231
|
-
when true
|
232
|
-
cmds << 'default ip address'
|
233
|
-
when false
|
234
|
-
cmds << (value.nil? ? 'no ip address' : "ip address #{value}")
|
235
|
-
end
|
236
|
-
configure cmds
|
230
|
+
cmds = command_builder('ip address', opts)
|
231
|
+
configure_interface(name, cmds)
|
237
232
|
end
|
238
233
|
|
239
234
|
##
|
240
235
|
# set_mtu configures the IP mtu value of the ip interface in the nodes
|
241
|
-
# configuration. If the
|
242
|
-
# configured using the no keyword. If the default
|
236
|
+
# configuration. If the enable option is false, then the ip mtu value is
|
237
|
+
# configured using the no keyword. If the default keyword option is
|
243
238
|
# provided and set to true then the ip mtu value is configured using the
|
244
|
-
# default keyword. The default keyword has precedence over the
|
239
|
+
# default keyword. The default keyword has precedence over the enable
|
245
240
|
# keyword if both options are specified.
|
246
241
|
#
|
247
242
|
# @eos_version 4.13.7M
|
@@ -261,22 +256,16 @@ module Rbeapi
|
|
261
256
|
# the nodes configuration. Valid values are in the range of 68 to 9214
|
262
257
|
# bytes. The default is 1500 bytes
|
263
258
|
#
|
259
|
+
# @option :opts [Boolean] :enable If false then the command is
|
260
|
+
# negated. Default is true.
|
261
|
+
#
|
264
262
|
# @option :opts [Boolean] :default Configure the ip mtu value using
|
265
263
|
# the default keyword
|
266
264
|
#
|
267
265
|
# @return [Boolean] returns true if the command completed successfully
|
268
266
|
def set_mtu(name, opts = {})
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
cmds = ["interface #{name}"]
|
273
|
-
case default
|
274
|
-
when true
|
275
|
-
cmds << 'default mtu'
|
276
|
-
when false
|
277
|
-
cmds << (value.nil? ? 'no mtu' : "mtu #{value}")
|
278
|
-
end
|
279
|
-
configure cmds
|
267
|
+
cmds = command_builder('mtu', opts)
|
268
|
+
configure_interface(name, cmds)
|
280
269
|
end
|
281
270
|
|
282
271
|
##
|
@@ -309,21 +298,17 @@ module Rbeapi
|
|
309
298
|
#
|
310
299
|
def set_helper_addresses(name, opts = {})
|
311
300
|
value = opts[:value]
|
301
|
+
enable = opts.fetch(:enable, true)
|
312
302
|
default = opts[:default] || false
|
313
303
|
|
314
|
-
cmds = ["interface #{name}"]
|
315
304
|
case default
|
316
305
|
when true
|
317
|
-
cmds
|
306
|
+
cmds = 'default ip helper-address'
|
318
307
|
when false
|
319
|
-
|
320
|
-
|
321
|
-
else
|
322
|
-
cmds << 'no ip helper-address'
|
323
|
-
value.each { |addr| cmds << "ip helper-address #{addr}" }
|
324
|
-
end
|
308
|
+
cmds = ['no ip helper-address']
|
309
|
+
value.each { |addr| cmds << "ip helper-address #{addr}" } if enable
|
325
310
|
end
|
326
|
-
|
311
|
+
configure_interface(name, cmds)
|
327
312
|
end
|
328
313
|
end
|
329
314
|
end
|
data/lib/rbeapi/api/logging.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
|
@@ -83,13 +83,11 @@ module Rbeapi
|
|
83
83
|
|
84
84
|
##
|
85
85
|
# set_enable configures the global logging instance on the node as either
|
86
|
-
# enabled or disabled. If the
|
87
|
-
# globally enabled and if set to false, it is globally disabled. If
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
# The default keyword option takes precedence over the value keyword if
|
92
|
-
# both options are specified.
|
86
|
+
# enabled or disabled. If the enable keyword is set to true then logging
|
87
|
+
# is globally enabled and if set to false, it is globally disabled. If
|
88
|
+
# the default keyword is specified and set to true, then the configuration
|
89
|
+
# is defaulted using the default keyword. The default keyword option
|
90
|
+
# takes precedence over the enable keyword if both options are specified.
|
93
91
|
#
|
94
92
|
# @eos_version 4.13.7M
|
95
93
|
#
|
@@ -100,23 +98,15 @@ module Rbeapi
|
|
100
98
|
#
|
101
99
|
# @param [Hash] :opts Optional keyword arguments
|
102
100
|
#
|
103
|
-
# @option :opts [Boolean] :
|
104
|
-
# or disabled logging
|
101
|
+
# @option :opts [Boolean] :enable Enables logging globally if value is
|
102
|
+
# true or disabled logging globally if value is false
|
105
103
|
#
|
106
104
|
# @option :opts [Boolean] :default Configure the ip address value using
|
107
105
|
# the default keyword
|
108
106
|
#
|
109
107
|
# @return [Boolean] returns true if the command completed successfully
|
110
108
|
def set_enable(opts = {})
|
111
|
-
|
112
|
-
default = opts[:default] || false
|
113
|
-
|
114
|
-
case default
|
115
|
-
when true
|
116
|
-
cmd = 'default logging on'
|
117
|
-
when false
|
118
|
-
cmd = value ? 'logging on' : 'no logging on'
|
119
|
-
end
|
109
|
+
cmd = command_builder('logging on', opts)
|
120
110
|
configure cmd
|
121
111
|
end
|
122
112
|
|
data/lib/rbeapi/api/mlag.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
|
@@ -48,7 +48,7 @@ module Rbeapi
|
|
48
48
|
|
49
49
|
##
|
50
50
|
# get scans the current nodes configuration and returns the values as
|
51
|
-
# a Hash
|
51
|
+
# a Hash describing the current state.
|
52
52
|
#
|
53
53
|
# The resource hash returned contains the following:
|
54
54
|
# * domain_id: (String) The MLAG domain-id value
|
@@ -169,7 +169,7 @@ module Rbeapi
|
|
169
169
|
private :parse_shutdown
|
170
170
|
|
171
171
|
##
|
172
|
-
# parse_interfaces scans the global
|
172
|
+
# parse_interfaces scans the global configuration and returns all of the
|
173
173
|
# configured MLAG interfaces. Each interface returns the configured MLAG
|
174
174
|
# identifier for establishing a MLAG peer. The return value is intended
|
175
175
|
# to be merged into the resource Hash
|
@@ -193,10 +193,10 @@ module Rbeapi
|
|
193
193
|
|
194
194
|
##
|
195
195
|
# set_domain_id configures the mlag domain-id value in the current nodes
|
196
|
-
# running configuration. If the
|
197
|
-
# domain-id is configured with the no keyword. If the default keyword
|
198
|
-
# provided, the configuration is defaulted using the default keyword.
|
199
|
-
# The default keyword takes precedence over the
|
196
|
+
# running configuration. If the enable keyword is false, the the
|
197
|
+
# domain-id is configured with the no keyword. If the default keyword
|
198
|
+
# is provided, the configuration is defaulted using the default keyword.
|
199
|
+
# The default keyword takes precedence over the enable keyword if both
|
200
200
|
# options are specified
|
201
201
|
#
|
202
202
|
# @eos_version 4.13.7M
|
@@ -209,34 +209,29 @@ module Rbeapi
|
|
209
209
|
#
|
210
210
|
# @param [Hash] :opts Optional keyword arguments
|
211
211
|
#
|
212
|
-
# @option :opts [String] :value The value to
|
212
|
+
# @option :opts [String] :value The value to configure the mlag
|
213
213
|
# domain-id to.
|
214
214
|
#
|
215
|
+
# @option :opts [Boolean] :enable If false then the command is
|
216
|
+
# negated. Default is true.
|
217
|
+
#
|
215
218
|
# @option :opts [Boolean] :default Configure the domain-id value using
|
216
219
|
# the default keyword
|
217
220
|
#
|
218
221
|
# @return [Boolean] returns true if the command completed successfully
|
219
222
|
def set_domain_id(opts = {})
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
cmds = ['mlag configuration']
|
224
|
-
case default
|
225
|
-
when true
|
226
|
-
cmds << 'default domain-id'
|
227
|
-
when false
|
228
|
-
cmds << (value ? "domain-id #{value}" : 'no domain-id')
|
229
|
-
end
|
223
|
+
cmd = command_builder('domain-id', opts)
|
224
|
+
cmds = ['mlag configuration', cmd]
|
230
225
|
configure(cmds)
|
231
226
|
end
|
232
227
|
|
233
228
|
##
|
234
229
|
# set_local_interface configures the mlag local-interface value in the
|
235
|
-
# current nodes running configuration. If the
|
236
|
-
#
|
230
|
+
# current nodes running configuration. If the enable keyword is false,
|
231
|
+
# the local-interface is configured with the no keyword. If
|
237
232
|
# the default keyword is provided, the configuration is defaulted using
|
238
233
|
# the default keyword. The default keyword takes precedence over the
|
239
|
-
#
|
234
|
+
# enable keyword if both options are specified
|
240
235
|
#
|
241
236
|
# @eos_version 4.13.7M
|
242
237
|
#
|
@@ -248,34 +243,29 @@ module Rbeapi
|
|
248
243
|
#
|
249
244
|
# @param [Hash] :opts Optional keyword arguments
|
250
245
|
#
|
251
|
-
# @option :opts [String] :value The value to
|
246
|
+
# @option :opts [String] :value The value to configure the mlag
|
252
247
|
# local-interface to. The local-interface accepts full interface
|
253
248
|
# identifiers and expects a Vlan interface
|
254
249
|
#
|
250
|
+
# @option :opts [Boolean] :enable If false then the command is
|
251
|
+
# negated. Default is true.
|
252
|
+
#
|
255
253
|
# @option :opts [Boolean] :default Configure the local-interface value
|
256
254
|
# using the default keyword
|
257
255
|
#
|
258
256
|
# @return [Boolean] returns true if the command completed successfully
|
259
257
|
def set_local_interface(opts = {})
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
cmds = ['mlag configuration']
|
264
|
-
case default
|
265
|
-
when true
|
266
|
-
cmds << 'default local-interface'
|
267
|
-
when false
|
268
|
-
cmds << (value ? "local-interface #{value}" : 'no local-interface')
|
269
|
-
end
|
258
|
+
cmd = command_builder('local-interface', opts)
|
259
|
+
cmds = ['mlag configuration', cmd]
|
270
260
|
configure(cmds)
|
271
261
|
end
|
272
262
|
|
273
263
|
##
|
274
264
|
# set_peer_link configures the mlag peer-link value in the current nodes
|
275
|
-
# running configuration. If
|
265
|
+
# running configuration. If enable keyword is false, then the
|
276
266
|
# peer-link is configured with the no keyword. If the default keyword
|
277
267
|
# is provided, the configuration is defaulted using the default keyword.
|
278
|
-
# The default keyword takes precedence over the
|
268
|
+
# The default keyword takes precedence over the enable keyword if both
|
279
269
|
# options are specified
|
280
270
|
#
|
281
271
|
# @eos_version 4.13.7M
|
@@ -288,34 +278,29 @@ module Rbeapi
|
|
288
278
|
#
|
289
279
|
# @param [Hash] :opts Optional keyword arguments
|
290
280
|
#
|
291
|
-
# @option :opts [String] :value The value to
|
281
|
+
# @option :opts [String] :value The value to configure the mlag
|
292
282
|
# peer-link to. The peer-link accepts full interface identifiers
|
293
|
-
# and expects an Ethernet or Port-Channel
|
283
|
+
# and expects an Ethernet or Port-Channel interface
|
284
|
+
#
|
285
|
+
# @option :opts [Boolean] :enable If false then the command is
|
286
|
+
# negated. Default is true.
|
294
287
|
#
|
295
288
|
# @option :opts [Boolean] :default Configure the peer-link using the
|
296
289
|
# default keyword
|
297
290
|
#
|
298
291
|
# @return [Boolean] returns true if the command completed successfully
|
299
292
|
def set_peer_link(opts = {})
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
cmds = ['mlag configuration']
|
304
|
-
case default
|
305
|
-
when true
|
306
|
-
cmds << 'default peer-link'
|
307
|
-
when false
|
308
|
-
cmds << (value ? "peer-link #{value}" : 'no peer-link')
|
309
|
-
end
|
293
|
+
cmd = command_builder('peer-link', opts)
|
294
|
+
cmds = ['mlag configuration', cmd]
|
310
295
|
configure(cmds)
|
311
296
|
end
|
312
297
|
|
313
298
|
##
|
314
299
|
# set_peer_address configures the mlag peer-address value in the current
|
315
|
-
# nodes running configuration. If the
|
300
|
+
# nodes running configuration. If the enable keyword is false, then the
|
316
301
|
# peer-address is configured with the no keyword. If the default keyword
|
317
302
|
# is provided, the configuration is defaulted using the default keyword.
|
318
|
-
# The default keyword takes precedence over the
|
303
|
+
# The default keyword takes precedence over the enable keyword if both
|
319
304
|
# options are specified
|
320
305
|
#
|
321
306
|
# @eos_version 4.13.7M
|
@@ -328,36 +313,30 @@ module Rbeapi
|
|
328
313
|
#
|
329
314
|
# @param [Hash] :opts Optional keyword arguments
|
330
315
|
#
|
331
|
-
# @option :opts [String] :value The value to
|
316
|
+
# @option :opts [String] :value The value to configure the mlag
|
332
317
|
# peer-address to. The peer-address accepts an IP address in the form
|
333
318
|
# of A.B.C.D/E
|
334
319
|
#
|
320
|
+
# @option :opts [Boolean] :enable If false then the command is
|
321
|
+
# negated. Default is true.
|
322
|
+
#
|
335
323
|
# @option :opts [Boolean] :default Configure the peer-address using the
|
336
324
|
# default keyword
|
337
325
|
#
|
338
326
|
# @return [Boolean] returns true if the command completed successfully
|
339
327
|
def set_peer_address(opts = {})
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
cmds = ['mlag configuration']
|
344
|
-
case default
|
345
|
-
when true
|
346
|
-
cmds << 'default peer-address'
|
347
|
-
when false
|
348
|
-
cmds << (value ? "peer-address #{value}" : 'no peer-address')
|
349
|
-
end
|
328
|
+
cmd = command_builder('peer-address', opts)
|
329
|
+
cmds = ['mlag configuration', cmd]
|
350
330
|
configure(cmds)
|
351
331
|
end
|
352
332
|
|
353
333
|
##
|
354
334
|
# set_shutdown configures the administrative state of the mlag process on
|
355
|
-
# the current node. If the
|
356
|
-
# the
|
357
|
-
#
|
358
|
-
# the default keyword is provided, the configuration is defaulted using
|
335
|
+
# the current node. If the enable keyword is true, then mlag is enabled
|
336
|
+
# and if the enable keyword is false, then mlag is disabled. If the
|
337
|
+
# default keyword is provided, the configuration is defaulted using
|
359
338
|
# the default keyword. The default keyword takes precedence over the
|
360
|
-
#
|
339
|
+
# enable keyword if both options are specified
|
361
340
|
#
|
362
341
|
# @eos_version 4.13.7M
|
363
342
|
#
|
@@ -369,34 +348,31 @@ module Rbeapi
|
|
369
348
|
#
|
370
349
|
# @param [Hash] :opts Optional keyword arguments
|
371
350
|
#
|
372
|
-
# @option :opts [Boolean] :
|
373
|
-
#
|
351
|
+
# @option :opts [Boolean] :enable True if the interface should be
|
352
|
+
# administratively enabled or false if the interface should be
|
353
|
+
# administratively disabled.
|
374
354
|
#
|
375
355
|
# @option :opts [Boolean] :default Configure the shutdown value using the
|
376
356
|
# default keyword
|
377
357
|
#
|
378
358
|
# @return [Boolean] returns true if the command completed successfully
|
379
359
|
def set_shutdown(opts = {})
|
380
|
-
value
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
cmds << 'default shutdown'
|
387
|
-
when false
|
388
|
-
cmds << (value ? 'shutdown' : 'no shutdown')
|
389
|
-
end
|
360
|
+
fail 'set_shutdown has the value option set' if opts[:value]
|
361
|
+
# Shutdown semantics are opposite of enable semantics so invert enable
|
362
|
+
value = !opts[:enable]
|
363
|
+
opts.merge!(enable: value)
|
364
|
+
cmd = command_builder('shutdown', opts)
|
365
|
+
cmds = ['mlag configuration', cmd]
|
390
366
|
configure(cmds)
|
391
367
|
end
|
392
368
|
|
393
369
|
##
|
394
370
|
# set_mlag_id configures the mlag id on the interface in the nodes
|
395
|
-
# current running configuration. If the
|
371
|
+
# current running configuration. If the enable keyword is false, then the
|
396
372
|
# interface mlag id is configured using the no keyword. If the default
|
397
373
|
# keyword is provided and set to true, the interface mlag id is
|
398
374
|
# configured using the default keyword. The default keyword takes
|
399
|
-
# precedence over the
|
375
|
+
# precedence over the enable keyword if both options are specified
|
400
376
|
#
|
401
377
|
# @eos_version 4.13.7M
|
402
378
|
#
|
@@ -407,7 +383,7 @@ module Rbeapi
|
|
407
383
|
# default mlag
|
408
384
|
#
|
409
385
|
# @param [String] :name The full interface identifier of the interface
|
410
|
-
# to
|
386
|
+
# to configure th mlag id for.
|
411
387
|
#
|
412
388
|
# @param [Hash] :opts Optional keyword arguments
|
413
389
|
#
|
@@ -415,22 +391,16 @@ module Rbeapi
|
|
415
391
|
# interface mlag to. The mlag id should be in the valid range of 1 to
|
416
392
|
# 2000
|
417
393
|
#
|
394
|
+
# @option :opts [Boolean] :enable If false then the command is
|
395
|
+
# negated. Default is true.
|
396
|
+
#
|
418
397
|
# @option :opts [Boolean] :default Configure the mlag value using the
|
419
398
|
# default keyword
|
420
399
|
#
|
421
400
|
# @return [Boolean] returns true if the command completed successfully
|
422
401
|
def set_mlag_id(name, opts = {})
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
cmds = ["interface #{name}"]
|
427
|
-
case default
|
428
|
-
when true
|
429
|
-
cmds << 'default mlag'
|
430
|
-
when false
|
431
|
-
cmds << (value ? "mlag #{value}" : 'no mlag')
|
432
|
-
end
|
433
|
-
configure(cmds)
|
402
|
+
cmd = command_builder('mlag', opts)
|
403
|
+
configure_interface(name, cmd)
|
434
404
|
end
|
435
405
|
end
|
436
406
|
end
|
data/lib/rbeapi/api/ntp.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
|
@@ -38,8 +38,8 @@ module Rbeapi
|
|
38
38
|
# Api is module namesapce for working with the EOS command API
|
39
39
|
module Api
|
40
40
|
##
|
41
|
-
# The Ntp class provides an
|
42
|
-
# NTP
|
41
|
+
# The Ntp class provides an instance for working with the nodes
|
42
|
+
# NTP configuration.
|
43
43
|
class Ntp < Entity
|
44
44
|
DEFAULT_SRC_INTF = ''
|
45
45
|
|
@@ -82,7 +82,7 @@ module Rbeapi
|
|
82
82
|
# parse_servers scans the nodes configuration and parses the configured
|
83
83
|
# ntp server host names and/or addresses. This method will also return
|
84
84
|
# the value of prefer. If no servers are configured, the value will be
|
85
|
-
# set to an empty array. The return hash is
|
85
|
+
# set to an empty array. The return hash is intended to be merged into
|
86
86
|
# the resource hash
|
87
87
|
#
|
88
88
|
# @api private
|
@@ -98,39 +98,34 @@ module Rbeapi
|
|
98
98
|
|
99
99
|
##
|
100
100
|
# set_source_interface configures the ntp source value in the nodes
|
101
|
-
# running configuration. If
|
101
|
+
# running configuration. If the enable keyword is false, then
|
102
102
|
# the ntp source is configured with the no keyword argument. If the
|
103
103
|
# default keyword argument is provided and set to true, the value is
|
104
104
|
# configured used the default keyword. The default keyword takes
|
105
|
-
# precedence over the
|
105
|
+
# precedence over the enable keyword if both options are specified.
|
106
106
|
#
|
107
107
|
# @eos_version 4.13.7M
|
108
108
|
#
|
109
109
|
# @commands
|
110
110
|
# ntp source <value>
|
111
111
|
# no ntp source
|
112
|
-
#
|
112
|
+
# default ntp source
|
113
113
|
#
|
114
114
|
# @param [Hash] :opts Optional keyword arguments
|
115
115
|
#
|
116
116
|
# @option :opts [String] :value The value to configure the ntp source
|
117
117
|
# in the nodes configuration
|
118
118
|
#
|
119
|
+
# @option :opts [Boolean] :enable If false then the command is
|
120
|
+
# negated. Default is true.
|
121
|
+
#
|
119
122
|
# @option :opts [Boolean] :default Configure the ntp source value using
|
120
123
|
# the default keyword
|
121
124
|
#
|
122
125
|
# @return [Boolean] returns true if the command completed successfully
|
123
126
|
def set_source_interface(opts = {})
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
case default
|
128
|
-
when true
|
129
|
-
cmds = 'default ntp source'
|
130
|
-
when false
|
131
|
-
cmds = (value ? "ntp source #{value}" : 'no ntp source')
|
132
|
-
end
|
133
|
-
configure(cmds)
|
127
|
+
cmd = command_builder('ntp source', opts)
|
128
|
+
configure(cmd)
|
134
129
|
end
|
135
130
|
|
136
131
|
##
|
data/lib/rbeapi/api/ospf.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
|
@@ -52,7 +52,7 @@ module Rbeapi
|
|
52
52
|
# "areas": {
|
53
53
|
# <string>: array<string>
|
54
54
|
# },
|
55
|
-
# "
|
55
|
+
# "redistribute"
|
56
56
|
# }
|
57
57
|
#
|
58
58
|
# @return [Hash] A Ruby hash object that provides the OSPF settings as
|
@@ -117,16 +117,8 @@ module Rbeapi
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def set_router_id(pid, opts = {})
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
cmds = ["router ospf #{pid}"]
|
124
|
-
case default
|
125
|
-
when true
|
126
|
-
cmds << 'default router-id'
|
127
|
-
when false
|
128
|
-
cmds << (value ? "router-id #{value}" : 'no router-id')
|
129
|
-
end
|
120
|
+
cmd = command_builder('router-id', opts)
|
121
|
+
cmds = ["router ospf #{pid}", cmd]
|
130
122
|
configure cmds
|
131
123
|
end
|
132
124
|
|
@@ -163,7 +155,7 @@ module Rbeapi
|
|
163
155
|
# values for. This must be the full interface identifier.
|
164
156
|
#
|
165
157
|
# @return [nil, Hash<String, String>] A Ruby hash that represents the
|
166
|
-
# MLAG interface
|
158
|
+
# MLAG interface configuration. A nil object is returned if the
|
167
159
|
# specified interface is not configured
|
168
160
|
def get(name)
|
169
161
|
config = get_block("interface #{name}")
|
@@ -187,7 +179,7 @@ module Rbeapi
|
|
187
179
|
# }
|
188
180
|
#
|
189
181
|
# @return [nil, Hash<String, String>] A Ruby hash that represents the
|
190
|
-
# MLAG interface
|
182
|
+
# MLAG interface configuration. A nil object is returned if no
|
191
183
|
# interfaces are configured.
|
192
184
|
def getall
|
193
185
|
interfaces = config.scan(/(?<=interface\s)[Et|Po|Lo|Vl].+/)
|
@@ -199,18 +191,9 @@ module Rbeapi
|
|
199
191
|
|
200
192
|
def set_network_type(name, opts = {})
|
201
193
|
value = opts[:value]
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
cmds = ["interface #{name}"]
|
207
|
-
case default
|
208
|
-
when true
|
209
|
-
cmds << 'default ip ospf network'
|
210
|
-
when false
|
211
|
-
cmds << (value ? "ip ospf network #{value}" : 'no ip ospf netework')
|
212
|
-
end
|
213
|
-
configure(cmds)
|
194
|
+
return false unless [nil, 'point-to-point'].include?(value)
|
195
|
+
cmd = command_builder('ip ospf network', opts)
|
196
|
+
configure_interface(name, cmd)
|
214
197
|
end
|
215
198
|
end
|
216
199
|
end
|