Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

A Python Module that allows you to Flexibly Automate your network devices

Notifications You must be signed in to change notification settings

eslam-gomaa/Flexible_Nework_Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 

Repository files navigation

Flexible_Nework-Automation

.

.

This has been replaced with Flexible Network Project

.

.


A Python Class that provides handy Methods to help make Network Automation with Python easier and more productive.

Features :octocat: :

As you may know network devices do NOT have the concept of stderr & exit_code, when you run a command on a network device you will only get the stdout

💎 The shell method can be used to run commands on Network Devices via SSH, Normally it can get stdout but it's also able to get the stderr by searching in the stdout and hence it can provide an exit_code of 0 or 1 - (Sample command output)

💎 All th work is done on a host is done in ONLY 1 SSH session, It starts the session in the initialization and YOU close it at the end of your script - (Example)

💎 Provides a nice output in different ways

💎 You can run a command or load commands from a text file

💎 ability to search in the output of a command with RegEX

💎 ability to use Python conditionals based on the status code or the search output of a command

💎 and more 😉

Simple Example

Code is Here

image-20200609050855480


Sample of Fetching stderr

Code is Here

image-20200609050302886

image-20200608211510011

image-20200608200752632


Requirements

  • Python3

Installation

  • To get started you just need to install the following Python Libraries
pip3 install pygments
pip3 install paramiko
git clone https://github.com/eslam-gomaa/Flexible_Nework_Automation.git
cd Flexible_Nework_Automation

Usage

Step 1

This idea behind this Module is that you can import it within your Python code

  • So simply you can create a a python script & import the following:
touch example.py
vi example.py
from main import SSH_Connect # import "SSH_Connect" class
from main import hosts       # import "hosts"       function

Step 2

After you write your code, ( discussed Here ) you can run your script

python3 example.py --help
  • hosts file is a text file contains a list of the hosts that the script will automate

Example:

192.168.1.20
router1.example.com
sw1.example.com
  • Then you run your script with --file or -f to specify the hosts file
python3 example.py --file <Hosts-File>

Eslam Gomaa

About

A Python Module that allows you to Flexibly Automate your network devices

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages