rbeapi 0.5.1 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +211 -76
- data/Gemfile +14 -3
- data/README.md +74 -38
- data/Rakefile +38 -17
- data/gems/inifile/inifile.spec.tmpl +31 -4
- data/gems/net_http_unix/net_http_unix.spec.tmpl +34 -8
- data/gems/netaddr/netaddr.spec.tmpl +31 -5
- data/guide/getting-started.rst +95 -64
- data/guide/installation.rst +27 -6
- data/guide/release-notes.rst +5 -1
- data/guide/testing.rst +5 -2
- data/guide/upgrading.rst +2 -0
- data/lib/rbeapi/api/dns.rb +8 -2
- data/lib/rbeapi/api/interfaces.rb +107 -21
- data/lib/rbeapi/api/ipinterfaces.rb +48 -0
- data/lib/rbeapi/api/prefixlists.rb +53 -23
- data/lib/rbeapi/api/routemaps.rb +11 -0
- data/lib/rbeapi/api/stp.rb +6 -3
- data/lib/rbeapi/api/switchports.rb +5 -11
- data/lib/rbeapi/api/system.rb +1 -1
- data/lib/rbeapi/api/users.rb +2 -0
- data/lib/rbeapi/api/varp.rb +6 -0
- data/lib/rbeapi/api/vlans.rb +44 -0
- data/lib/rbeapi/api/vrrp.rb +13 -0
- data/lib/rbeapi/client.rb +19 -4
- data/lib/rbeapi/switchconfig.rb +330 -0
- data/lib/rbeapi/version.rb +1 -1
- data/rbeapi.gemspec +2 -0
- data/rbeapi.spec.tmpl +30 -3
- data/spec/fixtures/.gitignore +1 -0
- data/spec/support/matchers/switch_config_sections.rb +80 -0
- data/spec/system/rbeapi/api/interfaces_base_spec.rb +32 -3
- data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +56 -8
- data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +33 -1
- data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +27 -0
- data/spec/system/rbeapi/api/ipinterfaces_spec.rb +34 -1
- data/spec/system/rbeapi/api/prefixlists_spec.rb +198 -0
- data/spec/system/rbeapi/api/stp_instances_spec.rb +49 -5
- data/spec/system/rbeapi/api/switchports_spec.rb +15 -9
- data/spec/system/rbeapi/api/vlans_spec.rb +46 -0
- data/spec/unit/rbeapi/api/interfaces/base_spec.rb +1 -1
- data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +1 -1
- data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +9 -2
- data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +1 -1
- data/spec/unit/rbeapi/api/prefixlists/default_spec.rb +202 -0
- data/spec/unit/rbeapi/api/prefixlists/fixture_prefixlists.text +11 -0
- data/spec/unit/rbeapi/api/routemaps/default_spec.rb +5 -0
- data/spec/unit/rbeapi/api/switchports/default_spec.rb +4 -4
- data/spec/unit/rbeapi/api/system/default_spec.rb +5 -0
- data/spec/unit/rbeapi/api/system/fixture_system.text +1 -0
- data/spec/unit/rbeapi/api/vlans/default_spec.rb +30 -0
- data/spec/unit/rbeapi/api/vrrp/default_spec.rb +10 -0
- data/spec/unit/rbeapi/client_spec.rb +42 -0
- data/spec/unit/rbeapi/switchconfig2_spec.rb +119 -0
- data/spec/unit/rbeapi/switchconfig3_spec.rb +125 -0
- data/spec/unit/rbeapi/switchconfig_spec.rb +335 -0
- metadata +21 -7
data/guide/installation.rst
CHANGED
@@ -3,18 +3,37 @@ Installation
|
|
3
3
|
|
4
4
|
.. contents:: :local:
|
5
5
|
|
6
|
-
The source code for rbeapi is provided on Github at
|
6
|
+
The source code for rbeapi is provided on Github at
|
7
|
+
http://github.com/arista-eosplus/rbeapi. All current development is done in the
|
8
|
+
develop branch. Stable released versions are tagged in the master branch and
|
9
|
+
uploaded to RubyGems.
|
7
10
|
|
8
|
-
|
11
|
+
To install the latest stable version of rbeapi, simply run ``gem install
|
12
|
+
rbeapi``
|
9
13
|
|
10
|
-
|
14
|
+
To install the latest development version from Github, simply clone the develop
|
15
|
+
branch and run
|
16
|
+
|
17
|
+
.. code-block:: console
|
11
18
|
|
12
19
|
$ rake build
|
13
20
|
$ rake install
|
14
21
|
|
15
|
-
To create an RPM, run rake rpm
|
22
|
+
To create an RPM, run ``rake rpm``
|
23
|
+
|
24
|
+
To generate a SWIX file for EOS with necessary dependencies, run ``rake
|
25
|
+
all_rpms`` then follow the swix create instructions, provided by the build.
|
26
|
+
NOTE: Puppet provides a puppet agent SWIX which includes Ruby 1.9.3 in
|
27
|
+
/opt/puppetlabs/bin/ which is different from where you might otherwise
|
28
|
+
install Ruby. If you have installed the puppet-enterprise 3.x SWIX, then
|
29
|
+
you should build and use the rbeapi-puppet3 swix, below. If you have
|
30
|
+
installed the puppet-enterprise 2015.x SWIX, then you should build and use
|
31
|
+
the rbeapi-puppet-aio swix, below. The Chef client omnibus install also
|
32
|
+
includes its own version of Ruby in /opt/chef/bin/, thus the rbeapi-chef
|
33
|
+
swix should be used. Otherwise, if you have installed at least Ruby
|
34
|
+
1.9.3 in the standard system location, then the rbeapi SWIX may be used.
|
16
35
|
|
17
|
-
|
36
|
+
.. code-block:: console
|
18
37
|
|
19
38
|
$ bundle install --path .bundle/gems/
|
20
39
|
$ bundle exec rake all_rpms
|
@@ -43,7 +62,9 @@ The source code for rbeapi is provided on Github at http://github.com/arista-eos
|
|
43
62
|
rubygem-netaddr-puppet-aio-1.5.0-2.eos4.noarch.rpm \
|
44
63
|
rubygem-net_http_unix-puppet-aio-0.2.1-3.eos4.noarch.rpm
|
45
64
|
|
46
|
-
|
65
|
+
On EOS:
|
66
|
+
|
67
|
+
.. code-block:: console
|
47
68
|
|
48
69
|
Arista# copy <URI-to-RPMs> flash:
|
49
70
|
Arista# bash
|
data/guide/release-notes.rst
CHANGED
@@ -3,4 +3,8 @@ Release Notes
|
|
3
3
|
|
4
4
|
.. toctree::
|
5
5
|
:maxdepth: 2
|
6
|
-
:titlesonly:
|
6
|
+
:titlesonly:
|
7
|
+
|
8
|
+
For the most up-to-date release notes, see the `GitHub release
|
9
|
+
<https://github.com/arista-eosplus/rbeapi/releases>`_ pages or the `CHANGELOG
|
10
|
+
<https://github.com/arista-eosplus/rbeapi/blob/develop/CHANGELOG.md>`_.
|
data/guide/testing.rst
CHANGED
@@ -3,6 +3,9 @@ Testing Modules
|
|
3
3
|
|
4
4
|
.. contents:: :local:
|
5
5
|
|
6
|
-
The rbeapi library provides spec tests. To run the spec tests, you will need to
|
6
|
+
The rbeapi library provides spec tests. To run the spec tests, you will need to
|
7
|
+
update the ``spec/fixtures/dut.conf`` file. The switch used for testing
|
8
|
+
must have at least interfaces Ethernet1-7.
|
7
9
|
|
8
|
-
|
10
|
+
To run the spec tests, run ``bundle exec rspec spec`` from the root of the
|
11
|
+
rbeapi source folder.
|
data/guide/upgrading.rst
CHANGED
data/lib/rbeapi/api/dns.rb
CHANGED
@@ -198,19 +198,24 @@ module Rbeapi
|
|
198
198
|
# no ip domain-list
|
199
199
|
# default ip domain-list
|
200
200
|
#
|
201
|
-
# @option value [Array] The set of domain names to configure on the
|
201
|
+
# @option opts value [Array] The set of domain names to configure on the
|
202
202
|
# node. The list of domain names will be replace in the nodes running
|
203
203
|
# configuration by the list provided in value.
|
204
204
|
#
|
205
|
-
# @option default [Boolean] Configures the ip domain-list using the
|
205
|
+
# @option opts default [Boolean] Configures the ip domain-list using the
|
206
206
|
# default keyword argument.
|
207
207
|
#
|
208
208
|
# @return [Boolean] Returns true if the commands completed successfully.
|
209
|
+
# rubocop:disable Metrics/MethodLength
|
209
210
|
def set_domain_list(opts = {})
|
210
211
|
value = opts[:value]
|
211
212
|
enable = opts.fetch(:enable, true)
|
212
213
|
default = opts[:default] || false
|
213
214
|
|
215
|
+
if value
|
216
|
+
fail ArgumentError, 'value must be an Array' unless value.is_a?(Array)
|
217
|
+
end
|
218
|
+
|
214
219
|
cmds = []
|
215
220
|
case default
|
216
221
|
when true
|
@@ -229,6 +234,7 @@ module Rbeapi
|
|
229
234
|
end
|
230
235
|
configure cmds
|
231
236
|
end
|
237
|
+
# rubocop:enable Metrics/MethodLength
|
232
238
|
|
233
239
|
##
|
234
240
|
# add_domain_list adds an ip domain-list.
|
@@ -144,6 +144,7 @@ module Rbeapi
|
|
144
144
|
# that is common to all interfaces configured in EOS.
|
145
145
|
class BaseInterface < Entity
|
146
146
|
DEFAULT_INTF_DESCRIPTION = ''
|
147
|
+
DEFAULT_LOAD_INTERVAL = ''
|
147
148
|
|
148
149
|
##
|
149
150
|
# get returns the specified interface resource hash that represents the
|
@@ -157,6 +158,7 @@ module Rbeapi
|
|
157
158
|
# type: 'generic'
|
158
159
|
# description: <string>
|
159
160
|
# shutdown: [true, false]
|
161
|
+
# load_interval: <string>
|
160
162
|
# }
|
161
163
|
#
|
162
164
|
# @param name [String] The name of the interface to return from the
|
@@ -172,6 +174,7 @@ module Rbeapi
|
|
172
174
|
response = { name: name, type: 'generic' }
|
173
175
|
response.merge!(parse_description(config))
|
174
176
|
response.merge!(parse_shutdown(config))
|
177
|
+
response.merge!(parse_load_interval(config))
|
175
178
|
response
|
176
179
|
end
|
177
180
|
|
@@ -213,6 +216,24 @@ module Rbeapi
|
|
213
216
|
end
|
214
217
|
private :parse_shutdown
|
215
218
|
|
219
|
+
##
|
220
|
+
# parse_load_interval scans the provided configuration block and
|
221
|
+
# parse the load-interval value. If the interface load-interval
|
222
|
+
# value is not configured, then this method will return the value of
|
223
|
+
# DEFAULT_LOAD_INTERVAL. The hash returned is intended to be merged into
|
224
|
+
# the interface resource hash.
|
225
|
+
#
|
226
|
+
# @api private
|
227
|
+
#
|
228
|
+
# @param config [String] The configuration block to parse.
|
229
|
+
#
|
230
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
231
|
+
def parse_load_interval(config)
|
232
|
+
mdata = /load-interval (\w+)$/.match(config)
|
233
|
+
{ load_interval: mdata.nil? ? DEFAULT_LOAD_INTERVAL : mdata[1] }
|
234
|
+
end
|
235
|
+
private :parse_load_interval
|
236
|
+
|
216
237
|
##
|
217
238
|
# create will create a new interface resource in the node's current
|
218
239
|
# configuration with the specified interface name. If the create
|
@@ -326,6 +347,27 @@ module Rbeapi
|
|
326
347
|
commands = command_builder('shutdown', opts)
|
327
348
|
configure_interface(name, commands)
|
328
349
|
end
|
350
|
+
|
351
|
+
##
|
352
|
+
# set_load_interval is a convenience function for configuring the
|
353
|
+
# value of interface load-interval
|
354
|
+
#
|
355
|
+
# @param name [String] The interface name to apply the configuration
|
356
|
+
# values to. The name must be the full interface identifier.
|
357
|
+
#
|
358
|
+
# @param opts [Hash] Optional keyword arguments.
|
359
|
+
#
|
360
|
+
# @option opts value [String] Specifies the value to configure the
|
361
|
+
# load-interval setting for. Valid values are between 5 and 600.
|
362
|
+
#
|
363
|
+
# @option opts default [Boolean] Configures the load-interval value on
|
364
|
+
# the interface using the default keyword.
|
365
|
+
#
|
366
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
367
|
+
def set_load_interval(name, opts = {})
|
368
|
+
commands = command_builder('load-interval', opts)
|
369
|
+
configure_interface(name, commands)
|
370
|
+
end
|
329
371
|
end
|
330
372
|
|
331
373
|
##
|
@@ -334,8 +376,8 @@ module Rbeapi
|
|
334
376
|
class EthernetInterface < BaseInterface
|
335
377
|
DEFAULT_ETH_FLOWC_TX = 'off'
|
336
378
|
DEFAULT_ETH_FLOWC_RX = 'off'
|
337
|
-
DEFAULT_SPEED = '
|
338
|
-
|
379
|
+
DEFAULT_SPEED = 'default'
|
380
|
+
DEFAULT_LACP_PRIORITY = 32_768
|
339
381
|
|
340
382
|
##
|
341
383
|
# get returns the specified Ethernet interface resource hash that
|
@@ -347,11 +389,12 @@ module Rbeapi
|
|
347
389
|
# type: <string>,
|
348
390
|
# description: <string>,
|
349
391
|
# shutdown: <boolean>,
|
392
|
+
# load_interval: <string>
|
350
393
|
# speed: <string>,
|
351
|
-
# forced: <boolean>,
|
352
394
|
# sflow: <boolean>,
|
353
395
|
# flowcontrol_send: <string>,
|
354
396
|
# flowcontrol_receive: <string>
|
397
|
+
# lacp_priority: <integer>
|
355
398
|
# }
|
356
399
|
#
|
357
400
|
# @param name [String] The interface name to return a resource hash
|
@@ -371,6 +414,7 @@ module Rbeapi
|
|
371
414
|
response.merge!(parse_sflow(config))
|
372
415
|
response.merge!(parse_flowcontrol_send(config))
|
373
416
|
response.merge!(parse_flowcontrol_receive(config))
|
417
|
+
response.merge!(parse_lacp_priority(config))
|
374
418
|
response
|
375
419
|
end
|
376
420
|
|
@@ -386,10 +430,8 @@ module Rbeapi
|
|
386
430
|
#
|
387
431
|
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
388
432
|
def parse_speed(config)
|
389
|
-
value = config.scan(/speed (
|
390
|
-
|
391
|
-
(forced, value) = value.first
|
392
|
-
{ speed: value, forced: !forced.nil? }
|
433
|
+
value = config.scan(/speed (.*)/).first
|
434
|
+
{ speed: value.nil? ? DEFAULT_SPEED : value.first }
|
393
435
|
end
|
394
436
|
private :parse_speed
|
395
437
|
|
@@ -446,6 +488,24 @@ module Rbeapi
|
|
446
488
|
end
|
447
489
|
private :parse_flowcontrol_receive
|
448
490
|
|
491
|
+
##
|
492
|
+
# parse_lacp_priority scans the provided configuration block and parse
|
493
|
+
# the lacp port-priority value. If the interface lacp port-priority value
|
494
|
+
# is not configured, then this method will return the value of
|
495
|
+
# DEFAULT_LACP_PRIORITY. The hash returned is intended to be merged into
|
496
|
+
# the interface resource hash.
|
497
|
+
#
|
498
|
+
# @api private
|
499
|
+
#
|
500
|
+
# @param config [String] The configuration block to parse.
|
501
|
+
#
|
502
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
503
|
+
def parse_lacp_priority(config)
|
504
|
+
mdata = /lacp port-priority (\d+)$/.match(config)
|
505
|
+
{ lacp_priority: mdata.nil? ? DEFAULT_LACP_PRIORITY : mdata[1] }
|
506
|
+
end
|
507
|
+
private :parse_lacp_priority
|
508
|
+
|
449
509
|
##
|
450
510
|
# create overrides the create method from the BaseInterface and raises
|
451
511
|
# an exception because Ethernet interface creation is not supported.
|
@@ -494,29 +554,21 @@ module Rbeapi
|
|
494
554
|
# @option opts enable [Boolean] If false then the command is
|
495
555
|
# negated. Default is true.
|
496
556
|
#
|
497
|
-
# @option opts forced [Boolean] Specifies if auto negotiation should be
|
498
|
-
# enabled (true) or disabled (false).
|
499
|
-
#
|
500
|
-
# @option opts default [Boolean] Configures the sflow value on the
|
501
|
-
# interface using the default keyword.
|
502
|
-
#
|
503
557
|
# @return [Boolean] Returns true if the command completed successfully.
|
504
558
|
def set_speed(name, opts = {})
|
505
559
|
value = opts[:value]
|
506
|
-
forced = opts.fetch(:forced, false)
|
507
560
|
enable = opts.fetch(:enable, true)
|
508
|
-
default =
|
509
|
-
|
510
|
-
forced = 'forced' if forced
|
511
|
-
forced = '' if value == 'auto'
|
561
|
+
default = (value == :default)
|
512
562
|
|
513
563
|
cmds = ["interface #{name}"]
|
514
564
|
case default
|
515
565
|
when true
|
516
566
|
cmds << 'default speed'
|
517
567
|
when false
|
518
|
-
|
568
|
+
cmd = enable ? "speed #{value}" : 'no speed'
|
569
|
+
cmds << cmd
|
519
570
|
end
|
571
|
+
|
520
572
|
configure cmds
|
521
573
|
end
|
522
574
|
|
@@ -633,6 +685,35 @@ module Rbeapi
|
|
633
685
|
def set_flowcontrol_receive(name, opts = {})
|
634
686
|
set_flowcontrol(name, 'receive', opts)
|
635
687
|
end
|
688
|
+
|
689
|
+
##
|
690
|
+
# set_lacp_priority configures the lacp port-priority on the interface.
|
691
|
+
# Setting the enable keyword to true enables the lacp port-priority on
|
692
|
+
# the interface and setting enable to false disables the lacp
|
693
|
+
# port-priority on the interface.
|
694
|
+
# If the default keyword is set to true, then the lacp port-priority
|
695
|
+
# value is defaulted using the default keyword. The default keyword takes
|
696
|
+
# precedence over the enable keyword
|
697
|
+
#
|
698
|
+
# @since eos_version 4.13.7M
|
699
|
+
#
|
700
|
+
# @param name [String] The interface name to apply the configuration
|
701
|
+
# values to. The name must be the full interface identifier.
|
702
|
+
#
|
703
|
+
# @param opts [Hash] Optional keyword arguments.
|
704
|
+
#
|
705
|
+
# @option opts enable [Boolean] Enables sflow if the value is true or
|
706
|
+
# disables the lacp port-priority on the interface if false. Default is
|
707
|
+
# true.
|
708
|
+
#
|
709
|
+
# @option opts default [Boolean] Configures the lacp port-priority value
|
710
|
+
# on the interface using the default keyword.
|
711
|
+
#
|
712
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
713
|
+
def set_lacp_priority(name, opts = {})
|
714
|
+
commands = command_builder('lacp port-priority', opts)
|
715
|
+
configure_interface(name, commands)
|
716
|
+
end
|
636
717
|
end
|
637
718
|
|
638
719
|
##
|
@@ -654,6 +735,7 @@ module Rbeapi
|
|
654
735
|
# type: 'portchannel'
|
655
736
|
# description: <string>
|
656
737
|
# shutdown: [true, false]
|
738
|
+
# load_interval: <string>
|
657
739
|
# members: array[<strings>]
|
658
740
|
# lacp_mode: [active, passive, on]
|
659
741
|
# minimum_links: <string>
|
@@ -700,7 +782,7 @@ module Rbeapi
|
|
700
782
|
grpid = name.scan(/(?<=Port-Channel)\d+/)[0]
|
701
783
|
command = "show port-channel #{grpid} all-ports"
|
702
784
|
config = node.enable(command, encoding: 'text')
|
703
|
-
values = config.first[:result]['output'].scan(/\bEthernet[^\s]+/)
|
785
|
+
values = config.first[:result]['output'].scan(/\bEthernet[^\s]+/).sort
|
704
786
|
{ members: values }
|
705
787
|
end
|
706
788
|
private :parse_members
|
@@ -843,6 +925,9 @@ module Rbeapi
|
|
843
925
|
#
|
844
926
|
# @return [Boolean] Returns true if the command completed successfully.
|
845
927
|
def set_members(name, members, mode = nil)
|
928
|
+
fail ArgumentError, 'members must be an Array' unless
|
929
|
+
members.is_a?(Array)
|
930
|
+
|
846
931
|
current_members = Set.new parse_members(name)[:members]
|
847
932
|
members = Set.new members
|
848
933
|
|
@@ -1021,6 +1106,7 @@ module Rbeapi
|
|
1021
1106
|
# type: <string>,
|
1022
1107
|
# description: <string>,
|
1023
1108
|
# shutdown: <boolean>,
|
1109
|
+
# load_interval: <string>
|
1024
1110
|
# source_interface: <string>,
|
1025
1111
|
# multicast_group: <string>,
|
1026
1112
|
# udp_port: <fixnum>,
|
@@ -1079,7 +1165,7 @@ module Rbeapi
|
|
1079
1165
|
#
|
1080
1166
|
# @return [Hash<Symbol, Object>]
|
1081
1167
|
def parse_multicast_group(config)
|
1082
|
-
mdata =
|
1168
|
+
mdata = /^\s*vxlan multicast-group ([^\s]+)$/.match(config)
|
1083
1169
|
{ multicast_group: mdata ? mdata[1] : DEFAULT_MCAST_GRP }
|
1084
1170
|
end
|
1085
1171
|
private :parse_multicast_group
|
@@ -42,6 +42,7 @@ module Rbeapi
|
|
42
42
|
# IP interfaces configured using eAPI.
|
43
43
|
class Ipinterfaces < Entity
|
44
44
|
DEFAULT_ADDRESS = ''
|
45
|
+
DEFAULT_LOAD_INTERVAL = ''
|
45
46
|
|
46
47
|
##
|
47
48
|
# get returns a resource hash that represents the configuration of the IP
|
@@ -52,6 +53,7 @@ module Rbeapi
|
|
52
53
|
# address: <string>,
|
53
54
|
# mtu: <string>,
|
54
55
|
# helper_addresses: array<strings>
|
56
|
+
# load_interval: <string>
|
55
57
|
# }
|
56
58
|
#
|
57
59
|
# @param name [String] The full interface identifier of the interface to
|
@@ -70,6 +72,7 @@ module Rbeapi
|
|
70
72
|
response.merge!(parse_address(config))
|
71
73
|
response.merge!(parse_mtu(config))
|
72
74
|
response.merge!(parse_helper_addresses(config))
|
75
|
+
response.merge!(parse_load_interval(config))
|
73
76
|
response
|
74
77
|
end
|
75
78
|
|
@@ -83,11 +86,13 @@ module Rbeapi
|
|
83
86
|
# address: <string>,
|
84
87
|
# mtu: <string>,
|
85
88
|
# helper_addresses: array<strings>
|
89
|
+
# load_interval: <string>
|
86
90
|
# },
|
87
91
|
# <name>: {
|
88
92
|
# address: <string>,
|
89
93
|
# mtu: <string>,
|
90
94
|
# helper_addresses: array<strings>
|
95
|
+
# load_interval: <string>
|
91
96
|
# },
|
92
97
|
# ...
|
93
98
|
# }
|
@@ -162,6 +167,24 @@ module Rbeapi
|
|
162
167
|
end
|
163
168
|
private :parse_helper_addresses
|
164
169
|
|
170
|
+
##
|
171
|
+
# parse_load_interval scans the provided configuration block and
|
172
|
+
# parse the load-interval value. If the interface load-interval
|
173
|
+
# value is not configured, then this method will return the value of
|
174
|
+
# DEFAULT_LOAD_INTERVAL. The hash returned is intended to be merged into
|
175
|
+
# the interface resource hash.
|
176
|
+
#
|
177
|
+
# @api private
|
178
|
+
#
|
179
|
+
# @param config [String] The configuration block to parse.
|
180
|
+
#
|
181
|
+
# @return [Hash<Symbol, Object>] Returns the resource hash attribute.
|
182
|
+
def parse_load_interval(config)
|
183
|
+
mdata = /load-interval (\w+)$/.match(config)
|
184
|
+
{ load_interval: mdata.nil? ? DEFAULT_LOAD_INTERVAL : mdata[1] }
|
185
|
+
end
|
186
|
+
private :parse_load_interval
|
187
|
+
|
165
188
|
##
|
166
189
|
# create will create a new IP interface on the node. If the ip interface
|
167
190
|
# already exists in the configuration, this method will still return
|
@@ -312,6 +335,10 @@ module Rbeapi
|
|
312
335
|
enable = opts.fetch(:enable, true)
|
313
336
|
default = opts[:default] || false
|
314
337
|
|
338
|
+
if value
|
339
|
+
fail ArgumentError, 'value must be an Array' unless value.is_a?(Array)
|
340
|
+
end
|
341
|
+
|
315
342
|
case default
|
316
343
|
when true
|
317
344
|
cmds = 'default ip helper-address'
|
@@ -321,6 +348,27 @@ module Rbeapi
|
|
321
348
|
end
|
322
349
|
configure_interface(name, cmds)
|
323
350
|
end
|
351
|
+
|
352
|
+
##
|
353
|
+
# set_load_interval is a convenience function for configuring the
|
354
|
+
# value of interface load-interval
|
355
|
+
#
|
356
|
+
# @param name [String] The interface name to apply the configuration
|
357
|
+
# values to. The name must be the full interface identifier.
|
358
|
+
#
|
359
|
+
# @param opts [Hash] Optional keyword arguments.
|
360
|
+
#
|
361
|
+
# @option opts value [String] Specifies the value to configure the
|
362
|
+
# load-interval setting for. Valid values are between 5 and 600.
|
363
|
+
#
|
364
|
+
# @option opts default [Boolean] Configures the load-interval value on
|
365
|
+
# the interface using the default keyword.
|
366
|
+
#
|
367
|
+
# @return [Boolean] Returns true if the command completed successfully.
|
368
|
+
def set_load_interval(name, opts = {})
|
369
|
+
cmds = command_builder('load-interval', opts)
|
370
|
+
configure_interface(name, cmds)
|
371
|
+
end
|
324
372
|
end
|
325
373
|
end
|
326
374
|
end
|