Skip to content

Commit

Permalink
Merge pull request #82 from arista-eosplus/release-0.5.0
Browse files Browse the repository at this point in the history
Release 0.5.0
  • Loading branch information
phil-dileo committed Feb 17, 2016
2 parents 185a057 + a7e0af0 commit f8b70cd
Show file tree
Hide file tree
Showing 67 changed files with 2,093 additions and 806 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ language: python
python:
- '2.7'
- '3.4'

install: pip install -r dev-requirements.txt

script: make unittest
script:
- make clean
- make pep8
- make flake8
- make check
- make unittest

notifications:
email:
Expand Down
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ recursive-include test *.portchannel
recursive-include test *.py
recursive-include test *.text
recursive-include test *.vxlan
recursive-include test *.bgp
recursive-include test *.routemaps
recursive-include test *.varp
recursive-include test *.varp_null
recursive-include test *.vrrp
recursive-include test *.yaml
recursive-include docs description.rst
recursive-include docs *.py
recursive-include docs *.rst
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ VERSION := $(shell cat VERSION)

########################################################

all: clean check pep8 pyflakes tests
all: clean check pep8 flake8 tests

pep8:
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 pyeapi/ test/
-pep8 -r --ignore=E402,E731,E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 pyeapi/ test/

pyflakes:
pyflakes pyeapi/ test/

flake8:
flake8 --ignore=E302,E303,W391 --exit-zero pyeapi/
flake8 --ignore=E302,E303,W391,N802 --max-line-length=100 test/
flake8 --ignore=E302,E303,E402,E731,W391 --exit-zero pyeapi/
flake8 --ignore=E302,E303,E402,E731,W391,N802 --max-line-length=100 test/

check:
check-manifest
Expand All @@ -50,6 +50,10 @@ clean:
rm -rf *.egg-info
@echo "Cleaning up byte compiled python stuff"
find . -type f -regex ".*\.py[co]$$" -delete
@echo "Cleaning up doc builds"
rm -rf docs/_build
rm -rf docs/api_modules
rm -rf docs/client_modules

sdist: clean
$(PYTHON) setup.py sdist
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.5.0
9 changes: 6 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import sys
import os
import re
import sphinx_rtd_theme

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -58,9 +59,11 @@
# built documents.
#
# The short X.Y version.
version = '1.0.0'
# The full version, including alpha/beta/rc tags.
release = '0.2.1'
release = open('../VERSION').read().split()[0].strip()
# Assume PEP 440 version strings
p = re.compile(r'(\d+!)?((\d+)(.\d+)*(.\d+)*)(.?[a|b|rc]\d*)?(.post\d*)?(.dev\d*)?', re.IGNORECASE)
vers = p.search(release)
version = vers.group(2)

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
22 changes: 12 additions & 10 deletions docs/configfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@ The following configuration options are available for defining node entries:

:transport: Configures the type of transport connection to use. Valid
values are:
- socket (default, available in EOS 4.14.5 or later)
- http_local (available in EOS 4.14.5 or later)
- http
- https

- socket (default, 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: http_local, default port: 8080
- transport: socket, default port: n/a
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: http_local, default port: 8080
- transport: socket, default port: n/a

*********************************
When is an eapi.conf file needed?
Expand Down
1 change: 1 addition & 0 deletions docs/generate_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def get_module_names(p):
mods = list()
mods = [f.split('.')[0] for f in listdir(p)
if isfile(join(p, f)) and not f.endswith('.pyc') and not f.startswith('__')]
print len(mods)
return mods

def process_modules(modules):
Expand Down
20 changes: 14 additions & 6 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ code in the develop branch.

**Step 1:** Clone the pyeapi Github repo

.. code-block:: console
.. code-block:: shell
# Go to a directory where you'd like to keep the source
admin:~ admin$ cd ~/projects
Expand All @@ -99,7 +99,7 @@ code in the develop branch.
**Step 2:** Check out the desired version or branch

.. code-block:: console
.. code-block:: shell
# Go to a directory where you'd like to keep the source
admin:~ admin$ cd ~/projects/pyeapi
Expand All @@ -113,21 +113,29 @@ code in the develop branch.
**Step 3:** Install pyeapi using Pip with -e switch

.. code-block:: console
.. code-block:: shell
# Go to a directory where you'd like to keep the source
admin:~ admin$ cd ~/projects/pyeapi
# Install
admin:~ admin$ sudo pip install -e ~/projects/pyeapi
**Step 4:** Install pyeapi requirements

.. code-block:: shell
# Go to a directory where you'd like to keep the source
admin:~ admin$ pip install -r dev-requirements.txt
.. Tip:: If you start using pyeapi and get import errors, make sure your
PYTHONPATH is set to include the path to pyeapi.

Development - Upgrade Pyeapi
============================

.. code-block:: console
Development - Upgrade Pyeapi
============================

.. code-block:: shell
admin:~ admin$ cd ~/projects/pyeapi
admin:~ admin$ git pull
Expand Down
1 change: 1 addition & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Enable EOS Command API
Refer to your official Arista EOS Configuration Guide to learn how to enable
EOS Command API. Depending upon your software version, the options available
include:

- HTTP
- HTTPS
- HTTP Local
Expand Down
45 changes: 45 additions & 0 deletions docs/release-notes-0.5.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
######
v0.5.0
######

2016-02-16

New APIs
^^^^^^^^

* NTP module (`72 <https://github.com/arista-eosplus/pyeapi/pull/72>`_) [`grybak-arista <https://github.com/grybak-arista>`_]
Add NTP functionality.

Enhancements
^^^^^^^^^^^^

* Add banner support to System API (`75 <https://github.com/arista-eosplus/pyeapi/pull/75>`_) [`dathelen <https://github.com/dathelen>`_]
Add API support for EOS banners and motd.
* Issue #18 performance fixes (`74 <https://github.com/arista-eosplus/pyeapi/pull/74>`_) [`cheynearista <https://github.com/cheynearista>`_]
Rework underlying HTTP transport to improve receive performance.
* Redmine issue 648 (`73 <https://github.com/arista-eosplus/pyeapi/pull/73>`_) [`grybak-arista <https://github.com/grybak-arista>`_]
Fix some instances where an empty string as negation would not properly negate the option/command.
* setup.py print statement for python 3 (`71 <https://github.com/arista-eosplus/pyeapi/pull/71>`_) [`mzbenami <https://github.com/mzbenami>`_]
Reformat print statement to work properly with Python3+
* Implement add ACL with seq nos (`70 <https://github.com/arista-eosplus/pyeapi/pull/70>`_) [`dathelen <https://github.com/dathelen>`_]
Add a sequence number when adding a new ACL entry.
* Fix for redmine issues 234 and 268 (`68 <https://github.com/arista-eosplus/pyeapi/pull/68>`_) [`grybak-arista <https://github.com/grybak-arista>`_]
Reworked some system tests for robustness
get_block accepts a config string as well as the default 'running_config'
* fix #7 and fix #37 (`67 <https://github.com/arista-eosplus/pyeapi/pull/67>`_) [`grybak-arista <https://github.com/grybak-arista>`_]
Certain command errors will return more detailed information.
The connect() method can optionally return a node object.
* Add disable key to existing modules for negation of properties (`65 <https://github.com/arista-eosplus/pyeapi/pull/65>`_) [`grybak-arista <https://github.com/grybak-arista>`_]
Modules now take disable=<True/False> to negate the command, rather than overloading value.
* Compatibility fix for current mock versions (`64 <https://github.com/arista-eosplus/pyeapi/pull/64>`_) [`wtucker <https://github.com/wtucker>`_]
* Add key error checking to set_tracks (`63 <https://github.com/arista-eosplus/pyeapi/pull/63>`_) [`grybak-arista <https://github.com/grybak-arista>`_]
.. comment
Fixed
^^^^^

* Failure when eapi.conf is not formatted correctly (`38 <https://github.com/arista-eosplus/pyeapi/issues/38>`_)
Adds more robust error handling when parsing eapi.conf files. Also, if an error is found it will syslog the error and continue parsing any other eapi.conf files.

Known Caveats
^^^^^^^^^^^^^
1 change: 1 addition & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Release Notes
release-notes-0.3.2.rst
release-notes-0.3.3.rst
release-notes-0.4.0.rst
release-notes-0.5.0.rst
2 changes: 1 addition & 1 deletion pyeapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
__version__ = '0.4.0'
__version__ = '0.5.0'
__author__ = 'Arista EOS+'


Expand Down
32 changes: 23 additions & 9 deletions pyeapi/api/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ def config(self):
def error(self):
return self.node.connection.error

def get_block(self, parent):
def get_block(self, parent, config='running_config'):
""" Scans the config and returns a block of code
Args:
parent (str): The parent string to search the config for and
return the block
config (str): A text config string to be searched. Default
is to search the running-config of the Node.
Returns:
A string object that represents the block from the config. If
Expand All @@ -90,7 +92,7 @@ def get_block(self, parent):
"""
try:
parent = r'^%s$' % parent
return self.node.section(parent)
return self.node.section(parent, config=config)
except TypeError:
return None

Expand Down Expand Up @@ -120,28 +122,42 @@ def configure(self, commands):
except (CommandError, ConnectionError):
return False

def command_builder(self, string, value=None, default=None):
def command_builder(self, string, value=None, default=None, disable=None):
"""Builds a command with keywords
Notes:
Negating a command string by overriding 'value' with None or an
assigned value that evalutates to false has been deprecated.
Please use 'disable' to negate a command.
Parameters are evaluated in the order 'default', 'disable', 'value'
Args:
string (str): The command string
value: The configuration setting to subsititue into the command
string. If value is a boolean and True, just the command
string is used
value (str): The configuration setting to subsititue into the
command string. If value is a boolean and True, just the
command string is used
default (bool): Specifies the command should use the default
keyword argument
keyword argument. Default preempts disable and value.
disable (bool): Specifies the command should use the no
keyword argument. Disable preempts value.
Returns:
A command string that can be used to configure the node
"""
if default:
return 'default %s' % string
elif disable:
return 'no %s' % string
elif value is True:
return string
elif value:
return '%s %s' % (string, value)
else:
return 'no %s' % string
# -- above line to be deprecated and replaced with the error below
# raise ValueError("abstract.command_builder: No value "
# "received '%s'" % value)

def configure_interface(self, name, commands):
"""Configures the specified interface with the commands
Expand Down Expand Up @@ -202,5 +218,3 @@ def getall(self):

def get(self, name, default=None):
raise NotImplementedError


9 changes: 7 additions & 2 deletions pyeapi/api/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

from pyeapi.api import EntityCollection


def mask_to_prefixlen(mask):
"""Converts a subnet mask from dotted decimal to bit length
Expand All @@ -60,6 +61,7 @@ def mask_to_prefixlen(mask):
mask = mask or '255.255.255.255'
return netaddr.IPAddress(mask).netmask_bits()


def prefixlen_to_mask(prefixlen):
"""Converts a prefix length to a dotted decimal subnet mask
Expand All @@ -73,6 +75,7 @@ def prefixlen_to_mask(prefixlen):
addr = '0.0.0.0/%s' % prefixlen
return str(netaddr.IPNetwork(addr).netmask)


class StandardAcls(EntityCollection):

entry_re = re.compile(r'(\d+)'
Expand Down Expand Up @@ -133,9 +136,11 @@ def update_entry(self, name, seqno, action, addr, prefixlen, log=False):
cmds.append('exit')
return self.configure(cmds)

def add_entry(self, name, action, addr, prefixlen, log=False):
def add_entry(self, name, action, addr, prefixlen, log=False, seqno=None):
cmds = ['ip access-list standard %s' % name]
entry = '%s %s/%s' % (action, addr, prefixlen)
if seqno is not None:
entry = '%s %s' % (seqno, entry)
if log:
entry += ' log'
cmds.append(entry)
Expand All @@ -146,6 +151,6 @@ def remove_entry(self, name, seqno):
cmds = ['ip access-list standard %s' % name, 'no %s' % seqno, 'exit']
return self.configure(cmds)


def instance(node):
return StandardAcls(node)

Loading

0 comments on commit f8b70cd

Please sign in to comment.