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/mlag.rb
CHANGED
@@ -32,14 +32,14 @@
|
|
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 Mlag class provides a configuration instance for working with
|
42
|
-
# the global MLAG configuration of the node
|
42
|
+
# the global MLAG configuration of the node.
|
43
43
|
class Mlag < Entity
|
44
44
|
DEFAULT_DOMAIN_ID = ''
|
45
45
|
DEFAULT_LOCAL_INTF = ''
|
@@ -73,8 +73,8 @@ module Rbeapi
|
|
73
73
|
# @see parse_interfaces
|
74
74
|
#
|
75
75
|
# @return [nil, Hash<Symbol, Object] returns the nodes current running
|
76
|
-
# configuration as a Hash.
|
77
|
-
# method will return nil
|
76
|
+
# configuration as a Hash. If mlag is not configured on the node this
|
77
|
+
# method will return nil.
|
78
78
|
def get
|
79
79
|
config = get_block('mlag configuration')
|
80
80
|
|
@@ -90,16 +90,16 @@ module Rbeapi
|
|
90
90
|
|
91
91
|
##
|
92
92
|
# parse_domain_id scans the current nodes running configuration and
|
93
|
-
# extracts the mlag domain-id value.
|
94
|
-
# configured, then this method will return DEFAULT_DOMAIN_ID.
|
95
|
-
# value is intended to be merged into the resource hash
|
93
|
+
# extracts the mlag domain-id value. If the mlag domain-id has not been
|
94
|
+
# configured, then this method will return DEFAULT_DOMAIN_ID. The return
|
95
|
+
# value is intended to be merged into the resource hash.
|
96
96
|
#
|
97
97
|
# @api private
|
98
98
|
#
|
99
|
-
# @param [String]
|
99
|
+
# @param config [String] The mlag configuration block retrieved from the
|
100
100
|
# nodes current running configuration.
|
101
101
|
#
|
102
|
-
# @return [Hash<Symbol, Object>] resource hash attribute
|
102
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
103
103
|
def parse_domain_id(config)
|
104
104
|
mdata = /(?<=\s{3}domain-id\s)(.+)$/.match(config)
|
105
105
|
{ domain_id: mdata.nil? ? DEFAULT_DOMAIN_ID : mdata[1] }
|
@@ -108,16 +108,16 @@ module Rbeapi
|
|
108
108
|
|
109
109
|
##
|
110
110
|
# parse_local_interface scans the current nodes running configuration and
|
111
|
-
# extracts the mlag local-interface value.
|
111
|
+
# extracts the mlag local-interface value. If the mlag local-interface
|
112
112
|
# has not been configured, this method will return DEFAULT_LOCAL_INTF.
|
113
|
-
# The return value is intended to be merged into the resource hash
|
113
|
+
# The return value is intended to be merged into the resource hash.
|
114
114
|
#
|
115
115
|
# @api private
|
116
116
|
#
|
117
|
-
# @param [String]
|
117
|
+
# @param config [String] The mlag configuration block retrieved from the
|
118
118
|
# nodes current running configuration.
|
119
119
|
#
|
120
|
-
# @return [Hash<Symbol, Object>] resource hash attribute
|
120
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
121
121
|
def parse_local_interface(config)
|
122
122
|
mdata = /(?<=\s{3}local-interface\s)(.+)$/.match(config)
|
123
123
|
{ local_interface: mdata.nil? ? DEFAULT_LOCAL_INTF : mdata[1] }
|
@@ -126,16 +126,16 @@ module Rbeapi
|
|
126
126
|
|
127
127
|
##
|
128
128
|
# parse_peer_address scans the current nodes running configuration and
|
129
|
-
# extracts the mlag peer-address value.
|
130
|
-
# been configured, this method will return DEFAULT_PEER_ADDR.
|
129
|
+
# extracts the mlag peer-address value. If the mlag peer-address has not
|
130
|
+
# been configured, this method will return DEFAULT_PEER_ADDR. The return
|
131
131
|
# value is intended to be merged into the resource hash.
|
132
132
|
#
|
133
133
|
# @api private
|
134
134
|
#
|
135
|
-
# @param [String]
|
135
|
+
# @param config [String] The mlag configuration block retrieved from the
|
136
136
|
# nodes current running configuration.
|
137
137
|
#
|
138
|
-
# @return [Hash<Symbol, Object>] resource hash attribute
|
138
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
139
139
|
def parse_peer_address(config)
|
140
140
|
mdata = /(?<=\s{3}peer-address\s)(.+)$/.match(config)
|
141
141
|
{ peer_address: mdata.nil? ? DEFAULT_PEER_ADDR : mdata[1] }
|
@@ -144,16 +144,16 @@ module Rbeapi
|
|
144
144
|
|
145
145
|
##
|
146
146
|
# parse_peer_link scans the current nodes running configuration and
|
147
|
-
# extracts the mlag peer-link value.
|
148
|
-
# configure, this method will return DEFAULT_PEER_LINK.
|
147
|
+
# extracts the mlag peer-link value. If the mlag peer-link hash not been
|
148
|
+
# configure, this method will return DEFAULT_PEER_LINK. The return value
|
149
149
|
# is intended to be merged into the resource hash.
|
150
150
|
#
|
151
151
|
# @api private
|
152
152
|
#
|
153
|
-
# @param [String]
|
153
|
+
# @param config [String] The mlag configuration block retrieved from the
|
154
154
|
# nodes current running configuration.
|
155
155
|
#
|
156
|
-
# @return [Hash<Symbol, Object>] resource hash attribute
|
156
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute
|
157
157
|
def parse_peer_link(config)
|
158
158
|
mdata = /(?<=\s{3}peer-link\s)(.+)$/.match(config)
|
159
159
|
{ peer_link: mdata.nil? ? DEFAULT_PEER_LINK : mdata[1] }
|
@@ -162,16 +162,16 @@ module Rbeapi
|
|
162
162
|
|
163
163
|
##
|
164
164
|
# parse_shutdown scans the current nodes mlag configuration and extracts
|
165
|
-
# the mlag shutdown value.
|
166
|
-
# the value of shutdown from the configuration block.
|
165
|
+
# the mlag shutdown value. The mlag configuration should always return
|
166
|
+
# the value of shutdown from the configuration block. The return value
|
167
167
|
# is intended to be merged into the resource hash.
|
168
168
|
#
|
169
169
|
# @api private
|
170
170
|
#
|
171
|
-
# @param [String]
|
171
|
+
# @param config [String] The mlag configuration block retrieved from the
|
172
172
|
# nodes current running configuration.
|
173
173
|
#
|
174
|
-
# @return [Hash<Symbol, Object>] resource hash attribute
|
174
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
175
175
|
def parse_shutdown(config)
|
176
176
|
value = /\s{3}no shutdown/ !~ config
|
177
177
|
{ shutdown: value }
|
@@ -180,16 +180,16 @@ module Rbeapi
|
|
180
180
|
|
181
181
|
##
|
182
182
|
# parse_interfaces scans the global configuration and returns all of the
|
183
|
-
# configured MLAG interfaces.
|
184
|
-
# identifier for establishing a MLAG peer.
|
185
|
-
# to be merged into the resource Hash
|
183
|
+
# configured MLAG interfaces. Each interface returns the configured MLAG
|
184
|
+
# identifier for establishing a MLAG peer. The return value is intended
|
185
|
+
# to be merged into the resource Hash.
|
186
186
|
#
|
187
187
|
# The resource Hash attribute returned contains:
|
188
|
-
# * mlag_id: (Fixnum) The configured MLAG identifier
|
188
|
+
# * mlag_id: (Fixnum) The configured MLAG identifier.
|
189
189
|
#
|
190
190
|
# @api private
|
191
191
|
#
|
192
|
-
# @return [Hash<Symbol, Object>] resource Hash attribute
|
192
|
+
# @return [Hash<Symbol, Object>] Returns the resource Hash attribute.
|
193
193
|
def parse_interfaces
|
194
194
|
names = config.scan(/(?<=^interface\s)Po.+/)
|
195
195
|
names.each_with_object({}) do |name, hsh|
|
@@ -204,31 +204,31 @@ module Rbeapi
|
|
204
204
|
##
|
205
205
|
# set_domain_id configures the mlag domain-id value in the current nodes
|
206
206
|
# running configuration. If the enable keyword is false, the the
|
207
|
-
# domain-id is configured with the no keyword.
|
207
|
+
# domain-id is configured with the no keyword. If the default keyword
|
208
208
|
# is provided, the configuration is defaulted using the default keyword.
|
209
209
|
# The default keyword takes precedence over the enable keyword if both
|
210
|
-
# options are specified
|
210
|
+
# options are specified.
|
211
211
|
#
|
212
|
-
# @eos_version 4.13.7M
|
212
|
+
# @since eos_version 4.13.7M
|
213
213
|
#
|
214
|
-
#
|
214
|
+
# ===Commands
|
215
215
|
# mlag configuration
|
216
216
|
# domain-id <value>
|
217
217
|
# no domain-id
|
218
218
|
# default domain-id
|
219
219
|
#
|
220
|
-
# @param [Hash]
|
220
|
+
# @param opts [Hash] Optional keyword arguments
|
221
221
|
#
|
222
|
-
# @option
|
222
|
+
# @option opts value [String] The value to configure the mlag
|
223
223
|
# domain-id to.
|
224
224
|
#
|
225
|
-
# @option
|
225
|
+
# @option opts enable [Boolean] If false then the command is
|
226
226
|
# negated. Default is true.
|
227
227
|
#
|
228
|
-
# @option
|
229
|
-
# the default keyword
|
228
|
+
# @option opts default [Boolean] Configure the domain-id value using
|
229
|
+
# the default keyword.
|
230
230
|
#
|
231
|
-
# @return [Boolean]
|
231
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
232
232
|
def set_domain_id(opts = {})
|
233
233
|
cmd = command_builder('domain-id', opts)
|
234
234
|
cmds = ['mlag configuration', cmd]
|
@@ -238,32 +238,32 @@ module Rbeapi
|
|
238
238
|
##
|
239
239
|
# set_local_interface configures the mlag local-interface value in the
|
240
240
|
# current nodes running configuration. If the enable keyword is false,
|
241
|
-
# the local-interface is configured with the no keyword.
|
241
|
+
# the local-interface is configured with the no keyword. If
|
242
242
|
# the default keyword is provided, the configuration is defaulted using
|
243
|
-
# the default keyword.
|
243
|
+
# the default keyword. The default keyword takes precedence over the
|
244
244
|
# enable keyword if both options are specified
|
245
245
|
#
|
246
|
-
# @eos_version 4.13.7M
|
246
|
+
# @since eos_version 4.13.7M
|
247
247
|
#
|
248
|
-
#
|
248
|
+
# ===Commands
|
249
249
|
# mlag configuration
|
250
250
|
# local-interface <value>
|
251
251
|
# no local-interface
|
252
252
|
# default local-interface
|
253
253
|
#
|
254
|
-
# @param [Hash]
|
254
|
+
# @param opts [Hash] Optional keyword arguments
|
255
255
|
#
|
256
|
-
# @option
|
257
|
-
# local-interface to.
|
256
|
+
# @option opts value [String] The value to configure the mlag
|
257
|
+
# local-interface to. The local-interface accepts full interface
|
258
258
|
# identifiers and expects a Vlan interface
|
259
259
|
#
|
260
|
-
# @option
|
260
|
+
# @option opts enable [Boolean] If false then the command is
|
261
261
|
# negated. Default is true.
|
262
262
|
#
|
263
|
-
# @option
|
264
|
-
# using the default keyword
|
263
|
+
# @option opts default [Boolean] Configure the local-interface value
|
264
|
+
# using the default keyword.
|
265
265
|
#
|
266
|
-
# @return [Boolean]
|
266
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
267
267
|
def set_local_interface(opts = {})
|
268
268
|
cmd = command_builder('local-interface', opts)
|
269
269
|
cmds = ['mlag configuration', cmd]
|
@@ -273,32 +273,32 @@ module Rbeapi
|
|
273
273
|
##
|
274
274
|
# set_peer_link configures the mlag peer-link value in the current nodes
|
275
275
|
# running configuration. If enable keyword is false, then the
|
276
|
-
# peer-link is configured with the no keyword.
|
276
|
+
# peer-link is configured with the no keyword. If the default keyword
|
277
277
|
# is provided, the configuration is defaulted using the default keyword.
|
278
278
|
# The default keyword takes precedence over the enable keyword if both
|
279
|
-
# options are specified
|
279
|
+
# options are specified.
|
280
280
|
#
|
281
|
-
# @eos_version 4.13.7M
|
281
|
+
# @since eos_version 4.13.7M
|
282
282
|
#
|
283
|
-
#
|
283
|
+
# ===Commands
|
284
284
|
# mlag configuration
|
285
285
|
# peer-link <value>
|
286
286
|
# no peer-link
|
287
287
|
# default peer-link
|
288
288
|
#
|
289
|
-
# @param [Hash]
|
289
|
+
# @param opts [Hash] Optional keyword arguments.
|
290
290
|
#
|
291
|
-
# @option
|
292
|
-
# peer-link to.
|
293
|
-
# and expects an Ethernet or Port-Channel interface
|
291
|
+
# @option opts value [String] The value to configure the mlag
|
292
|
+
# peer-link to. The peer-link accepts full interface identifiers
|
293
|
+
# and expects an Ethernet or Port-Channel interface.
|
294
294
|
#
|
295
|
-
# @option
|
295
|
+
# @option opts enable [Boolean] If false then the command is
|
296
296
|
# negated. Default is true.
|
297
297
|
#
|
298
|
-
# @option
|
299
|
-
# default keyword
|
298
|
+
# @option opts default [Boolean] Configure the peer-link using the
|
299
|
+
# default keyword.
|
300
300
|
#
|
301
|
-
# @return [Boolean]
|
301
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
302
302
|
def set_peer_link(opts = {})
|
303
303
|
cmd = command_builder('peer-link', opts)
|
304
304
|
cmds = ['mlag configuration', cmd]
|
@@ -308,32 +308,32 @@ module Rbeapi
|
|
308
308
|
##
|
309
309
|
# set_peer_address configures the mlag peer-address value in the current
|
310
310
|
# nodes running configuration. If the enable keyword is false, then the
|
311
|
-
# peer-address is configured with the no keyword.
|
311
|
+
# peer-address is configured with the no keyword. If the default keyword
|
312
312
|
# is provided, the configuration is defaulted using the default keyword.
|
313
313
|
# The default keyword takes precedence over the enable keyword if both
|
314
314
|
# options are specified
|
315
315
|
#
|
316
|
-
# @eos_version 4.13.7M
|
316
|
+
# @since eos_version 4.13.7M
|
317
317
|
#
|
318
|
-
#
|
318
|
+
# ===Commands
|
319
319
|
# mlag configuration
|
320
320
|
# peer-address <value>
|
321
321
|
# no peer-address
|
322
322
|
# default peer-address
|
323
323
|
#
|
324
|
-
# @param [Hash]
|
324
|
+
# @param opts [Hash] Optional keyword arguments.
|
325
325
|
#
|
326
|
-
# @option
|
327
|
-
# peer-address to.
|
328
|
-
# of A.B.C.D/E
|
326
|
+
# @option opts value [String] The value to configure the mlag
|
327
|
+
# peer-address to. The peer-address accepts an IP address in the form
|
328
|
+
# of A.B.C.D/E.
|
329
329
|
#
|
330
|
-
# @option
|
330
|
+
# @option opts enable [Boolean] If false then the command is
|
331
331
|
# negated. Default is true.
|
332
332
|
#
|
333
|
-
# @option
|
334
|
-
# default keyword
|
333
|
+
# @option opts default [Boolean] Configure the peer-address using the
|
334
|
+
# default keyword.
|
335
335
|
#
|
336
|
-
# @return [Boolean]
|
336
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
337
337
|
def set_peer_address(opts = {})
|
338
338
|
cmd = command_builder('peer-address', opts)
|
339
339
|
cmds = ['mlag configuration', cmd]
|
@@ -342,30 +342,30 @@ module Rbeapi
|
|
342
342
|
|
343
343
|
##
|
344
344
|
# set_shutdown configures the administrative state of the mlag process on
|
345
|
-
# the current node.
|
345
|
+
# the current node. If the enable keyword is true, then mlag is enabled
|
346
346
|
# and if the enable keyword is false, then mlag is disabled. If the
|
347
347
|
# default keyword is provided, the configuration is defaulted using
|
348
348
|
# the default keyword. The default keyword takes precedence over the
|
349
349
|
# enable keyword if both options are specified
|
350
350
|
#
|
351
|
-
# @eos_version 4.13.7M
|
351
|
+
# @since eos_version 4.13.7M
|
352
352
|
#
|
353
|
-
#
|
353
|
+
# ===Commands
|
354
354
|
# mlag configuration
|
355
355
|
# shutdown
|
356
356
|
# no shutdown
|
357
357
|
# default shutdown
|
358
358
|
#
|
359
|
-
# @param [Hash]
|
359
|
+
# @param opts [Hash] Optional keyword arguments.
|
360
360
|
#
|
361
|
-
# @option
|
361
|
+
# @option opts enable [Boolean] True if the interface should be
|
362
362
|
# administratively enabled or false if the interface should be
|
363
363
|
# administratively disabled.
|
364
364
|
#
|
365
|
-
# @option
|
366
|
-
# default keyword
|
365
|
+
# @option opts default [Boolean] Configure the shutdown value using the
|
366
|
+
# default keyword.
|
367
367
|
#
|
368
|
-
# @return [Boolean]
|
368
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
369
369
|
def set_shutdown(opts = {})
|
370
370
|
fail 'set_shutdown has the value option set' if opts[:value]
|
371
371
|
# Shutdown semantics are opposite of enable semantics so invert enable
|
@@ -378,36 +378,36 @@ module Rbeapi
|
|
378
378
|
|
379
379
|
##
|
380
380
|
# set_mlag_id configures the mlag id on the interface in the nodes
|
381
|
-
# current running configuration.
|
382
|
-
# interface mlag id is configured using the no keyword.
|
381
|
+
# current running configuration. If the enable keyword is false, then the
|
382
|
+
# interface mlag id is configured using the no keyword. If the default
|
383
383
|
# keyword is provided and set to true, the interface mlag id is
|
384
|
-
# configured using the default keyword.
|
384
|
+
# configured using the default keyword. The default keyword takes
|
385
385
|
# precedence over the enable keyword if both options are specified
|
386
386
|
#
|
387
|
-
# @eos_version 4.13.7M
|
387
|
+
# @since eos_version 4.13.7M
|
388
388
|
#
|
389
|
-
#
|
389
|
+
# ===Commands
|
390
390
|
# interface <name>
|
391
391
|
# mlag <value>
|
392
392
|
# no mlag
|
393
393
|
# default mlag
|
394
394
|
#
|
395
|
-
# @param [String]
|
395
|
+
# @param name [String] The full interface identifier of the interface
|
396
396
|
# to configure th mlag id for.
|
397
397
|
#
|
398
|
-
# @param [Hash]
|
398
|
+
# @param opts [Hash] Optional keyword arguments.
|
399
399
|
#
|
400
|
-
# @option
|
401
|
-
# interface mlag to.
|
402
|
-
# 2000
|
400
|
+
# @option opts value [String, Integer] The value to configure the
|
401
|
+
# interface mlag to. The mlag id should be in the valid range of 1 to
|
402
|
+
# 2000.
|
403
403
|
#
|
404
|
-
# @option
|
404
|
+
# @option opts enable [Boolean] If false then the command is
|
405
405
|
# negated. Default is true.
|
406
406
|
#
|
407
|
-
# @option
|
408
|
-
# default keyword
|
407
|
+
# @option opts default [Boolean] Configure the mlag value using the
|
408
|
+
# default keyword.
|
409
409
|
#
|
410
|
-
# @return [Boolean]
|
410
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
411
411
|
def set_mlag_id(name, opts = {})
|
412
412
|
cmd = command_builder('mlag', opts)
|
413
413
|
configure_interface(name, cmd)
|
data/lib/rbeapi/api/ntp.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 Ntp class provides an instance for working with the nodes
|
@@ -44,7 +44,7 @@ module Rbeapi
|
|
44
44
|
DEFAULT_SRC_INTF = ''
|
45
45
|
|
46
46
|
##
|
47
|
-
# get returns the nodes current ntp configure as a resource hash
|
47
|
+
# get returns the nodes current ntp configure as a resource hash.
|
48
48
|
#
|
49
49
|
# @example
|
50
50
|
# {
|
@@ -65,13 +65,13 @@ module Rbeapi
|
|
65
65
|
|
66
66
|
##
|
67
67
|
# parse_source_interface scans the nodes configurations and parses
|
68
|
-
# the ntp source interface if configured.
|
68
|
+
# the ntp source interface if configured. If the source interface
|
69
69
|
# is not configured, this method will return DEFAULT_SRC_INTF as the
|
70
|
-
# value. The return hash is intended to be merged into the resource hash
|
70
|
+
# value. The return hash is intended to be merged into the resource hash.
|
71
71
|
#
|
72
72
|
# @api private
|
73
73
|
#
|
74
|
-
# @return [Hash<Symbol, Object>] resource hash attribute
|
74
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
75
75
|
def parse_source_interface
|
76
76
|
mdata = /(?<=^ntp\ssource\s)(.+)$/.match(config)
|
77
77
|
{ source_interface: mdata.nil? ? DEFAULT_SRC_INTF : mdata[1] }
|
@@ -80,14 +80,14 @@ module Rbeapi
|
|
80
80
|
|
81
81
|
##
|
82
82
|
# parse_servers scans the nodes configuration and parses the configured
|
83
|
-
# ntp server host names and/or addresses.
|
84
|
-
# the value of prefer.
|
85
|
-
# set to an empty array.
|
86
|
-
# the resource hash
|
83
|
+
# ntp server host names and/or addresses. This method will also return
|
84
|
+
# the value of prefer. If no servers are configured, the value will be
|
85
|
+
# set to an empty array. The return hash is intended to be merged into
|
86
|
+
# the resource hash.
|
87
87
|
#
|
88
88
|
# @api private
|
89
89
|
#
|
90
|
-
# @return [Hash<Symbol, Object>] resource hash attribute
|
90
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
91
91
|
def parse_servers
|
92
92
|
servers = config.scan(/(?:ntp server\s)([^\s]+)\s(prefer)?/)
|
93
93
|
values = servers.each_with_object({}) do |(srv, prefer), hsh|
|
@@ -99,31 +99,31 @@ module Rbeapi
|
|
99
99
|
|
100
100
|
##
|
101
101
|
# set_source_interface configures the ntp source value in the nodes
|
102
|
-
# running configuration.
|
103
|
-
# the ntp source is configured with the no keyword argument.
|
102
|
+
# running configuration. If the enable keyword is false, then
|
103
|
+
# the ntp source is configured with the no keyword argument. If the
|
104
104
|
# default keyword argument is provided and set to true, the value is
|
105
|
-
# configured used the default keyword.
|
105
|
+
# configured used the default keyword. The default keyword takes
|
106
106
|
# precedence over the enable keyword if both options are specified.
|
107
107
|
#
|
108
|
-
# @eos_version 4.13.7M
|
108
|
+
# @since eos_version 4.13.7M
|
109
109
|
#
|
110
|
-
#
|
110
|
+
# ===Commands
|
111
111
|
# ntp source <value>
|
112
112
|
# no ntp source
|
113
113
|
# default ntp source
|
114
114
|
#
|
115
|
-
# @param [Hash]
|
115
|
+
# @param opts [Hash] Optional keyword arguments.
|
116
116
|
#
|
117
|
-
# @option
|
118
|
-
# in the nodes configuration
|
117
|
+
# @option opts value [String] The value to configure the ntp source
|
118
|
+
# in the nodes configuration.
|
119
119
|
#
|
120
|
-
# @option
|
120
|
+
# @option opts enable [Boolean] If false then the command is
|
121
121
|
# negated. Default is true.
|
122
122
|
#
|
123
|
-
# @option
|
124
|
-
# the default keyword
|
123
|
+
# @option opts default [Boolean] Configure the ntp source value using
|
124
|
+
# the default keyword.
|
125
125
|
#
|
126
|
-
# @return [Boolean]
|
126
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
127
127
|
def set_source_interface(opts = {})
|
128
128
|
cmd = command_builder('ntp source', opts)
|
129
129
|
configure(cmd)
|
@@ -131,17 +131,17 @@ module Rbeapi
|
|
131
131
|
|
132
132
|
##
|
133
133
|
# add_server configures a new ntp server destination hostname or ip
|
134
|
-
# address to the list of ntp destinations.
|
134
|
+
# address to the list of ntp destinations. The optional prefer argument
|
135
135
|
# configures the server as a preferred (true) or not (false) ntp
|
136
136
|
# destination.
|
137
137
|
#
|
138
|
-
# @param [String]
|
139
|
-
# be removed from the configuration
|
138
|
+
# @param server [String] The IP address or FQDN of the NTP server to
|
139
|
+
# be removed from the configuration.
|
140
140
|
#
|
141
|
-
# @param [Boolean]
|
142
|
-
# command if this value is true
|
141
|
+
# @param prefer [Boolean] Appends the prefer keyword argument to the
|
142
|
+
# command if this value is true.
|
143
143
|
#
|
144
|
-
# @return [Boolean]
|
144
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
145
145
|
def add_server(server, prefer = false)
|
146
146
|
cmd = "ntp server #{server}"
|
147
147
|
cmd << ' prefer' if prefer
|
@@ -150,13 +150,13 @@ module Rbeapi
|
|
150
150
|
|
151
151
|
##
|
152
152
|
# remove_server deletes the provided server destination from the list of
|
153
|
-
# ntp server destinations.
|
153
|
+
# ntp server destinations. If the ntp server does not exist in the list
|
154
154
|
# of servers, this method will return successful
|
155
155
|
#
|
156
|
-
# @param [String]
|
157
|
-
# be removed from the configuration
|
156
|
+
# @param server [String] The IP address or FQDN of the NTP server to
|
157
|
+
# be removed from the configuration.
|
158
158
|
#
|
159
|
-
# @return [Boolean]
|
159
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
160
160
|
def remove_server(server)
|
161
161
|
configure("no ntp server #{server}")
|
162
162
|
end
|
@@ -166,20 +166,20 @@ module Rbeapi
|
|
166
166
|
# If the server does not already exist in the configuration, it will be
|
167
167
|
# added and the prefer keyword will be set.
|
168
168
|
#
|
169
|
-
# @eos_version 4.13.7M
|
169
|
+
# @since eos_version 4.13.7M
|
170
170
|
#
|
171
|
-
#
|
171
|
+
# ===Commands
|
172
172
|
# ntp server <srv> prefer
|
173
173
|
# no ntp server <srv> prefer
|
174
174
|
#
|
175
|
-
# @param [String]
|
176
|
-
# configure with the prefer value
|
175
|
+
# @param srv [String] The IP address or hostname of the ntp server to
|
176
|
+
# configure with the prefer value.
|
177
177
|
#
|
178
|
-
# @param [Boolean]
|
178
|
+
# @param value [Boolean] The value to configure for prefer. If true
|
179
179
|
# the prefer value is configured for the server. If false, then the
|
180
180
|
# prefer value is removed.
|
181
181
|
#
|
182
|
-
# @return [Boolean]
|
182
|
+
# @return [Boolean] Returns true if the commands completed successfully.
|
183
183
|
def set_prefer(srv, value)
|
184
184
|
case value
|
185
185
|
when true
|