Skip to content

inexio/NESi

Repository files navigation

Network Equipment Simulator (NESi)

(former Softboxen)

GitHub license GitHub build

The NESi project which originated from softboxen, a project originally created by our co-developer Ilya Etingof, aims to support different network devices of various vendors like Alcatel or Huawei.

The goal of the project is to simulate the presence of a large number of network devices (such as switches, routers, modems etc) on the network. These simulated devices expose their management interfaces and support command-line dialogues in a reasonably convincing way. The main use-case for the software is to create a testing environment for network management and automation.

For more information on softboxen or NESi please refer to our local documentation.

NESi at FOSDEM 2021 - Request for Papers

The NESi team will organize a devroom for Network monitoring, discovery and inventory. Click here for more information

Features

GitHub build GitHub build GitHub build GitHub build GitHub build GitHub build

Supported Vendors

  • Alcatel
  • Huawei
  • Edgecore
  • Keymile
  • Zhone

Upcoming Vendors

  • Pbn
  • Juniper
  • Cisco

Supported network components

  • Subracks
  • Cards
  • Ports
  • ONTs
  • CPEs
  • Vlans
  • Interfaces

Download

The NESi package is distributed under terms and conditions of 2-clause BSD license.

Furthermore the previous softboxen project is freely available as a GitHub repository or can be downloaded from PyPI.

Installation

Basic Setup

Either clone the repository with the following command:

$ git clone git@github.com:inexio/NESi.git

After that, make sure you have installed the required python packages found in the requirements.txt. An easy way to do this is with the following command:

$ pip install -r requirements.txt

pip Setup

If you want to install our project as binaries into a venv using pip you can follow theses steps:

python3 -m venv venv
cd venv
source bin/activate
pip install https://github.com/inexio/NESi/archive/master.zip

After finishing the installation you can use these commands:

nesi-api --recreate-db --load-model <vendor>
nesi-cli --box-uuid <uuid>
nesi-cli --standalone <vendor> --box-uuid <uuid>

Debian-package Setup

If you want to install our project using debian-package you can follow theses steps:

pip install -r requirements.txt
apt-get update
apt install NESi/deb_dist/$(ls "NESi/deb_dist" | grep ".deb$")

After finishing the installation you can use these commands:

nesi-api --recreate-db --load-model <vendor>
nesi-cli --box-uuid <uuid>
nesi-cli --standalone <vendor> --box-uuid <uuid>

Systemd Setup

Add a nesi user to your system

$ sudo adduser nesi

Add a folder for nesi to /opt

$ cd /opt
$ mkdir nesi

Add a 'var' and 'etc' folder

$ cd nesi/
$ mkdir var/ etc/

Add a new venv via python

$ python3 -m venv venv

Clone NESi into the venv and install requirements

$ cd venv
$ git clone https://github.com/inexio/NESi.git
$ source bin/activate
$ python3 -m pip install -r NESi/requirements.txt
$ deactivate

Change access rights

$ chown nesi:nesi -R /opt/nesi/

Copy the service template to /etc/systemd/system

$ cp NESi/bootup/conf/systemd/nesi-gunicorn.service /etc/systemd/system

Copy nesi.conf to /opt/nesi/etc and make according changes

$ cp NESi/bootup/conf/nesi.conf /opt/nesi/etc/

Start systemd process

$ systemctl daemon-reload
$ systemctl start nesi-gunicorn.service

How to use NESi

The easiest way to play with the example CLI is to run two terminals on the NESi repo - one that starts up the REST API server and populates the example model in the underlying DB, and another that simulates the devices Command Line Interface and runs against the REST API server.

REST API terminal:

$ python3 api.py [--recreate-db] [--load-model <VENDOR>]

CLI terminal:

First we collect the uuid´s of all boxes

% python3 cli.py --list-boxen

Vendor Alcatel, model 7360, version FX-4, uuid d8da2c00-ed28-11ea-9cc7-8c8590d3240c

Second we connect to one box with the specific uuid

% python3 cli.py --box-uuid d8da2c00-ed28-11ea-9cc7-8c8590d3240c

      _   _ ______  _____ _ 
     | \ | |  ____|/ ____(_)
     |  \| | |__  | (___  _ 
     | . ` |  __|  \___ \| |
     | |\  | |____ ____) | |
     |_| \_|______|_____/|_|


Hint: login credentials: admin/secret (Huawei: root/secret)

login:admin
Password:secret
Last login on 01.03.2020

Interactive menus will guide you through the implemented commands.

SSH and Telnet Daemon

NESi comes with SSH and Telnet socket Daemons built into the boxes itself.

To use either telnet or ssh you have to specify one of them in the setup-script of a box or set it via the rest-api.

req='{
  ...
  "network_protocol": "ssh",
  "network_address": "127.0.0.1",
  ...
}'

After setting the network_protocol of a device you can launch the 'box.sh' script with the --daemon flag to start the device in either telnet or ssh socket mode.

$ ./bootup/box.sh --box-uuid <devices uuid> --daemon

The network_adress field is used as the host adress for the socket, so set this option accordingly.

After the socket has started you can connect to your device with the chosen protocol.

How to use debug mode

First we configure a debugger in our IDE. Therefore we add a Python Debug Server with pydevd_pycharm.

Host name   : localhost
Port        : 3001

After that we first start our debuger and add the argument '--debug' in our CLI terminal:

% python3 cli.py --box-uuid <box-uuid> --debug

How to start tests

Tests can be started with the following command structure:

python3 cli.py --test Alcatel 

For other vendors replace 'Alcatel' with your desired vendor.

For more information see test_structure.rst

Available Flags

api.py

--recreate-db

Recreate the underlying SQLite Database (Important for first run)

--debug

Launches the API in debug mode

--load-model <vendor>

load the data of vendor into the underlying Database

--help

Displays help for available flags

cli.py

--list_boxen

Lists all available devices that were created in the database

--box-uuid <uuid>

Launches the device with the given uuid

--daemon

Launches the device in daemon mode

--standalone <vendor>

Launches the device without having to launch the API in a seperate window first

--debug

Launches the device in debug mode

--help

Displays help for available flags

Docker

For people using Docker we included a dockerfile.

You can build nesi using docker with the command

% docker build . -t nesi

After building you can start the container via

% docker run -(d)it nesi

How to add new simulated CLI

For more information on this matter, please refer to the developer's documentation.

Issues

If you find any bug or a feature you think should be implemented, you can open up an issue. We will take care of the problem as fast as we can!

Contributing

Contributions to the project are welcome.

We are looking forward to your pull requests, suggestions and fixes.

Happy Coding!


Copyright (c) 2020

Original Software Design by Ilya Etingof.

Software adapted by inexio.


All rights reserved.