Skip to content

NetDriver is a project designed for connecting network devices and executing CLI commands. Developers can make calls through the HTTP RESTful interface, which simplifies the development of network device automation and enhances security.

License

Notifications You must be signed in to change notification settings

OpenSecFlow/netdriver

Repository files navigation

NetDriver

Python Poetry License Build & Test Contributions Welcome Last Commit Release Release Date

⭐ Star us on GitHub β€” your support motivates us a lot! πŸ™πŸ˜Š

Share Share Share Share Share

Table of Contents

About

Everyone loves netmiko cause it's the best at what it can do, so instead of reinventing the wheel we decided to add couple of sticks in to it by implementing some Quality-of-life features. NetDriver is a network device automation framework that enables CLI command execution through HTTP RESTful APIs. With features like session persistence for efficiency a command queue to avoid configuration conflicts and an HTTP RESTful API for simple third-party integration. With its plugin architecture which combines automation scalability and contemporary network management in a single framework it offers high concurrency and is built on top of AsyncSSH for your convinience.

NetDriver adopts a Monorepo architecture consisting of multiple sub-projects:

  • netdriver-agent - Provides REST APIs for device connectivity testing and command execution
  • netdriver-simunet - Simulates network device terminals for automated testing and other scenarios requiring device emulation

Features:

  • 🌐 HTTP RESTful API : Easy integration with third-party platforms
  • πŸ”„ Session Management : Customizable session persistence for improved efficiency, eliminating repeated connections per command
  • πŸ“‹ Command Queue : Ensures sequential command execution on devices, preventing configuration errors and failures caused by concurrent modifications
  • ⚑ AsyncSSH Foundation : Superior concurrency capabilities through asynchronous SSH implementation
  • πŸ”Œ Plugin Architecture : Simplified and accelerated development of new vendor support

Comparison

Feature NetDriver Netmiko
HTTP RESTful API for third-party integration βœ… ❌
Session persistence with customizable duration βœ… ❌
Python-based implementation βœ… βœ…
Command execution queue to prevent concurrent conflicts βœ… ❌
Plugin architecture for easier device support development βœ… ❌
Standard CLI automation βœ… βœ…
Open source βœ… βœ…
AsyncSSH-based architecture for high concurrency βœ… ❌

Project Structure

netdriver/
β”œβ”€β”€ bases/ 
β”‚   └── netdriver/
β”‚       β”œβ”€β”€ agent/          # netdirver-agent app
β”‚       └── simunet/        # netdriver-simunet app 
β”œβ”€β”€ components/
β”‚   └── netdriver/
β”‚       β”œβ”€β”€ client/         # SSH client with session management 
β”‚       β”œβ”€β”€ exception/      # Exception handling and error codes
β”‚       β”œβ”€β”€ log/           # Logging utilities
β”‚       β”œβ”€β”€ plugin/        # Plugin system core
β”‚       β”œβ”€β”€ plugins/       # Device-specific plugins
β”‚       β”œβ”€β”€ server/        # SSH server of simulated devices
β”‚       β”œβ”€β”€ textfsm/       # Enhanced Textfsm
β”‚       └── utils/         # Utility functions
β”œβ”€β”€ config/                # Configuration files
β”œβ”€β”€ tests/                 # Test suites
└── pyproject.toml        # Project metadata and dependencies

Build

Fallow this steps to build our package:

Prerequisites

  • Python 3.12 or higher
  • Poetry for dependency management

Development Environment Setup

Python Installation

Recommended using pyenv to manage and install Python.

Install Python build dependencies

sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl git \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Install pyenv

curl -fsSL https://pyenv.run | bash

Configure ~/.bashrc file by appending the following text to the end

# Load pyenv automatically by appending
# the following to
# ~/.bash_profile if it exists, otherwise ~/.bashrc (for login shells)
# and ~/.bashrc (for interactive shells) :

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init - bash)"

Apply the changes to your current shell session

source ~/.bashrc

Verify pyenv installation

$ pyenv --version
pyenv 2.6.8

Reference: https://github.com/pyenv/pyenv/wiki#suggested-build-environment

Install Python (recommended version: 3.12.7)

# List available versions
pyenv install --list
# Install Python 3.12.7
pyenv install 3.12.7
# Set as global version
pyenv global 3.12.7
# Verify installation
python --version
Python 3.12.7

Poetry Installation

Poetry is the default build and dependency management tool for this project

# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -

# Configure ~/.bashrc
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Verify installation
poetry --version
Poetry (version 1.8.3)

# Install Poetry plugins
poetry self add poetry-multiproject-plugin
poetry self add poetry-polylith-plugin

References:

Install Development Dependencies

poetry install

Usage

Start the Agent Service

poetry run agent

Once the Agent service is started, you can access the FastAPI OpenAPI interface through a web browser to test API calls.

http://localhost:8000/docs

alt text

Start the Simulation Network Service

poetry run simunet

Once the Simunet service is started, you can access the simulated devices through SSH clients or the Agent.

alt text

alt text

Configuration

Configuration files are located in the config/ directory:

  • config/agent/agent.yml - Agent service configuration
  • config/simunet/simunet.yml - Simulation network configuration

Testing

Run all tests:

poetry run pytest

Run unit tests only:

poetry run pytest -m unit

Run integration tests only:

poetry run pytest -m integration

🀝 Contributions and Requests

Your contributions matter!Our project can always be better so we would be happy to recive your help!Please take a look at contributing guide before submiting a pull request! For questions, issues, or feature requests, please open an issue on the project repository.

Development Guidelines

  1. Follow PEP 8 style guidelines
  2. Add tests for new features
  3. Update documentation as needed
  4. Ensure all tests pass before submitting PR

Support

πŸ“ƒ License

This project is licensed under the Apache License 2.0.

Authors

πŸ—¨οΈ Contacts

We look forward to assisting you and ensuring your experience with our products is successful and enjoyable!

Back to top

About

NetDriver is a project designed for connecting network devices and executing CLI commands. Developers can make calls through the HTTP RESTful interface, which simplifies the development of network device automation and enhances security.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 5

Languages