Skip to content

Commit

Permalink
Release 1.0
Browse files Browse the repository at this point in the history
Release 1.0
Merge pull request #153 from arista-eosplus/develop
  • Loading branch information
jerearista authored Sep 26, 2016
2 parents 3a11da2 + 96da647 commit 15e6443
Show file tree
Hide file tree
Showing 56 changed files with 2,725 additions and 329 deletions.
287 changes: 211 additions & 76 deletions CHANGELOG.md

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

gem 'inifile'
gem 'json'
gem 'net_http_unix'
gem 'netaddr'

group :development do
gem 'rubocop', '>=0.35.1'
gem 'guard'
gem 'guard-rspec'
gem 'guard-rubocop'
Expand All @@ -24,10 +22,23 @@ group :development, :test do
gem 'pry', require: false
gem 'pry-doc', require: false
gem 'pry-stack_explorer', require: false
gem 'rbeapi', '0.5.1', path: '.'
gem 'rbeapi', '1.0', path: '.'
gem 'ci_reporter_rspec', require: false
gem 'simplecov-json', require: false
gem 'simplecov-rcov', require: false
end

# Rubocop > 0.37 requires a gem that only works with ruby 2.x
if RUBY_VERSION.to_f < 2.0
gem 'json', '<2.0'
group :development, :test do
gem 'rubocop', '>=0.35.1', '< 0.38'
end
else
gem 'json'
group :development, :test do
gem 'rubocop', '>=0.35.1'
end
end

# vim:ft=ruby
112 changes: 74 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,28 @@ Unit/System spec/coverage: [![Spec Build Status](https://revproxy.arista.com/eos

# 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.
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)
* 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
Expand Down Expand Up @@ -152,7 +164,7 @@ node.config('hostname veos01')
node.config(['interface Ethernet1', 'description foo'])
=> [{}, {}]
# return the running or startup configuration from the node (output omitted for brevity)
# return the running or startup configuration from the node as a string (output omitted for brevity)
node.running_config
Expand Down Expand Up @@ -214,17 +226,18 @@ and uploaded to [RubyGems](https://rubygems.org/).
```

* 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:
[PuppetLabs](https://puppetlabs.com/misc/pe-files) 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.
* 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](https://puppet.com/misc/pe-files) 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/
Expand All @@ -235,38 +248,46 @@ Copy the RPMs to an EOS device then run the 'swix create' command.
Examples:
Puppet Open Source:
cd /mnt/flash; \
swix create rbeapi-0.5.1-1.swix \
rubygem-rbeapi-0.5.1-1.eos4.noarch.rpm \
swix create rbeapi-1.0-1.swix \
rubygem-rbeapi-1.0-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-0.5.1-1.swix \
rubygem-rbeapi-puppet3-0.5.1-1.eos4.noarch.rpm \
swix create rbeapi-puppet3-1.0-1.swix \
rubygem-rbeapi-puppet3-1.0-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-0.5.1-1.swix \
rubygem-rbeapi-puppet-aio-0.5.1-1.eos4.noarch.rpm \
swix create rbeapi-puppet-aio-1.0-1.swix \
rubygem-rbeapi-puppet-aio-1.0-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.0-1.swix \
rubygem-rbeapi-chef-1.0-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-0.5.1-1.swix \
rubygem-rbeapi-puppet3-0.5.1-1.eos4.noarch.rpm \
-bash-4.1# swix create rbeapi-puppet3-1.0-1.swix \
rubygem-rbeapi-puppet3-1.0-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-0.5.1-1.swix extension:
Arista# extension rbeapi-puppet3-0.5.1-1.swix
Arista# copy flash:rbeapi-puppet3-1.0-1.swix extension:
Arista# extension rbeapi-puppet3-1.0-1.swix
Arista# copy installed-extensions boot-extensions
```

Expand All @@ -275,7 +296,7 @@ Copy the RPMs to an EOS device then run the 'swix create' command.
On EOS:
```
Arista# no extension pe-rbeapi-0.3.0-1.swix
Arista# extension rbeapi-puppet3-0.5.1-1.swix
Arista# extension rbeapi-puppet3-1.0-1.swix
Arista# copy installed-extensions boot-extensions
```

Expand All @@ -298,12 +319,27 @@ corresponding test cases otherwise the pull request will be rejected.

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.
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.
55 changes: 38 additions & 17 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,50 +82,65 @@ task all_rpms: :build do
puts 'RPMs are available in rpms/noarch/'
puts "Copy the RPMs to an EOS device then run the 'swix create' command."
puts ' Examples: '
puts ' Chef client: '
puts ' cd /mnt/flash; \\'
puts " swix create rbeapi-chef-#{Rbeapi::VERSION}-1.swix \\"
puts " rubygem-rbeapi-chef-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \\"
puts ' rubygem-inifile-chef-3.0.0-5.eos4.noarch.rpm \\'
puts ' rubygem-netaddr-chef-1.5.1-4.eos4.noarch.rpm \\'
puts ' rubygem-net_http_unix-chef-0.2.2-5.eos4.noarch.rpm'
puts ' Puppet Open Source: '
puts ' cd /mnt/flash; \\'
puts " swix create rbeapi-#{Rbeapi::VERSION}-1.swix \\"
puts " rubygem-rbeapi-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \\"
puts ' rubygem-inifile-3.0.0-3.eos4.noarch.rpm \\'
puts ' rubygem-netaddr-1.5.0-2.eos4.noarch.rpm \\'
puts ' rubygem-net_http_unix-0.2.1-3.eos4.noarch.rpm'
puts ' rubygem-inifile-3.0.0-5.eos4.noarch.rpm \\'
puts ' rubygem-netaddr-1.5.1-4.eos4.noarch.rpm \\'
puts ' rubygem-net_http_unix-0.2.2-5.eos4.noarch.rpm'
puts ' Puppet-enterprise agent (3.x): '
puts ' cd/mnt/flash; \\'
puts " swix create rbeapi-puppet3-#{Rbeapi::VERSION}-1.swix \\"
puts " rubygem-rbeapi-puppet3-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \\"
puts ' rubygem-inifile-puppet3-3.0.0-3.eos4.noarch.rpm \\'
puts ' rubygem-netaddr-puppet3-1.5.0-2.eos4.noarch.rpm'
puts ' rubygem-inifile-puppet3-3.0.0-5.eos4.noarch.rpm \\'
puts ' rubygem-netaddr-puppet3-1.5.1-4.eos4.noarch.rpm'
puts ' Puppet-All-in-one agent (2015.x/4.x): '
puts ' cd/mnt/flash; \\'
puts " swix create rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.swix \\"
puts " rubygem-rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \\"
puts ' rubygem-inifile-puppet-aio-3.0.0-3.eos4.noarch.rpm \\'
puts ' rubygem-netaddr-puppet-aio-1.5.0-2.eos4.noarch.rpm \\'
puts ' rubygem-net_http_unix-puppet-aio-0.2.1-3.eos4.noarch.rpm'
puts ' rubygem-inifile-puppet-aio-3.0.0-5.eos4.noarch.rpm \\'
puts ' rubygem-netaddr-puppet-aio-1.5.1-4.eos4.noarch.rpm \\'
puts ' rubygem-net_http_unix-puppet-aio-0.2.2-5.eos4.noarch.rpm'
end

desc 'Generate SWIX files from RPMs'
task swix: :all_rpms do
SWIX = 'PYTHONPATH=${PYTHONPATH}:/nfs/misc/tools/swix \
/nfs/misc/tools/swix/swix'
system "cd rpms/noarch;
system "(cd rpms/noarch;
rm -f rbeapi-#{Rbeapi::VERSION}-1.swix;
#{SWIX} create rbeapi-#{Rbeapi::VERSION}-1.swix \
rubygem-rbeapi-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \
rubygem-inifile-3.0.0-3.eos4.noarch.rpm \
rubygem-netaddr-1.5.0-2.eos4.noarch.rpm"
system "cd rpms/noarch;
rubygem-inifile-3.0.0-5.eos4.noarch.rpm \
rubygem-netaddr-1.5.1-4.eos4.noarch.rpm \
rubygem-net_http_unix-0.2.2-5.eos4.noarch.rpm)"
system "(cd rpms/noarch;
rm -f rbeapi-chef-#{Rbeapi::VERSION}-1.swix;
#{SWIX} create rbeapi-chef-#{Rbeapi::VERSION}-1.swix \
rubygem-rbeapi-chef-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \
rubygem-inifile-chef-3.0.0-5.eos4.noarch.rpm \
rubygem-netaddr-chef-1.5.1-4.eos4.noarch.rpm)"
system "(cd rpms/noarch;
rm -f rbeapi-puppet3-#{Rbeapi::VERSION}-1.swix;
#{SWIX} create rbeapi-puppet3-#{Rbeapi::VERSION}-1.swix \
rubygem-rbeapi-puppet3-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \
rubygem-inifile-puppet3-3.0.0-3.eos4.noarch.rpm \
rubygem-netaddr-puppet3-1.5.0-2.eos4.noarch.rpm"
system "cd rpms/noarch;
rubygem-inifile-puppet3-3.0.0-5.eos4.noarch.rpm \
rubygem-netaddr-puppet3-1.5.1-4.eos4.noarch.rpm)"
system "(cd rpms/noarch;
rm -f rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.swix;
#{SWIX} create rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.swix \
rubygem-rbeapi-puppet-aio-#{Rbeapi::VERSION}-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-inifile-puppet-aio-3.0.0-5.eos4.noarch.rpm \
rubygem-netaddr-puppet-aio-1.5.1-4.eos4.noarch.rpm \
rubygem-net_http_unix-puppet-aio-0.2.2-5.eos4.noarch.rpm)"
SWIXS = `find rpms/noarch -name "rbeapi*swix" -ls`
puts "\n################################################\n#"
puts "The following artifacts are in rpms/noarch/\n#{SWIXS}"
Expand Down Expand Up @@ -155,6 +170,12 @@ task ci_spec: [:ci_prep, 'ci:setup:rspec', :spec]

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:unit) do |t|
t.pattern = './**/unit/**/*_spec.rb'
end
RSpec::Core::RakeTask.new(:system) do |t|
t.pattern = './**/system/**/*_spec.rb'
end

desc 'Generate typedoc.rst for the guide'
task :typedoc do
Expand Down
35 changes: 31 additions & 4 deletions gems/inifile/inifile.spec.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Name: %{?enterprise:pe-}rubygem-%{gem_name}
Version: 3.0.0
Release: 3.eos4
Release: 5.eos4
Summary: INI file reader and writer

Group: Development/Languages
Expand Down Expand Up @@ -49,6 +49,15 @@ are also possible
var1 = baz
var2 = shoodle.

%package chef
Summary: Inifile rubygem packaged for Chef
Group: Development/Languages
Requires: chef
Provides: chef-rubygem(%{gem_name}) = %{version}
Provides: chef-rubygem-%{gem_name} = %{version}
%description chef
The inifile rubygem packaged for Chef client on Arista EOS.

%package puppet3
Summary: Inifile rubygem packaged for Puppet 3.x on Arista EOS
Group: Development/Languages
Expand Down Expand Up @@ -78,22 +87,34 @@ install %{SOURCE0} %{buildroot}/
%files
/%{gem_name}-%{version}.gem

%files chef
/%{gem_name}-%{version}.gem

%files puppet3
/%{gem_name}-%{version}.gem

%files puppet-aio
/%{gem_name}-%{version}.gem

%post
GEM_OPTS="--no-document --local"
GEM_OPTS="--no-rdoc --no-ri --local"
gem install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1

%preun
gem uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1

%post chef
GEM=/opt/chef/embedded/bin/gem
GEM_OPTS="--no-document --local"
${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1

%preun chef
GEM=/opt/chef/embedded/bin/gem
${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1

%post puppet3
GEM=/opt/puppet/bin/gem
GEM_OPTS="--no-document --local"
GEM_OPTS="--no-rdoc --no-ri --local"
${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1

%preun puppet3
Expand All @@ -102,14 +123,20 @@ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1

%post puppet-aio
GEM=/opt/puppetlabs/puppet/bin/gem
GEM_OPTS="--no-document --local"
GEM_OPTS="--no-rdoc --no-ri --local"
${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1

%preun puppet-aio
GEM=/opt/puppetlabs/puppet/bin/gem
${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1

%changelog
* Tue May 24 2016 Jere Julian - 3.0.0-5
- Add chef package

* Wed Apr 6 2016 Jere Julian - 3.0.0-4
- Disable install of gem docs

* Fri Oct 30 2015 Jere Julian - 3.0.0-3
- Detect the location of the puppet-agent's gem install

Expand Down
Loading

0 comments on commit 15e6443

Please sign in to comment.