Skip to content

Commit

Permalink
Merge pull request #390 from arista-eosplus/release-2.0.0
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
dlobato authored Aug 7, 2023
2 parents cfd8d30 + 07472a6 commit 8058dcc
Show file tree
Hide file tree
Showing 87 changed files with 6,034 additions and 5,798 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
pip install -r requirements-node.txt
- name: Analysing the code with pylint
run: |
make pylint
27 changes: 27 additions & 0 deletions .github/workflows/unittest-node-py2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Unittest Node py2

on: [push]

jobs:
build:
runs-on: ubuntu-latest
container:
image: python:2.7.18-buster
volumes:
- /dev/log:/dev/log
env:
USER: root
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-node-py2.txt
pip install -r requirements-dev.txt
- name: Run client tests
run: |
make test_client
- name: Run action tests
run: |
make test_actions
28 changes: 28 additions & 0 deletions .github/workflows/unittest-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Unittest Node

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-node.txt
pip install -r requirements-dev.txt
- name: Run client tests
run: |
make test_client
- name: Run action tests
run: |
make test_actions
24 changes: 24 additions & 0 deletions .github/workflows/unittest-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Unittest server

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run server tests
run: |
make test_server
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ rpm/rpms

# virtualenv
venv

# IDE
.idea
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: ["-l", "100"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
36 changes: 8 additions & 28 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
[FORMAT]

[MASTER]
init-hook="from pylint.config import find_pylintrc;import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))"
[BASIC]
method-rgx=[a-z_][a-z0-9_]{2,50}$

[MESSAGES CONTROL]
# Used when an except catches Exception instances.
disable=W0703

# Too many branches
disable=R0912

# Too many return statements
disable=R0911

# No exception type specified
disable=W0702

# Disable statistics by type
disable=RP0101

# Allow local disables
# Missing docstring
# Abstract class not referenced
# Similar lines in 2 files
disable=I0011,C0111,R0921,R0801
disable=
W0703, # broad-exception-caught
R0912, # Too many branches
C0111, # Missing docstring
R0801 # Similar lines in 2 files

[REPORTS]
# Include message's id in output
include-ids=yes

# Tells wether to display a full report or only the messages
reports=no

[FORMAT]
max-module-lines=2000
good-names=fd

[DESIGN]
# Maximum number of locals for function / method body
Expand All @@ -42,10 +27,6 @@ max-locals=20
# Maximum number of return / yield for function / method body
max-returns=20

# Maximum number of branch for function / method body
# pylint bug
max-branchs=30

# Maximum number of statements in function / method body
max-statements=100

Expand All @@ -60,4 +41,3 @@ max-public-methods=600

# Maximum number of attributes for a class (see R0902).
max-attributes=20

11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# docker run -P ztpserver
# docker run -i -t --rm -p 80:80 nginx
#
FROM python:2
FROM python:3

LABEL version="0.1"
LABEL version="0.2"
LABEL maintainer="[email protected]"

WORKDIR /src/ztpserver
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ Dependencies

Server
======
* [Python 2.7](https://www.python.org/download/releases/2.7/)
* [routes 2.0 or later](https://pypi.python.org/pypi/Routes)
* [webob 1.3 or later](http://webob.org/)
* [PyYaml 3.0 or later](http://pyyaml.org/)
* Python 3.7 or later (https://www.python.org/downloads)
* routes 2.5 or later (https://pypi.python.org/pypi/Routes)
* webob 1.8 or later (http://webob.org/)
* PyYaml 6.0 or later (http://pyyaml.org/)

Client
======
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.0
2.0.0
52 changes: 26 additions & 26 deletions actions/add_config
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pylint: disable=W0703,W0402,E1103
# pylint: disable=C0209

import io
import os

TEMP_CONFIG = '/tmp/tmp-add-config'
from six import raise_from

TEMP_CONFIG = "/tmp/tmp-add-config"


def main(attributes):
''' Appends config section to startup-config.
"""Appends config section to startup-config.
This action is dual-supervisor compatible.
Attributes:
url: path to source config/template
substitution_mode: loose|strict (default: loose)
variables: list of value substitutions
Special_attributes:
Special_attributes:
NODE: API object - see documentation for details
Example:
Expand All @@ -60,41 +64,37 @@ def main(attributes):
onsuccess: "SUCCESS: ma1 configure"
onfailure: "FAIL: IM [email protected] for help"
'''
"""

node = attributes.get('NODE')
url = attributes.get('url')
node = attributes.get("NODE")
url = attributes.get("url")

if not url:
raise Exception('Missing attribute(\'url\')')
raise RuntimeError("Missing attribute('url')")


substitution_mode = attributes.get('substitution_mode', 'loose')
if substitution_mode not in ['loose', 'strict']:
raise Exception('Invalid option specified for substitution_mode '
'attribute')
substitution_mode = attributes.get("substitution_mode", "loose")
if substitution_mode not in ["loose", "strict"]:
raise RuntimeError("Invalid option specified for substitution_mode attribute")

try:
node.retrieve_url(url, TEMP_CONFIG)
except Exception as exc:
raise Exception('Unable to retrieve config from URL (%s)' %
exc)
raise_from(RuntimeError("Unable to retrieve config from URL"), exc)

contents = open(TEMP_CONFIG, 'r').read()
with io.open(TEMP_CONFIG, encoding="utf8") as fd:
contents = fd.read()

variables = attributes.get('variables')
variables = attributes.get("variables")
if not variables:
variables = {}

if not isinstance(variables, dict):
node.log_msg('Variables: %s' % variables)
raise Exception('Unable to perform variable substitution - '
'invalid variables')

contents = node.substitute(contents, variables,
substitution_mode == 'strict')
node.append_startup_config_lines(contents.split('\n'))

node.log_msg("Variables: {}".format(variables))
raise RuntimeError("Unable to perform variable substitution - invalid variables")

contents = node.substitute(contents, variables, substitution_mode == "strict")
node.append_startup_config_lines(contents.split("\n"))

# Only remove this in case everything else succeeded
# for debugging purposes
os.remove(TEMP_CONFIG)
Loading

0 comments on commit 8058dcc

Please sign in to comment.