Arista eAPI Ruby Library

This ruby gem library implements configuration tasks using the Arista EOS eAPI. The goal if this library is to provide a reusable set of classes and methods for use with Puppet types and providers.

Installation for Development

First, clone the repository to your local development system:

$ cd /workspace
$ git clone [email protected]:puppetlabs/puppet_x_eos_eapi.git

Then add these lines to your module's Gemfile in order to use your development copy of the Gem library:

puppet_x_eos_eapi_version = ENV['GEM_PUPPET_X_EOS_EAPI_VERSION']
if puppet_x_eos_eapi_version
  gem 'puppet_x_eos_eapi', *location_for(puppet_x_eos_eapi_version)
else
  gem 'puppet_x_eos_eapi'
end

And then execute:

$ export GEM_PUPPET_X_EOS_EAPI_VERSION=file:///workspace/puppet_x_eos_eapi
$ bundle install --path .bundle/gems/

Usage

Provider's extend themselves by including the API methods into the provider class. For example,

# encoding: utf-8

require 'puppet/type'
require 'puppet_x_eos_eapi'
Puppet::Type.type(:network_snmp).provide(:eos) do

  # Create methods that set the @property_hash for the #flush method
  mk_resource_methods

  # Mix in the api as instance methods
  include PuppetX::Eos::ProviderMethods
  # Mix in the api as class methods
  extend PuppetX::Eos::ProviderMethods
  # Mix in common provider class methods (e.g. self.prefetch)
  extend PuppetX::Eos::ProviderClassMethods

  def initialize(resource = {})
    super(resource)
    @property_flush = {}
  end
end

Behavior tests

When making changes to this Gem, please check the spec tests, code coverage, documentation coverage, and rubocop warnings:

Behavior Tests:

bundle exec rspec spec

Code Coverage is automatically generated after the spec tests are run:

open coverage/index.html

Documentation:

bundle exec yard

Rubocop warnings:

bundle exec rubocop

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request