Coder Social home page Coder Social logo

rbeapi's Introduction

Arista eAPI Ruby Library

Table of Contents

  1. Overview
  2. Getting Started
  3. Installation
  4. Upgrading
  5. Contributing
  6. Testing
  7. License

Build status

Rubygems.org: Gem Version

Style/package build: Start Build Status

Unit/System spec/coverage: Spec Build Status

Overview

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.

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.

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.

Requirements

  • Arista EOS 4.12 or later
  • Arista eAPI enabled for at least one transport (see official EOS Config Guide at arista.com for details)
  • Ruby 1.9.3 or later

Getting Started

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.

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.

Example eapi.conf File

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.

The following configuration options are available for defining node entries:

  • host - The IP address or FQDN of the remote device. If the host parameter is omitted then the connection name is used
  • username - The eAPI username to use for authentication (only required for http or https connections)
  • password - The eAPI password to use for authentication (only required for http or https connections)
  • enablepwd - The enable mode password if required by the destination node
  • transport - Configures the type of transport connection to use. The default value is https. Valid values are:
    • socket (available in EOS 4.14.5 or later)
    • http_local (available in EOS 4.14.5 or later)
    • http
    • https
  • 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:
    • transport: http, default port: 80
    • transport: https, deafult port: 443
    • transport: https_local, default port: 8080
    • transport: socket, default port: n/a
  • 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.
  • 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.

Note: See the EOS User Manual found at arista.com for more details on configuring eAPI values.

All configuration values are optional.

[connection:veos01]
username: eapi
password: password
transport: http

[connection:veos02]
transport: http

[connection:veos03]
transport: socket

[connection:veos04]
host: 172.16.10.1
username: eapi
password: password
enablepwd: itsasecret
port: 1234
transport: https

[connection:localhost]
transport: http_local

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.

Configuring [connection:localhost]

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.

Using rbeapi

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.

Creating a connection and sending commands

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.

# start by importing the library
require 'rbeapi/client'

# create a node object by specifying the node to work with
node = Rbeapi::Client.connect_to('veos01')

# send one or more commands to the node
node.enable('show hostname')
node.enable('show hostname')
=> [{:command=>"show hostname", :result=>{"fqdn"=>"veos01.arista.com", "hostname"=>"veos01"}, :encoding=>"json"}]

# use the config method to send configuration commands
node.config('hostname veos01')
=> [{}]

# multiple commands can be sent by using a list (works for both enable or config)

node.config(['interface Ethernet1', 'description foo'])
=> [{}, {}]

# return the running or startup configuration from the node as a string (output omitted for brevity)

node.running_config

node.startup_config

Using the API

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

# create a connection to the node
require 'rbeapi/client'
node = Rbeapi::Client.connect_to('veos01')

# get the instance of the API (in this case vlans)
vlans = node.api('vlans')

# return all vlans from the node
vlans.getall
=> {"1"=>{:name=>"tester", :state=>"active", :trunk_groups=>[]},
 "4"=>{:name=>"VLAN0004", :state=>"active", :trunk_groups=>[]},
 "100"=>{:name=>"TEST_VLAN_100", :state=>"active", :trunk_groups=>[]},
 "300"=>{:name=>"VLAN0300", :state=>"active", :trunk_groups=>[]}}

# return a specific vlan from the node
vlans.get(1)
=> {:name=>"tester", :state=>"active", :trunk_groups=>[]}

# add a new vlan to the node
vlans.create(400)
=> true

# set the new vlan name
vlans.set_name(100, value: 'foo')
=> true

All API implementations developed by Arista EOS+ CS are found in the rbeapi/api folder. See the examples folder for additional examples.

Installation

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.

  • To install the latest stable version of rbeapi, simply run gem install rbeapi

  • To install the latest development version from Github, simply clone the develop branch and run

    $ rake build
    $ rake install
    
  • To create an RPM, run rake rpm

  • 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: Puppet provides a puppet agent SWIX which includes Ruby in /opt/puppet/bin/, or /opt/puppetlabs/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, or higher, (the all-in-one agent) then you should build and use the rbeapi-puppet-aio swix, below. Chef includes its own Ruby in the omnibus installation package in /opt/chef/bin/. For Chef, use the rbeapi-chef SWIX package. Otherwise, if you have installed at least Ruby 1.9.3 in the standard system location, then the rbeapi SWIX may be used.

    $ bundle install --path .bundle/gems/
    $ bundle exec rake all_rpms
    ...
    RPMs are available in rpms/noarch/
    Copy the RPMs to an EOS device then run the 'swix create' command.
      Examples: 
        Puppet Open Source: 
          cd /mnt/flash; \
          swix create rbeapi-1.3-1.swix \
          rubygem-rbeapi-1.3-1.eos4.noarch.rpm \
          rubygem-inifile-3.0.0-3.eos4.noarch.rpm \
          rubygem-netaddr-1.5.0-2.eos4.noarch.rpm \
          rubygem-net_http_unix-0.2.1-3.eos4.noarch.rpm
        Puppet-enterprise agent (3.x): 
          cd/mnt/flash; \
          swix create rbeapi-puppet3-1.3-1.swix \
          rubygem-rbeapi-puppet3-1.3-1.eos4.noarch.rpm \
          rubygem-inifile-puppet3-3.0.0-3.eos4.noarch.rpm \
          rubygem-netaddr-puppet3-1.5.0-2.eos4.noarch.rpm
        Puppet-All-in-one agent (2015.x/4.x): 
          cd/mnt/flash; \
          swix create rbeapi-puppet-aio-1.3-1.swix \
          rubygem-rbeapi-puppet-aio-1.3-1.eos4.noarch.rpm \
          rubygem-inifile-puppet-aio-3.0.0-3.eos4.noarch.rpm \
          rubygem-netaddr-puppet-aio-1.5.0-2.eos4.noarch.rpm \
          rubygem-net_http_unix-puppet-aio-0.2.1-3.eos4.noarch.rpm
    
        Chef client:
          cd /mnt/flash; \
          swix create rbeapi-chef-1.3-1.swix \
          rubygem-rbeapi-chef-1.3-1.eos4.noarch.rpm \
          rubygem-inifile-chef-3.0.0-5.eos4.noarch.rpm \
          rubygem-netaddr-chef-1.5.1-4.eos4.noarch.rpm \
          rubygem-net_http_unix-chef-0.2.2-5.eos4.noarch.rpm
    

    On EOS:

    Arista# copy <URI-to-RPMs> flash:
    Arista# bash
    -bash-4.1# cd /mnt/flash/
    -bash-4.1# swix create rbeapi-puppet3-1.3-1.swix \
               rubygem-rbeapi-puppet3-1.3-1.eos4.noarch.rpm \
               rubygem-inifile-puppet3-3.0.0-1.eos4.noarch.rpm \
               rubygem-netaddr-puppet3-1.5.0-1.eos4.noarch.rpm
    -bash-4.1# exit
    Arista# copy flash:rbeapi-puppet3-1.3-1.swix extension:
    Arista# extension rbeapi-puppet3-1.3-1.swix
    Arista# copy installed-extensions boot-extensions
    

Upgrading

On EOS:

Arista# no extension pe-rbeapi-1.1.0-1.swix
Arista# extension rbeapi-puppet3-1.3-1.swix
Arista# copy installed-extensions boot-extensions

Testing

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.

  • To run the spec tests, run bundle exec rspec spec from the root of the rbeapi source folder.

Contributing

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.

License

Copyright (c) 2016, Arista Networks, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

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.

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.

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.

rbeapi's People

Contributors

alvagante avatar brandt avatar devrobo avatar huntburdick avatar jerearista avatar kakkotetsu avatar n1cn0c avatar privateip avatar rknaus avatar shermdog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rbeapi's Issues

PeerEthernet regex issue

  • Change regex to ignore lag members that start with PeerEthernet
  • Add missing systest to check for this

Need to validate value keyword in set methods when array

Need to add checks where needed similar to set_trunk_allowed_vlans in switchports.rb. These checks are validating the parameters with respect to the rbeapi interface and not with respect to EOS.

Need to add test cases to unit tests, move any of these checks out of system tests into unit tests.

Need to remove checks that attempt to validate parameters with respect to EOS supported values because doing so increases the probability that a future release of EOS may no longer work with an older release of rbeapi. The approach we are taking is to send the command to EOS and let EOS tell us the parameters are bad.

rbeapi coding documentation incomplete

Need an example for all get and getall methods.
Need method documentation for all global methods.
Any other changes required for the auto-generated documentation.

switchport api should support trunk groups

It looks like the switchport api doesn't support trunk groups, which causes rbeapi to be confused about:

  • what access vlan is applied to the interface
  • what trunk vlan is applied to the interface
  • what vlans are allowed on the interface.

Testing locally with vEOS and rbeapi 0.2.0

Software image version: 4.15.0F
Architecture:           i386
Internal build version: 4.15.0F-2387143.4150F
Internal build ID:      1d97861d-09c7-4fc3-b38d-a98c99b77ae9

Switch configuration

full running-config at https://gist.github.com/logikal/f8359047e55ad994ea8b

switch2(config-if-Et3)# show vlan trunk group
VLAN     Trunk Groups
----     ----------------------------------------------------------------------
1
240      PEER, PROD
340      PEER, STAGING
4093     mlagpeer
switch2(config-if-Et3)# show running config #edited for brevity

vlan 240
   name Production-inside
   trunk group PEER
   trunk group PROD
!
interface Ethernet3
   switchport mode trunk
   switchport trunk group PROD
!

Ruby code

require 'rbeapi'

connection = Rbeapi::Client.connect(
      host: '192.168.50.12',
      transport: 'https',
      password: ENV['SWITCH_PASS'],
      username: ENV['SWITCH_USER']
    )
    switch = Rbeapi::Client::Node.new(connection)

switchports = switch.api('switchports')

switchports.get('Ethernet3')
=> {:mode=>"trunk",
 :access_vlan=>"1",
 :trunk_native_vlan=>"1",
 :trunk_allowed_vlans=>
  [1,
   2,
   3,
   4,
   5,
   6,
   ...
   4094
  ]
}

api interfaces get_members() passes format: instead of encoding: to enable()

Found with EOS 4.15.2 now that 'show port-channel all-ports' has been converted to JSON, the API does not parse the output, properly.

        command = "show port-channel #{grpid} all-ports"
        config = node.enable(command, format: 'text')
        values = config.first[:result]['output'].scan(/\bEthernet[^\s]+/)

Should be

        command = "show port-channel #{grpid} all-ports"
        config = node.enable(command, encoding: 'text')
        values = config.first[:result]['output'].scan(/\bEthernet[^\s]+/)

Enable password setting in the .eapi.conf file not honored

It doesn't seem to be used.

enablepwd is referenced in the eapi.conf section of the README.

There is a reference to enable_pwd in https://github.com/arista-eosplus/rbeapi/blob/develop/lib/rbeapi/client.rb#L125 though I can't see where it's being used.

The only way I could get enable mode to work is calling node.enable_authentication with the password explicitly.

I'd submit a patch except I can't seem to get the tests to run cleanly (on master) against vEOS. Who do I get help with that?

failure when eapi.conf is not formatted correctly

pyeapi should not crash when an eapi.conf file is not properly formatted. Perhaps we could wrap SafeConfigParser in a try/except block and just throw a warning that the file did not parse.

Background, in some cases, where the application does not make use of the eapi.conf, but uses the connect() method, instead, the existence of a file named eapi.conf could cause the application to fail.

snmp_users_set method contains fails to set all information

netdev/snmp.rb snmp_user_set fails in puppet-netdev with

Error: /Stage[main]/Main/Snmp_user[trapuser]: Could not evaluate: undefined local variable or method `running_config' for #<Rbeapi::Netdev::Snmp:0x007f8ecd64e750>
snmp_user { 'trapuser:v3':
  roles           => ['ops'],
  #version         => 'v3',
  enforce_privacy => true,
  localized_key   => false,
  auth            => 'sha',
  #password        => 'my_auth_phrase',
  password        => '59049ce9523878cbd1e930062e40d1848d2d80b8',
  privacy         => 'aes128',
  #private_key     => 'my_priv_phrase',
  private_key     => 'b2f0f1ce083aca9e50e33fe4e73982ac813b77c4',
}

This appears to be the last netdev api. Mayeb its time to update this and puppet-netdev to switch this to a newer-style rbeapi api.

Error installing rbeapi-chef-1.2-1.swix: RPM install error

hi

I am getting the following error on Arista DCS-7150S-64-CL-R switch while installing extension rbeapi-chef-1.2-1.swix

% Error installing rbeapi-chef-1.2-1.swix: RPM install error: Transaction check failed: chef is needed by rubygem-rbeapi-chef-1.2-1.eos4.noarch
chef is needed by rubygem-inifile-chef-3.0.0-5.eos4.noarch
chef is needed by rubygem-netaddr-chef-1.5.1-4.eos4.noarch
chef is needed by rubygem-net_http_unix-chef-0.2.2-5.eos4.noarch

Here is the Arista switch release.

Arista DCS-7150S-64-CL-R
Hardware version: 01.02
Serial number: JPE13370490
System MAC address: 001c.7341.4cb3

Software image version: 4.13.14M
Architecture: i386

Wildcard connection config gets clobbered

Given the following configuration:

[connection:*]
username: foo
password: bar

Given the following code:

client = Rbeapi::Client.connect_to('host1')
client = Rbeapi::Client.connect_to('host2')

The config['host'] of value * is clobbered to host1: https://github.com/arista-eosplus/rbeapi/blob/develop/lib/rbeapi/client.rb#L104

The second call to connect_to('host2') has a config['host'] value of host1

It should probably .dup the configuration before modifying config['host'].

rbeapi exits if $HOME is not set

rbeapi should gracefully continue if the path expansion for '~/.eapi.conf' fails.

bash-3.2$ (unset HOME; irb)
irb(main):001:0> require 'rbeapi/client'
=> true
irb(main):002:0> node = Rbeapi::Client.connect_to('veos01')
ArgumentError: couldn't find HOME environment -- expanding `~'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:190:in `expand_path'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:190:in `block in autoload'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:189:in `each'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:189:in `autoload'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:171:in `initialize'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:61:in `new'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:61:in `config'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:89:in `config_for'
    from /opt/crossfader/versions/ruby/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rbeapi-0.2.0/lib/rbeapi/client.rb:102:in `connect_to'
    from (irb):2
    from /opt/crossfader/versions/ruby/1.9.3-p448/bin/irb:12:in `<main>'

wildcard connection config

Looking at the code, the [connection:*] is used when there are no explicit name matches. However, I think it's more useful to use it as a 'base' configuration. Setting from other explicit matches will be merged with the wildcard match.

For example:

[connection:*]
username: eapi
password: mysecret

[connection:veos1]
192.168.1.1

[connection:veos2]
192.168.1.2

The configuration for veos1 should be:

{
   'username' => 'eapi',
   'password' => 'mysecret',
   'host' => '192.168.1.1'
}

Right now, the username and password is needed for each switch even though they all have the same credentials.

multicast group parsing for vxlan interfaces fails

Hi there,

there is an issue when parsing the multicast-group configuration for a vxlan interface.

Symptoms:

  • if the multicast group is not set for the interface, the returned value is decap

Reason:

  • the dumped running-config includes all the config commands, including the vxlan multicast-group decap (see bellow the output example)
  • since this line is dumped every time, the regex used in parse_multicast_group will match it when the multicast group is not configured

Sample output when multicast group is not set:

no interface vxlan 1
interface vxlan 1
show running-config all interfaces vxlan 1
interface Vxlan1
   no description
   no shutdown
   default load-interval
      [output omitted]
   no vxlan multicast-group
   no vxlan controller-client 
   vxlan udp-port 4789
      [output omitted]
   no vxlan multicast-group decap
   no vxlan flood step

Need units tests for framework

The majority of unit tests validate the API. Need more unit tests to test the framework. Need to address this issue after the code coverage reports are enabled.

interfaces API may appear to return duplicate port-channel members on MLAG interfaces

show port-channel <n> all-ports on an MLAG port-channel will return the local, physical 'Ethernet' and a 'PeerEthernet' interface. The second gets caught by the regex scan and gets included in the port-channel members list. This can cause puppet to mistakenly believe that the active configuration is out of sync with the desired and re-apply the port-channel config to that interface.

Add [connection:*] to eapi.conf syntax

this will provide a default connection profile for connection names that do not have a more specific entry in eapi.conf.

[connection:eos01]
username: eapi
password: password
transport: http

[connection:*]
username: eapi
password: password
transport: http

In the above example a connection to any hostname other than eos01 will result in a connection using the section entry defined as [connection:*]

This is related to PR #15

snmp_users method does not return the aes key

The netdev/snmp api snmp_users method does not return all fields for users. Seen in netdev-eos Puppet provider.

snmp-server user trapuser ops v3 localized f5717f080027c9c8c500 auth sha f49e5fa1322914e2a9353b21e1f74753551cd90d priv aes f49e5fa1322914e2a9353b21e1f74753551cd90d
bundle exec puppet resource snmp_user
snmp_user { 'trapuser:v3':
  ensure    => 'present',
  auth      => 'sha',
  engine_id => 'f5717f080027c9c8c500',
  password  => 'f49e5fa1322914e2a9353b21e1f74753551cd90d',
  privacy   => 'aes128',
  roles     => ['ops'],

NoMethodError when accessing a vlan-name containing a '-' character

rbeapi returns a NoMethodError when retrieving a VLAN-name which contains the '-' character.

Arista#sh vlan
VLAN  Name                             Status    Ports
----- -------------------------------- --------- -------------------------------
1     default                          active    Et1, Et2, Et3, Et4
100   test-2-3                         active   
333   VLAN0333                         active   
irb(main):006:0* vlans.getall

NoMethodError: undefined method `[]' for nil:NilClass
    from /opt/crossfader/versions/ruby/1.9.3-p448/gemsets/playground/ruby/1.9.1/gems/rbeapi-0.1.0/lib/rbeapi/api/vlans.rb:110:in `parse_name'
    from /opt/crossfader/versions/ruby/1.9.3-p448/gemsets/playground/ruby/1.9.1/gems/rbeapi-0.1.0/lib/rbeapi/api/vlans.rb:69:in `get'
    from /opt/crossfader/versions/ruby/1.9.3-p448/gemsets/playground/ruby/1.9.1/gems/rbeapi-0.1.0/lib/rbeapi/api/vlans.rb:94:in `block in getall'
    from /opt/crossfader/versions/ruby/1.9.3-p448/gemsets/playground/ruby/1.9.1/gems/rbeapi-0.1.0/lib/rbeapi/api/vlans.rb:93:in `each'
    from /opt/crossfader/versions/ruby/1.9.3-p448/gemsets/playground/ruby/1.9.1/gems/rbeapi-0.1.0/lib/rbeapi/api/vlans.rb:93:in `each_with_object'
    from /opt/crossfader/versions/ruby/1.9.3-p448/gemsets/playground/ruby/1.9.1/gems/rbeapi-0.1.0/lib/rbeapi/api/vlans.rb:93:in `getall'
    from (irb):6
    from /opt/crossfader/versions/ruby/1.9.3-p448/bin/irb:12:in `<main>'

add read_timeout and open_timeout to client.rb

this issue is to track adding optional keyword args for #config and #enable to set the timeout values. Values should be transparently passed through #run_commands to eapilib. If the values are not specified in the method (set to nil) then the default values are to be invoked in eapilib.

timeout values should also be configurable via eapi.conf

references:

vlans API only returns first trunk_group

-bash-4.1# FastCli -p 15 -c 'show run sect vlan'
vlan 5
   name myname
   trunk group mlag_ctl
   trunk group test
irb(main):004:0> vlans = node.api('vlans').getall
=> {"1"=>{:name=>"default", :state=>"active", :trunk_groups=>[]}, "5"=>{:name=>"myname", :state=>"active", :trunk_groups=>["mlag_ctl"]}}
irb(main):006:0> vlans['5']
=> {:name=>"jere05", :state=>"active", :trunk_groups=>["mlag_ctl"]}

trunk_groups should be :trunk_groups=>["mlag_ctl", "test"]

'create swix' fails, can i --force?

i've got a couple of questions/probs - might be easy ones for you to solve:

  1. which rbeapi should i upload to the switch? is the pe-* or the rubygem-* ?
  2. the 'swix create' fails to bundle the rpms, what's up with that? is it safe to use --force option?
  3. how can i tell if rbeapi is installed properly? (i've enabled eapi with both http and unix-socket)
  4. my next step is to install puppet-eos... stay tune.

thanks for all the support!!

[admin@sw1 flash]$ swix create rbeapi-0.1.0-eos4.swix rubygem.rpm
adding: manifest.txt (stored 0%)
adding: pe-rubygem-inifile-3.0.0-2.eos4.noarch.rpm (stored 0%)
adding: pe-rubygem-rbeapi-0.1.0-1.eos4.noarch.rpm (stored 0%)
adding: pe-rubygem-rbeapi-0.1.0-2.eos4.noarch.rpm (stored 0%)
adding: rubygem-inifile-3.0.0-2.eos4.noarch.rpm (stored 0%)
adding: rubygem-net_http_unix-0.2.1-2.eos4.noarch.rpm (stored 0%)
adding: rubygem-rbeapi-0.1.0-1.eos4.noarch.rpm (stored 0%)
adding: rubygem-rbeapi-0.1.0-2.eos4.noarch.rpm (stored 0%)
[admin@sw1 flash]$ logout
sw1#config
sw1(config)#copy flash:rbeapi-0.1.0-eos4.swix extension:
Copy completed successfully.
sw1(config)#extension rbeapi-0.1.0-eos4.swix
% Error installing rbeapi-0.1.0-eos4.swix: RPM install error: Transaction check failed: pe-ruby is needed by pe-rubygem-inifile-3.0.0-2.eos4.noarch
pe-rubygems is needed by pe-rubygem-inifile-3.0.0-2.eos4.noarch
pe-ruby is needed by pe-rubygem-rbeapi-0.1.0-2.eos4.noarch
pe-rubygem(net-http-unix) is needed by pe-rubygem-rbeapi-0.1.0-2.eos4.noarch
pe-rubygems is needed by pe-rubygem-rbeapi-0.1.0-2.eos4.noarch
ruby(abi) = %{rubyabi} is needed by rubygem-inifile-3.0.0-2.eos4.noarch
ruby(abi) = %{rubyabi} is needed by rubygem-net_http_unix-0.2.1-2.eos4.noarch
ruby(abi) = %{rubyabi} is needed by rubygem-rbeapi-0.1.0-2.eos4.noarch

sw1(config)#extension rbeapi-0.1.0-eos4.swix force
sw1(config)#sho extensions
Name Version/Release Status extension


EosCliForSplunk-1.1.2.rpm 1.1.2/1.fc14 A, I 1
Telemetry-1.1.2.rpm 1.1.2/1 A, I 1
puppet-enterprise-3.8.0-eos-4-i386.swix 3.8.0.3/1.pe.eos4 A, NI 21
rbeapi-0.1.0-eos4.swix 3.0.0/2.eos4 A, F 7
splunkforwarder-6.2.2-255606.i386.rpm 6.2.2/255606 A, I 1

A: available | NA: not available | I: installed | NI: not installed | F: forced
sw1(config)#extension puppet-enterprise-3.8.0-eos-4-i386.swix
sw1(config)#

sw1(config)#puppet resource --types
augeas
computer
cron
exec
file
filebucket
group
host
interface
k5login
macauthorization
mailalias
maillist
..
..
sw1(config)#puppet resource --types | grep eos
'sudo puppet resource --types | grep eos' returned error code:1

the "running_config" api error

hi,

The running_config calls get_config, and it uses strip in these two lines.

rbeapi/lib/rbeapi/client.rb

Lines 515 to 516 in 7ad79fa

return result.first['output'].strip.split("\n") unless as_string
result.first['output'].strip

What about the config result is nil? and then the strip will fail?

How to install/upgrade the rbeapi.rpm via puppet?

Hi,
I played around with the idea to update the rbeapi.rpm via puppet.
I cannot use the rbeapi it self, because than I am limited to updates
and cannot to an initial install.
Therefore I tired to warp it into FastCli -c ‚foo bar‘ commands, which I put into a shell script.
If I execute the script it works fine, but if the puppet agent executes it is not able to connect through the FastCli call.

Therefore I used strace to see what is happening.

Puppet run

execve("/usr/bin/FastCli", ["/usr/bin/FastCli", "-p", "15", "-c", "show extension"], [/* 15 vars /]) = 0
..
execve("/usr/bin/fastclient", ["fastclient", "-r", "FastCli", "-t", "CliPoolMgr/ar", "-p", "15", "-c", "show extension"], [/
16 vars */]) = 0
..
connect(6, {sa_family=AF_FILE, path=@"/fastclient/CliPoolMgr/ar"}, 28) = -1 ECONNREFUSED (Connection refused)
..

If I run it as the root user it works.

execve("/usr/bin/FastCli", ["/usr/bin/FastCli", "-p", "15", "-c", "show extension"], [/* 22 vars /]) = 0
..
execve("/usr/bin/fastclient", ["fastclient", "-r", "FastCli", "-t", "CliPoolMgr/ar", "-p", "15", "-c", "show extension"], [/
23 vars */]) = 0
..
connect(6, {sa_family=AF_FILE, path=@"/fastclient/CliPoolMgr/ar"}, 28) = 0

Does anyone have an idea how to solve this?

Puppet:

exec { 'update_extension':
subscribe => File['/usr/local/sbin/update_extension.sh'],
refreshonly => true,
user => 'root',
group => 'root',
logoutput => true,
command => '/usr/local/sbin/update_extension.sh',
}

script:

!/bin/bash -x

/usr/bin/strace /usr/bin/FastCli -p 15 -c 'show extension'

can't rake all_rpms

hi, my intention is to build all necessary rpms to later build swix in my eos switch.
but i kept running into rake problem. like for example, if i generate individual inifile below..
my host is ubuntu 12.04.05. i tried to install gawk, mawk, original awk.. all of them failed..
my ruby/gem/rake experience is nil to nothing.
can you help? thanks!

me@chloroplast:~/src/rbeapi$ sudo rake inifile
Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options: GNU long options:
-f progfile --file=progfile
-F fs --field-separator=fs
-v var=val --assign=var=val
-m[fr] val
-O --optimize
-W compat --compat
-W copyleft --copyleft
-W copyright --copyright
-W dump-variables[=file] --dump-variables[=file]
-W exec=file --exec=file
-W gen-po --gen-po
-W help --help
-W lint[=fatal] --lint[=fatal]
-W lint-old --lint-old
-W non-decimal-data --non-decimal-data
-W profile[=file] --profile[=file]
-W posix --posix
-W re-interval --re-interval
-W source=program-text --source=program-text
-W traditional --traditional
-W usage --usage
-W use-lc-numeric --use-lc-numeric
-W version --version

To report bugs, see node Bugs' ingawk.info', which is
section `Reporting Problems and Bugs' in the printed version.

gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.

Examples:
gawk '{ sum += $1 }; END { print sum }' file
gawk -F: '{ print $1 }' /etc/passwd
ERROR: While executing gem ... (ArgumentError)
Illformed requirement ["="]
Building rpm for inifile ()
error: line 5: Empty tag: Version:
error: line 5: Empty tag: Version:
RPMs are available in rpms/noarch/ ---- it's a lie!!

rbeapi swix/rpms fail to install completely on EOS

Need to include rubygem netaddr as a requirement in the swix file

bash-4.1# sudo /opt/puppet/bin/gem install --local /rbeapi-0.1.0.gem
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: rbeapi requires netaddr (>= 0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.