Link Search Menu Expand Document (external link)

Script used in this example can be found in this directory: Code Samples

In this example we create a script that does the following:

  1. Authenticate to the selected inventory group (Using CLI)
  2. execute set of commands
  3. Take a config backup & store it in S3


Run the script

python3.6 docs/Docs/Examples/sample-2.py -n task-1 --config ~/flexible_network.cfg  --inventory user/hots  --authenticate-group works --user orange --password cisco

OUTPUT

> Authenticating selected devices
   90.84.41.239  [ 1 / 1 ]          Connected [ 1 ]     Failed [ 0 ]    

> Connection Report   
+--------------+---------------------+-----------+--------------+---------------+-------------------------+---------------+
| Host         | Connection Status   | Comment   |   N of tries |   Max Retries |   Time tring in seconds | Fail Reason   |
+==============+=====================+===========+==============+===============+=========================+===============+
| 90.84.41.239 | 🟢                  | connected |            1 |             3 |                       1 |               |
+--------------+---------------------+-----------+--------------+---------------+-------------------------+---------------+


@ 90.84.41.239
Execution Time: 0.5 seconds
sh ip int br
Interface              IP-Address      OK? Method Status                Protocol
Ethernet0/0            unassigned      YES unset  up                    up      
Ethernet0/1            unassigned      YES unset  up                    up      
Ethernet0/2            unassigned      YES unset  up                    up      
Ethernet0/3            unassigned      YES unset  up                    up      
Ethernet1/0            unassigned      YES unset  up                    up      
Ethernet1/1            unassigned      YES unset  up                    up      
Ethernet1/2            unassigned      YES unset  up                    up      
Ethernet1/3            unassigned      YES unset  up                    up      
Vlan1                  unassigned      YES unset  administratively down down    
Vlan11                 192.168.11.2    YES NVRAM  up                    up      
backup-config-eslam-5

@ 90.84.41.239
> backup taken successfully > [ Testing S3 integrations ]

Screenshoots

image


List the backups

python3.6 docs/Docs/Examples/sample-2.py --backup --list
| a893500c-836e-4d22-94b9-e4980be1fe00 | Testing S3 integrations  | 90.84.41.239 | s3       | 🟢 success | 29-03-2022 | 10-47-05 |
+--------------------------------------+--------------------------+--------------+----------+------------+------------+----------+
| 4d6fae23-8c80-417a-bafb-af617b6dd5ba | test                     | 90.84.41.239 | local    | 🔴 failed  | 01-04-2022 | 06-10-32 |
+--------------------------------------+--------------------------+--------------+----------+------------+------------+----------+
| 41ce52a6-0c03-4efe-a29d-07ef752c53f0 | test                     | 90.84.41.239 | local    | 🟢 success | 01-04-2022 | 06-13-12 |
+--------------------------------------+--------------------------+--------------+----------+------------+------------+----------+
| e02e2910-c3b3-4e25-9f1c-19fa389f1710 | test                     | 90.84.41.239 | local    | 🟢 success | 01-04-2022 | 06-14-09 |
+--------------------------------------+--------------------------+--------------+----------+------------+------------+----------+
| 116ba93e-4e90-4e33-9b39-0b89b37e648e | test                     | 90.84.41.239 | local    | 🟢 success | 01-04-2022 | 06-14-32 |
+--------------------------------------+--------------------------+--------------+----------+------------+------------+----------+
| 53a63787-6f26-4d23-89c5-18a71471bc50 | Testing S3 integrations  | 90.84.41.239 | s3       | 🟢 success | 12-04-2022 | 20-25-50 |
+--------------------------------------+--------------------------+--------------+----------+------------+------------+----------+

image


Get the backup

image

Note: For any backup targets other than local you need to specify the configuration file. (which in this case contains the credentials for S3 APIs)

image