rbeapi 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- 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/guide/conf.py
CHANGED
@@ -61,11 +61,11 @@ copyright = u'2016, Arista Networks - EOS+ Consulting Services'
|
|
61
61
|
# built documents.
|
62
62
|
#
|
63
63
|
import re
|
64
|
-
p = re.compile("
|
65
|
-
with open("../
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
p = re.compile("VERSION\s=\s'(.*)'")
|
65
|
+
with open("../lib/rbeapi/version.rb") as f:
|
66
|
+
data = f.read()
|
67
|
+
ver = p.search(data)
|
68
|
+
if ver:
|
69
69
|
version = ver.group(1)
|
70
70
|
|
71
71
|
#print "Version: {}".format(version)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Contributing
|
2
|
+
============
|
3
|
+
|
4
|
+
.. contents:: :local:
|
5
|
+
|
6
|
+
Contributing pull requests are gladly welcomed for this repository. Please note that all contributions that modify the library behavior require corresponding test cases otherwise the pull request will be rejected.
|
@@ -0,0 +1,134 @@
|
|
1
|
+
Getting Started
|
2
|
+
===============
|
3
|
+
|
4
|
+
.. contents:: :local:
|
5
|
+
|
6
|
+
In order to use rbeapi, the EOS command API must be enabled using management api http-commands configuration mode. This library supports eAPI calls over both HTTP and UNIX Domain Sockets. Once the command API is enabled on the destination node, create a configuration file with the node properities.
|
7
|
+
|
8
|
+
Note: The default search path for the conf file is ~/.eapi.conf followed by /mnt/flash/eapi.conf. This can be overridden by setting EAPI_CONF=<path file conf file> in your environment.
|
9
|
+
|
10
|
+
Example eapi.conf File
|
11
|
+
----------------------
|
12
|
+
|
13
|
+
Below is an example of an eAPI conf file. The conf file can contain more than one node. Each node section must be prefaced by connection:<name> where <name> is the name of the connection.
|
14
|
+
|
15
|
+
The following configuration options are available for defining node entries:
|
16
|
+
|
17
|
+
host - The IP address or FQDN of the remote device. If the host parameter is omitted then the connection name is used
|
18
|
+
username - The eAPI username to use for authentication (only required for http or https connections)
|
19
|
+
password - The eAPI password to use for authentication (only required for http or https connections)
|
20
|
+
enablepwd - The enable mode password if required by the destination node
|
21
|
+
transport - Configures the type of transport connection to use. The default value is https. Valid values are:
|
22
|
+
socket (available in EOS 4.14.5 or later)
|
23
|
+
http_local (available in EOS 4.14.5 or later)
|
24
|
+
http
|
25
|
+
https
|
26
|
+
port - Configures the port to use for the eAPI connection. A default port is used if this parameter is absent, based on the transport setting using the following values:
|
27
|
+
transport: http, default port: 80
|
28
|
+
transport: https, deafult port: 443
|
29
|
+
transport: https_local, default port: 8080
|
30
|
+
transport: socket, default port: n/a
|
31
|
+
open_timeout - The default number of seconds to wait for the eAPI connection to open. Any number may be used, including Floats for fractional seconds. Default value is 10 seconds.
|
32
|
+
read_timeout - The default number of seconds to wait for one block of eAPI results to be read (via one read(2) call). Any number may be used, including Floats for fractional seconds. Default value is 10 seconds.
|
33
|
+
|
34
|
+
Note: See the EOS User Manual found at arista.com for more details on configuring eAPI values.
|
35
|
+
|
36
|
+
All configuration values are optional.
|
37
|
+
|
38
|
+
[connection:veos01]
|
39
|
+
username: eapi
|
40
|
+
password: password
|
41
|
+
transport: http
|
42
|
+
|
43
|
+
[connection:veos02]
|
44
|
+
transport: http
|
45
|
+
|
46
|
+
[connection:veos03]
|
47
|
+
transport: socket
|
48
|
+
|
49
|
+
[connection:veos04]
|
50
|
+
host: 172.16.10.1
|
51
|
+
username: eapi
|
52
|
+
password: password
|
53
|
+
enablepwd: itsasecret
|
54
|
+
port: 1234
|
55
|
+
transport: https
|
56
|
+
|
57
|
+
[connection:localhost]
|
58
|
+
transport: http_local
|
59
|
+
|
60
|
+
The above example shows different ways to define EOS node connections. All configuration options will attempt to use default values if not explicitly defined. If the host parameter is not set for a given entry, then the connection name will be used as the host address.
|
61
|
+
|
62
|
+
Configuring [connection:localhost]
|
63
|
+
----------------------------------
|
64
|
+
|
65
|
+
The rbeapi library automatically installs a single default configuration entry for connecting to localhost host using a transport of sockets. If using the rbeapi library locally on an EOS node, simply enable the command API to use sockets and no further configuration is needed for rbeapi to function. If you specify an entry in a conf file with the name [connection:localhost], the values in the conf file will overwrite the default.
|
66
|
+
|
67
|
+
Using rbeapi
|
68
|
+
------------
|
69
|
+
|
70
|
+
The Ruby Client for eAPI was designed to be easy to use and implement for writing tools and applications that interface with the Arista EOS management plane.
|
71
|
+
|
72
|
+
Creating a connection and sending commands
|
73
|
+
------------------------------------------
|
74
|
+
|
75
|
+
Once EOS is configured properly and the config file created, getting started with a connection to EOS is simple. Below demonstrates a basic connection using rbeapi. For more examples, please see the examples folder.
|
76
|
+
|
77
|
+
# start by importing the library
|
78
|
+
require 'rbeapi/client'
|
79
|
+
|
80
|
+
# create a node object by specifying the node to work with
|
81
|
+
node = Rbeapi::Client.connect_to('veos01')
|
82
|
+
|
83
|
+
# send one or more commands to the node
|
84
|
+
node.enable('show hostname')
|
85
|
+
node.enable('show hostname')
|
86
|
+
=> [{:command=>"show hostname", :result=>{"fqdn"=>"veos01.arista.com", "hostname"=>"veos01"}, :encoding=>"json"}]
|
87
|
+
|
88
|
+
# use the config method to send configuration commands
|
89
|
+
node.config('hostname veos01')
|
90
|
+
=> [{}]
|
91
|
+
|
92
|
+
# multiple commands can be sent by using a list (works for both enable or config)
|
93
|
+
|
94
|
+
node.config(['interface Ethernet1', 'description foo'])
|
95
|
+
=> [{}, {}]
|
96
|
+
|
97
|
+
# return the running or startup configuration from the node (output omitted for brevity)
|
98
|
+
|
99
|
+
node.running_config
|
100
|
+
|
101
|
+
node.startup_config
|
102
|
+
|
103
|
+
Using the API
|
104
|
+
-------------
|
105
|
+
|
106
|
+
The rbeapi library provides both a client for send and receiving commands over eAPI as well as an API for working directly with EOS resources. The API is designed to be easy and straightforward to use yet also extensible. Below is an example of working with the vlans API
|
107
|
+
|
108
|
+
# create a connection to the node
|
109
|
+
require 'rbeapi/client'
|
110
|
+
node = Rbeapi::Client.connect_to('veos01')
|
111
|
+
|
112
|
+
# get the instance of the API (in this case vlans)
|
113
|
+
vlans = node.api('vlans')
|
114
|
+
|
115
|
+
# return all vlans from the node
|
116
|
+
vlans.getall
|
117
|
+
=> {"1"=>{:name=>"tester", :state=>"active", :trunk_groups=>[]},
|
118
|
+
"4"=>{:name=>"VLAN0004", :state=>"active", :trunk_groups=>[]},
|
119
|
+
"100"=>{:name=>"TEST_VLAN_100", :state=>"active", :trunk_groups=>[]},
|
120
|
+
"300"=>{:name=>"VLAN0300", :state=>"active", :trunk_groups=>[]}}
|
121
|
+
|
122
|
+
# return a specific vlan from the node
|
123
|
+
vlans.get(1)
|
124
|
+
=> {:name=>"tester", :state=>"active", :trunk_groups=>[]}
|
125
|
+
|
126
|
+
# add a new vlan to the node
|
127
|
+
vlans.create(400)
|
128
|
+
=> true
|
129
|
+
|
130
|
+
# set the new vlan name
|
131
|
+
vlans.set_name(100, value: 'foo')
|
132
|
+
=> true
|
133
|
+
|
134
|
+
All API implementations developed by Arista EOS+ CS are found in the rbeapi/api folder. See the examples folder for additional examples.
|
data/guide/index.rst
CHANGED
data/guide/installation.rst
CHANGED
@@ -1,4 +1,59 @@
|
|
1
1
|
Installation
|
2
2
|
============
|
3
3
|
|
4
|
-
.. contents:: :local:
|
4
|
+
.. contents:: :local:
|
5
|
+
|
6
|
+
The source code for rbeapi is provided on Github at http://github.com/arista-eosplus/rbeapi. All current development is done in the develop branch. Stable released versions are tagged in the master branch and uploaded to RubyGems.
|
7
|
+
|
8
|
+
To install the latest stable version of rbeapi, simply run gem install rbeapi
|
9
|
+
|
10
|
+
To install the latest development version from Github, simply clone the develop branch and run
|
11
|
+
|
12
|
+
$ rake build
|
13
|
+
$ rake install
|
14
|
+
|
15
|
+
To create an RPM, run rake rpm
|
16
|
+
|
17
|
+
To generate a SWIX file for EOS with necessary dependencies, run rake all_rpms then follow the swix create instructions, provided by the build. NOTE: PuppetLabs provides a puppet agent SWIX which includes Ruby 1.9.3 in /opt/puppet/bin/ which is different from where you might otherwise install Ruby. If you have installed the puppet-enterprise 3.x SWIX, then you should build and use the rbeapi-puppet3 swix, below. If you have installed the puppet-enterprise 2015.x SWIX, then you should build and use the rbeapi-puppet-aio swix, below. Otherwise, if you have installed at least Ruby 1.9.3 in the standard system location, then the rbeapi SWIX may be used.
|
18
|
+
|
19
|
+
$ bundle install --path .bundle/gems/
|
20
|
+
$ bundle exec rake all_rpms
|
21
|
+
...
|
22
|
+
RPMs are available in rpms/noarch/
|
23
|
+
Copy the RPMs to an EOS device then run the 'swix create' command.
|
24
|
+
Examples:
|
25
|
+
Puppet Open Source:
|
26
|
+
cd /mnt/flash; \
|
27
|
+
swix create rbeapi-0.4.0-1.swix \
|
28
|
+
rubygem-rbeapi-0.4.0-1.eos4.noarch.rpm \
|
29
|
+
rubygem-inifile-3.0.0-3.eos4.noarch.rpm \
|
30
|
+
rubygem-netaddr-1.5.0-2.eos4.noarch.rpm \
|
31
|
+
rubygem-net_http_unix-0.2.1-3.eos4.noarch.rpm
|
32
|
+
Puppet-enterprise agent (3.x):
|
33
|
+
cd/mnt/flash; \
|
34
|
+
swix create rbeapi-puppet3-0.4.0-1.swix \
|
35
|
+
rubygem-rbeapi-puppet3-0.4.0-1.eos4.noarch.rpm \
|
36
|
+
rubygem-inifile-puppet3-3.0.0-3.eos4.noarch.rpm \
|
37
|
+
rubygem-netaddr-puppet3-1.5.0-2.eos4.noarch.rpm
|
38
|
+
Puppet-All-in-one agent (2015.x/4.x):
|
39
|
+
cd/mnt/flash; \
|
40
|
+
swix create rbeapi-puppet-aio-0.4.0-1.swix \
|
41
|
+
rubygem-rbeapi-puppet-aio-0.4.0-1.eos4.noarch.rpm \
|
42
|
+
rubygem-inifile-puppet-aio-3.0.0-3.eos4.noarch.rpm \
|
43
|
+
rubygem-netaddr-puppet-aio-1.5.0-2.eos4.noarch.rpm \
|
44
|
+
rubygem-net_http_unix-puppet-aio-0.2.1-3.eos4.noarch.rpm
|
45
|
+
|
46
|
+
On EOS:
|
47
|
+
|
48
|
+
Arista# copy <URI-to-RPMs> flash:
|
49
|
+
Arista# bash
|
50
|
+
-bash-4.1# cd /mnt/flash/
|
51
|
+
-bash-4.1# swix create rbeapi-puppet3-0.4.0-1.swix \
|
52
|
+
rubygem-rbeapi-puppet3-0.4.0-1.eos4.noarch.rpm \
|
53
|
+
rubygem-inifile-puppet3-3.0.0-1.eos4.noarch.rpm \
|
54
|
+
rubygem-netaddr-puppet3-1.5.0-1.eos4.noarch.rpm
|
55
|
+
-bash-4.1# exit
|
56
|
+
Arista# copy flash:rbeapi-puppet3-0.4.0-1.swix extension:
|
57
|
+
Arista# extension rbeapi-puppet3-0.4.0-1.swix
|
58
|
+
Arista# copy installed-extensions boot-extensions
|
59
|
+
|
data/guide/license.rst
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
License
|
2
2
|
=======
|
3
3
|
|
4
|
-
..
|
5
|
-
|
4
|
+
.. contents:: :local:
|
5
|
+
|
6
|
+
Copyright (c) 2015, 2016, Arista Networks, Inc. All rights reserved.
|
7
|
+
|
8
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
9
|
+
|
10
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
Neither the name of Arista Networks nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/guide/overview.rst
CHANGED
@@ -3,17 +3,14 @@ Overview
|
|
3
3
|
|
4
4
|
.. contents:: :local:
|
5
5
|
|
6
|
-
Introduction
|
7
|
-
------------
|
8
|
-
|
9
6
|
The Ruby Client for eAPI provides a native Ruby implementation for programming Arista EOS network devices using Ruby. The Ruby client provides the ability to build native applications in Ruby that can communicate with EOS either locally via Unix domain sockets (on-box) or remotely over a HTTP/S transport (off-box). It uses a standard INI-style configuration file to specifiy one or more connection profiles.
|
10
7
|
|
11
8
|
The rbeapi implemenation also provides an API layer for building native Ruby objects that allow for configuration and state extraction of EOS nodes. The API layer provides a consistent implementation for working with EOS configuration resources. The implementation of the API layer is highly extensible and can be used as a foundation for building custom data models.
|
12
9
|
|
13
10
|
The libray is freely provided to the open source community for building robust applications using Arista EOS eAPI. Support is provided as best effort through Github iusses.
|
14
11
|
|
15
|
-
|
16
|
-
|
12
|
+
Requirements
|
13
|
+
------------
|
17
14
|
|
18
15
|
* Arista EOS 4.12 or later
|
19
16
|
* Arista eAPI enabled for at least one transport (see official EOS Config Guide at arista.com for details)
|
data/guide/testing.rst
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
Testing Modules
|
2
2
|
===============
|
3
3
|
|
4
|
-
.. contents:: :local:
|
4
|
+
.. contents:: :local:
|
5
|
+
|
6
|
+
The rbeapi library provides spec tests. To run the spec tests, you will need to update the dut.conf file found in spec/fixtures. The switch used for testing should have at least interfaces Ethernet1-7.
|
7
|
+
|
8
|
+
To run the spec tests, run bundle exec rspec spec from the root of the rbeapi source folder.
|
data/guide/upgrading.rst
ADDED
data/lib/rbeapi/api.rb
CHANGED
@@ -32,14 +32,14 @@
|
|
32
32
|
require 'rbeapi/eapilib'
|
33
33
|
|
34
34
|
##
|
35
|
-
# Rbeapi toplevel namespace
|
35
|
+
# Rbeapi toplevel namespace.
|
36
36
|
module Rbeapi
|
37
37
|
##
|
38
38
|
# Rbeapi::Api
|
39
39
|
module Api
|
40
40
|
##
|
41
41
|
# The Entity class provides a base class implementation for building
|
42
|
-
# API modules.
|
42
|
+
# API modules. The Entity class is typically not instantiated directly
|
43
43
|
# but serves as a super class with convenience methods used to
|
44
44
|
# work with the node.
|
45
45
|
class Entity
|
@@ -50,56 +50,56 @@ module Rbeapi
|
|
50
50
|
##
|
51
51
|
# Construct the node.
|
52
52
|
#
|
53
|
-
# @param [Node]
|
54
|
-
# send and receive eAPI messages
|
53
|
+
# @param node [Node] An instance of Rbeapi::Client::Node used to
|
54
|
+
# send and receive eAPI messages.
|
55
55
|
def self.instance(node)
|
56
56
|
new(node)
|
57
57
|
end
|
58
58
|
|
59
59
|
##
|
60
60
|
# The Entity class provides a base class implementation for building
|
61
|
-
# API modules.
|
61
|
+
# API modules. The Entity class is typically not instantiated directly
|
62
62
|
# but serves as a super class with convenience methods used to
|
63
63
|
# work with the node.
|
64
64
|
#
|
65
|
-
# @param [Node]
|
66
|
-
# that is used to send and receive eAPI messages
|
65
|
+
# @param node [Node] This should be an instance of Rbeapi::Client::Node
|
66
|
+
# that is used to send and receive eAPI messages.
|
67
67
|
#
|
68
68
|
def initialize(node)
|
69
69
|
@node = node
|
70
70
|
end
|
71
71
|
|
72
72
|
##
|
73
|
-
# Returns the running configuration from the node instance.
|
73
|
+
# Returns the running configuration from the node instance. This is
|
74
74
|
# a convenience method to easily access the current running config
|
75
|
-
# from an API module
|
75
|
+
# from an API module.
|
76
76
|
#
|
77
|
-
# @return [String] The current running-config from the node
|
77
|
+
# @return [String] The current running-config from the node.
|
78
78
|
def config
|
79
79
|
@node.running_config
|
80
80
|
end
|
81
81
|
|
82
82
|
##
|
83
83
|
# Provides a convenience method for access the connection error (if
|
84
|
-
# one exists) of the node's connection instance
|
84
|
+
# one exists) of the node's connection instance.
|
85
85
|
#
|
86
86
|
# @return [Rbeapi::Eapilib::CommandError] An instance of CommandError
|
87
|
-
# that can be used to further evaluate the root cause of an error
|
87
|
+
# that can be used to further evaluate the root cause of an error.
|
88
88
|
def error
|
89
89
|
@node.connection.error
|
90
90
|
end
|
91
91
|
|
92
92
|
##
|
93
93
|
# Returns a block of configuration from the current running config
|
94
|
-
# as a string.
|
94
|
+
# as a string. The argument is used to search the config and return
|
95
95
|
# the text along with any child configuration statements.
|
96
96
|
#
|
97
|
-
# @param [String]
|
97
|
+
# @param text [String] The text to be used to find the parent line
|
98
98
|
# in the nodes configuration.
|
99
99
|
#
|
100
|
-
# @
|
101
|
-
# the supplied argument.
|
102
|
-
# configuration, nil is returned
|
100
|
+
# @return [nil, String] Returns the block of configuration based on
|
101
|
+
# the supplied argument. If the argument is not found in the
|
102
|
+
# configuration, nil is returned.
|
103
103
|
def get_block(text)
|
104
104
|
mdata = /^#{text}$/.match(config)
|
105
105
|
return nil unless mdata
|
@@ -115,16 +115,16 @@ module Rbeapi
|
|
115
115
|
end
|
116
116
|
|
117
117
|
##
|
118
|
-
# Method called to send configuration commands to the node.
|
118
|
+
# Method called to send configuration commands to the node. This method
|
119
119
|
# will send the commands to the node and rescue from CommandError or
|
120
120
|
# ConnectionError.
|
121
121
|
#
|
122
|
-
# @param [String, Array]
|
123
|
-
# the API connection to configure the system
|
122
|
+
# @param commands [String, Array] The commands to send to the node over
|
123
|
+
# the API connection to configure the system.
|
124
124
|
#
|
125
125
|
# @return [Boolean] Returns True if the commands were successful or
|
126
126
|
# returns False if there was an error issuing the commands on the
|
127
|
-
# node. Use error to further investigate the cause of any errors
|
127
|
+
# node. Use error to further investigate the cause of any errors.
|
128
128
|
def configure(commands)
|
129
129
|
@node.config(commands)
|
130
130
|
return true
|
@@ -134,26 +134,27 @@ module Rbeapi
|
|
134
134
|
|
135
135
|
##
|
136
136
|
# Method called to build the correct version of a command based on
|
137
|
-
# the modifier options.
|
137
|
+
# the modifier options. If value option is set then it is appended
|
138
138
|
# to the command. If the enable option is false then the 'no'
|
139
|
-
# keyword is prefixed to the command.
|
140
|
-
# provided and set to true, then the default keyword is used.
|
139
|
+
# keyword is prefixed to the command. If the default value is
|
140
|
+
# provided and set to true, then the default keyword is used. If
|
141
141
|
# both options are provided, then default option takes precedence.
|
142
142
|
#
|
143
|
-
# @param [String, Array]
|
144
|
-
# over the API connection to configure the system
|
145
|
-
# @param [Hash] :opts the options for the command
|
143
|
+
# @param cmd [String, Array] The commands to send to the node
|
144
|
+
# over the API connection to configure the system.
|
146
145
|
#
|
147
|
-
# @
|
146
|
+
# @param opts [Hash] The options for the command.
|
147
|
+
#
|
148
|
+
# @option opts value [String] Optional value that is
|
148
149
|
# appended to the command if set.
|
149
150
|
#
|
150
|
-
# @option
|
151
|
+
# @option opts enable [Boolean] Prefix the command with 'no'.
|
151
152
|
# Default is true.
|
152
153
|
#
|
153
|
-
# @option
|
154
|
+
# @option opts default [Boolean] Configure the command using
|
154
155
|
# the default keyword. Default is false.
|
155
156
|
#
|
156
|
-
# @return [String] Returns built command string
|
157
|
+
# @return [String] Returns built command string.
|
157
158
|
def command_builder(cmd, opts = {})
|
158
159
|
enable = opts.fetch(:enable, true)
|
159
160
|
default = opts.fetch(:default, false)
|
@@ -167,13 +168,13 @@ module Rbeapi
|
|
167
168
|
# configure_interface sends the commands over eAPI to the destination
|
168
169
|
# node to configure a specific interface.
|
169
170
|
#
|
170
|
-
# @param [String]
|
171
|
-
# to.
|
171
|
+
# @param name [String] The interface name to apply the configuration
|
172
|
+
# to. The name value must be the full interface identifier.
|
172
173
|
#
|
173
|
-
# @param [Array]
|
174
|
-
# interface
|
174
|
+
# @param commands [Array] The list of commands to configure the
|
175
|
+
# interface.
|
175
176
|
#
|
176
|
-
# @return [Boolean] Returns true if the commands complete successfully
|
177
|
+
# @return [Boolean] Returns true if the commands complete successfully.
|
177
178
|
def configure_interface(name, commands)
|
178
179
|
commands = [*commands]
|
179
180
|
commands.insert(0, "interface #{name}")
|