Afenioux's Blog page

3am; darkness; Maintenance window closing. Safety net: rollback.

Arista EOS automation scripts with the API

Written by Arnaud no comments

I've added in a github repository some of the scripts I use for basic operations.
The username should be provide in argument while the password will be requested by the prompt,
here are the details :

First make sur you have enabled the http/https API (there is a lot of documentation and examples if you connect with your web browser on your router's IP) :

management api http-commands
  protocol http
  vrf default
   ip access-group ACL-
API-IN in
   ipv6 access-group ACL6-API-IN in
   exit
  no shutdown
exit

 

sw_list.yml

the list of switches/routers you want to connect to

backup_all.py

backup the running-config and write a file per hostname

./backup_all.py <username>
passwd:


- - - - - -
Proceeding with device : router1
Model and version are: DCS-7280SR-48C6-F - 4.20.8M-INT

- - - - - -
Proceeding with device : router2
Model and version are: DCS-7280SR2A-48YC6-F - 4.20.8M-INT

cli_run.py

./cli_run.py <username>
passwd:
Type your command : show run | include bgp
Proceeding with device : router1
Model and version are: DCS-7280SR-48C6-F - 4.20.8M-INT
router bgp 65535
   no bgp default ipv4-unicast
   no bgp additional-paths receive
   no bgp bestpath as-path multipath-relax


- - - - - -
Proceeding with device : router2
Model and version are: DCS-7280SR2A-48YC6-F - 4.20.8M-INT

deploy.py

If you chose to no commit a change, the script will rollback configuration and exit without processing next device.

eos.conf : the commands you want to deploy with deploy.py

./deploy.py <username>
passwd:
Type configuration session name: bgp


- - - - - -
Proceeding with device : router1
Model and version are: DCS-7280SR-48C6-F - 4.20.8M-INT

--- system:/running-config
+++ session:/bgp-session-config
@@ -824,7 +824,6 @@
    neighbor BPG-IBGP peer-group
    neighbor BPG-IBGP remote-as 65536
    neighbor BPG-IBGP update-source Loopback0
+   neighbor BPG-IBGP additional-paths receive
-   neighbor BPG-IBGP additional-paths send

Commit? (y/N) N
Rollback: aborting session bgp
Exiting...

Some more examples here : https://github.com/ksator/arista_eos_automation_with_eAPI

Classified in : Arista Tags : none

Comments are closed.

Rss feed of the article's comments