.
.
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.
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 😉
Code is Here
Code is Here
- Python3
- 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
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
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 thehosts file
python3 example.py --file <Hosts-File>