项目作者: inexio

项目描述 :
Network Equipment Simulator (NESi)
高级语言: Python
项目地址: git://github.com/inexio/NESi.git
创建时间: 2020-08-27T08:26:24Z
项目社区:https://github.com/inexio/NESi

开源协议:BSD 2-Clause "Simplified" License

下载


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:
```shell script
$ git clone git@github.com:inexio/NESi.git

  1. 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:
  2. ```shell script
  3. $ 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:

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

After finishing the installation you can use these commands:

  1. nesi-api --recreate-db --load-model <vendor>
  2. nesi-cli --box-uuid <uuid>
  3. 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:

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

After finishing the installation you can use these commands:

  1. nesi-api --recreate-db --load-model <vendor>
  2. nesi-cli --box-uuid <uuid>
  3. nesi-cli --standalone <vendor> --box-uuid <uuid>

Systemd Setup

Add a nesi user to your system

```shell script
$ sudo adduser nesi

  1. Add a folder for nesi to /opt
  2. ```shell script
  3. $ cd /opt
  4. $ mkdir nesi

Add a ‘var’ and ‘etc’ folder

```shell script
$ cd nesi/
$ mkdir var/ etc/

  1. Add a new venv via python
  2. ```shell script
  3. $ python3 -m venv venv

Clone NESi into the venv and install requirements

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

  1. Change access rights
  2. ```shell script
  3. $ chown nesi:nesi -R /opt/nesi/

Copy the service template to /etc/systemd/system

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

  1. Copy nesi.conf to /opt/nesi/etc and make according changes
  2. ```shell script
  3. $ cp NESi/bootup/conf/nesi.conf /opt/nesi/etc/

Start systemd process
```shell script
$ systemctl daemon-reload
$ systemctl start nesi-gunicorn.service

  1. ## How to use NESi
  2. The easiest way to play with the example CLI is to run two terminals on the NESi
  3. repo - one that starts up the REST API server and populates the example model in
  4. the underlying DB, and another that simulates the devices Command Line Interface and runs against the REST API server.
  5. REST API terminal:
  6. $ python3 api.py [--recreate-db] [--load-model <VENDOR>]
  7. CLI terminal:
  8. First we collect the uuid´s of all boxes
  9. % python3 cli.py --list-boxen
  10. Vendor Alcatel, model 7360, version FX-4, uuid d8da2c00-ed28-11ea-9cc7-8c8590d3240c
  11. Second we connect to one box with the specific uuid
  12. % python3 cli.py --box-uuid d8da2c00-ed28-11ea-9cc7-8c8590d3240c
  13. _ _ ______ _____ _
  14. | \ | | ____|/ ____(_)
  15. | \| | |__ | (___ _
  16. | . ` | __| \___ \| |
  17. | |\ | |____ ____) | |
  18. |_| \_|______|_____/|_|
  19. Hint: login credentials: admin/secret (Huawei: root/secret)
  20. login:admin
  21. Password:secret
  22. Last login on 01.03.2020
  23. Interactive menus will guide you through the implemented commands.
  24. ### SSH and Telnet Daemon
  25. NESi comes with SSH and Telnet socket Daemons built into the boxes itself.
  26. 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.
  27. ```shell script
  28. req='{
  29. ...
  30. "network_protocol": "ssh",
  31. "network_address": "127.0.0.1",
  32. ...
  33. }'

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.

shell script $ ./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.

  1. Host name : localhost
  2. Port : 3001

After that we first start our debuger and add the argument ‘—debug’ in our CLI terminal:

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

How to start tests

Tests can be started with the following command structure:

  1. 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

  1. % docker build . -t nesi

After building you can start the container via

  1. % 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.