Usage _ Python Library
Getting started with the Flexible-Network Library is simple:
- Import
Flexible-Network
library in your Python script - Make sure that you’ve added the hosts in the inventory file
- Use
.authenticate()
method to connect to the choosen group of devices- It returns an object with few attributes, we need to use
hosts_connected
(List) attribute (as it contains the devices that were connected successfully)
- It returns an object with few attributes, we need to use
- Loop through
hosts_connected
list and use the methods you need - Use cli options to run your script
Getting started Example
vi /etc/flexible_network/hosts
[switches]
192.168.1.12
192.168.1.13
192.168.1.11
vi my_script.py
python3 my_script.py --name "Test task"
List the tasks, you’ll find your task at the end
python3 my_script.py --task --list
python3 my_script.py --task --get-log <TASK-ID>
If’ve taken backups, you can list them as well
python3 my_script.py --backup --list
python3 my_script.py --backup --get-backup <BACKUP-ID>