Skip to main content

A Network Unit Test System

Project description

==================================
Nuts - Network Unit Testing System
==================================

.. image:: https://travis-ci.org/HSRNetwork/Nuts.svg?branch=master
:alt: Build status
:target: https://travis-ci.org/HSRNetwork/Nuts

.. image:: https://img.shields.io/pypi/v/nuts.svg
:alt: PyPi Version
:target: https://pypi.python.org/pypi/nuts

.. image:: https://img.shields.io/pypi/pyversions/nuts.svg
:alt: PyPi Python Versions
:target: https://pypi.python.org/pypi/nuts

.. image:: https://img.shields.io/pypi/wheel/nuts.svg
:alt: PyPi wheel
:target: https://pypi.python.org/pypi/nuts

.. image:: https://img.shields.io/pypi/l/nuts.svg
:alt: PyPi Licence
:target: https://pypi.python.org/pypi/nuts

Nuts is a network unit testing system that automates tests in the network similar to unit tests you might know from programming.
The project uses SaltStack and napalm to communicate with network devices. Regular Salt minions are used for Linux devices.
This project is currently under heavy construction and we can't guarantee you that this code works. But we do our best.
If you have any questions, feature request or use cases please reach out to us at https://github.com/HSRNetwork/Nuts or https://networktocode.slack.com/

**Documentation:** http://nuts.readthedocs.io/

**Vagrant Project:** https://github.com/HSRNetwork/vagrant-nuts

--------------------
Installation of nuts
--------------------

The following Python versions are supported:

- Python 2.7
- Python 3.6


Pre-requirements
----------------
- Salt master
Because nuts is fully based on saltstack you have to install and configure a salt master first.
For the full installation guide head over to the `installation guide <https://docs.saltstack.com/en/latest/topics/installation/>`_.
- Salt api
To use nuts you also need salt-api which enables nuts to connect to the salt master over Http. For the installation guide visit `cherrypy documentation <https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html>`_.
- Napalm salt
To create a connection from the salt master to your network device of choice there's a fantastic library called NAPALM which got an integration into saltstack. For the installation guide head to `napalm-salt repository <https://github.com/napalm-automation/napalm-salt/>`_.

Install with pip
----------------

The recommended way to install nuts is using `pip <http://pip.readthedocs.org/en/latest/>`_:

::

$ sudo pip install -U nuts

This will automatically install the latest version from the `Python Package
Index <https://pypi.python.org/pypi/nuts/>`__.

Manual Installation
-------------------

Get code::

$ git clone https://github.com/HSRNetwork/Nuts.git
$ cd Nuts

Install::

$ sudo python setup.py install

-------
Usage
-------

usage: nuts.py [-h] [-v] [-m ITERATIONS] [-r RETRIES] [-c CONFIG] testfile

positional arguments:
testfile Start with a Testfile

optional arguments:
-h, --help show this help message and exit
-v, --validate Validates Testfile
-m ITERATIONS, --iterations ITERATIONS Changes the number of iterations that nuts waits for a result
-r RETRIES, --retries RETRIES Set the max retries for failed tests
-c CONFIG, --config CONFIG Config file formatted as YAML. Settings will be merged with ENVVARs

---------
Testfiles
---------
The structure of the testfile has to be compliant with the testschema found in the folder nuts/src/service/testSchema.yaml.
An example could be:

.. code:: yaml

- name: example_arp
command: arp
devices: cisco.csr.1000v
parameter: [192.168.16.128]
operator: '='
expected: '00:0C:29:EA:D1:68'

Please note that the devices attribute gets directly passed to the salt master which determines the targeted minions with so called globbing. For more information what's globbing head to `saltstack globbing <https://docs.saltstack.com/en/latest/topics/targeting/globbing.html#globbing>`_.
If multiple minions are targeted each of them has to satisify the expected value for the test to pass.

The following commands are currently available with napalm-salt if this command is available on your device is also dependent on the availability of der underlying functions of napalm:
- connectivity - checks the connectivity to a certain IP address with a simple ping. Takes the target IP address as a parameter
- traceroute - checks the connectivity to a certain IP address with a traceroute. Takes the target IP address as a parameter
- interfacestatus - checks if a specific interface is available. Takes the interface name as a parameter
- interfacespeed - checks the speed of a specific interface. Takes the interface name as a parameter
- arp - checks the mac address of a specific IP address. Takes the IP address as a parameter
- checkversion - checks the version of the device. Takes no parameter
- checkuser - checks which users are available on the device. Takes no parameter

For more information about the availability visit `napalm docs <https://napalm.readthedocs.io/en/latest/support/index.html>`_.

The following commands are currently available for debian systems:
- connectivity
- traceroute
- dnscheck
- dhcpcheck
- webresponse
- portresponse

There are the following operators available:
- =
- <
- >
- not

--------
Examples
--------
There are a few more examples of test files available in the example folder.

-------------
Configuration
-------------
You can use a YAML formatted configuration file and/or set environment variables
Configuration options:
- NUTS_SALT_REST_API_URL
- NUTS_SALT_REST_API_USERNAME
- NUTS_SALT_REST_API_PASSWORD
- NUTS_SALT_REST_API_EAUTN
- NUTS_MAX_RETRIES
- NUTS_WAIT_ITERATIONS
- NUTS_LOG_FILE_LEVEL
- NUTS_LOG_CONSOLE_LEVEL
- NUTS_LOG_FOLDER


config.yml example:

.. code:: yaml

NUTS_SALT_REST_API_URL: 'http://salt-master.lab:8000'
NUTS_SALT_REST_API_USERNAME: 'myUser'
NUTS_SALT_REST_API_PASSWORD: 'myPassword'
NUTS_SALT_REST_API_EAUTH: 'pam'


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nuts-1.2.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nuts-1.2.1-py2.py3-none-any.whl (19.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file nuts-1.2.1.tar.gz.

File metadata

  • Download URL: nuts-1.2.1.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nuts-1.2.1.tar.gz
Algorithm Hash digest
SHA256 bf37c7beaada922a64d8beee3770dfe1f8a78e5a531d04580d372ed8ff205a5b
MD5 b7a1e86e8b29f2aec7548d55a1a87daf
BLAKE2b-256 8046e7cbc3b632a13021bc7965f52762fbb175221364c76a5bebae4e7d83a85e

See more details on using hashes here.

File details

Details for the file nuts-1.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for nuts-1.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3488dc073245f87954aaa9439d7cba3bfed438485f2ba643661dc9c9c3d2ecfc
MD5 5847b762f53ae4bbbf90ec0aeb762480
BLAKE2b-256 ff843d091f2141f1e0b4a41dff77aeff56a36dcda2b49619ef3aa5a14d439835

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page