• Tag : Python


Arista VLAN with Pexpect

Hello, I’m trying to create multiple VLANs for Arista EOS switches with for loop but not sure how to as (config-vlan-number) changing on every vlan configuration. Any advice? Using pexpect for this: “` for n in range(2, 11): print(“Creating VLAN ” + str(n)) ch.sendline(‘conf t’) ch.expect(‘\(config\)#’) config_commands = f’vlan {n}’ config_name = f’name PexpectVLAN{n}’ ch.sendline(config_commands) ch.expect(‘\(config-vlan-{n}\)#’)    #how to read every vlan in the loop ch.sendline(config_name) ch.expect(‘\(config-vlan-{n}\)#’) ch.sendline(‘end’) “` Thank you  

Using the CloudVision API with Service Accounts

Description With the release of CloudVision Portal 2020.3, you have the ability to create Service Accounts. I won’t show you how to create a Service Account, but you can go to this TOI to read about that. This article will show you how to use Service Account Tokens in Python and cURL for API calls. Platform Compatibility This applies to both CVaaS and on-premise installations. How To Using a Service Account Token allows you to bypass the standard authentication process when making API calls. It also allows you to create a local “account” on CloudVision that doesn’t depend on outside authentication...
Continue reading →

Running python script in vrf

Hello, My management interface is in the mgmt vrf. I have writtel a very simple python script, where I have defined switch = Server(“https://test:test@”) When trying to run my script from Bash, it stucks and after awhile I get connection timeout: socket.error: [Errno 110] Connection timed out I suspect that the script cannot reach the mgmt vrf, because from Bash I cannot ping the Management IP. If this is the reason, is there a way to insert the vrf into the switch declaration? Thanks

JSON responces

Hi, I work with your equipment and I need to know the system parameters. In my work I use pyeapi. I retrieve data using commands: Hi, I work with your equipment and I need to know the system parameters. In my work I use pyeapi. conn.execute(['show mac address-table']) conn.execute(['show interfaces status']) and so on I inherited the code and now I am having difficulty parsing data from JSON Could you give a link to the data structure so that I can better analyze JSON ?  

Installing python libraries in arista EOS

Hi, I have some arista switches running on 4.16.6FX. I am trying to run some python scripts but they are failing due to missing modules/libraries. How can I install 3rd party python libraries/modules in arista? I tried and pip install …. didn’t work. jacob

How to Automate MAC Address Lookups

Introduction MAC addresses are often overlooked, compared to higher layers of the OSI model, but they are a necessity in the transfer of data across the network. MAC addresses are unique in nature, with the vendor OUI portion of the MAC, and the client portion of the MAC. There are many reasons why locating a device is necessary, a few of them are: A device is causing adverse affects to the network and the port needs to be shutdown A port needs to be re-configured for a new device, but it is not known where the device is connected to...
Continue reading →

Multi-Line / Python Input for the Event Handler Actions

Introduction The EOS Event Handler feature provides the ability to specify a condition and an action to be carried out when that condition is detected. It is a flexible and configurable way to automate the reaction to conditions without the need for a system operator to observe and apply the desired actions manually. The multi-line action is an extension to the Event Manager. It provides the ability to write an action script that is not limited to a single line. In addition, it allows the script start with a #! or “bang line” to indicate the interpreter that should be...
Continue reading →

Network CI/CD Part 2 – Automated Testing with Robot Framework library for Arista devices

Previously on Network CI/CD Part 1… We’ve established that lack of simulated test environments and automated test tools are among the inhibitors in a transition from a traditional network operation model to a DevOps workflow, where all changes are verified and tested prior to being deployed in production. We’ve seen how to solve the first problem with Arista’s cEOS-Lab docker container and a simple container orchestration tool. We’ve shown how the new containerised EOS allows us to dramatically increase the number of nodes we can deploy on a single host and decrease the total build and boot time compared to VM orchestration methods, e.g. the ones based on...
Continue reading →

EAPI script to push extensions across list of EOS devices using Python

Introduction This article demonstrates Arista’s EOS automation capabilities leveraging eAPI. This document walks you through a script to Secure Copy (SCP) an extension on Arista switches along with installing the extension on the list of switches defined in the script. Pre-Requisites This script is supported on Linux/Unix/Mac Operation Systems. The Arista eAPI must be enabled on the switches and can be configured as follows: Arista> enable Arista# configure terminal Arista(config)# management api http-commands Arista(config-mgmt-api-http-cmds)# [no] shutdown Arista(config-mgmt-api-http-cmds)# [no] protocol https [port ] Arista(config-mgmt-api-http-cmds)# [no] protocol http [port ] Jsonrpclib python module, could be installed as follows: [admin@Arista ~]$ pip install jsonrpclib Deployment methods There...
Continue reading →

CloudVision Portal RESTful API Client

Arista Cloudvision® Portal (CVP) provides a central point of management for Arista network switches through shared snippets of configuration (configlets) enabling Network Engineers to provision the network more consistently and efficiently. While CVP highlights a graphical user interface for configuration and management of devices, it also includes a full-featured RESTful API that provides all of the same functionality available via the GUI which can be used to automate workflows and integrate with other tools. CVPRAC is a wrapper client for CVP’s RESTful APIs which greatly simplifies usage of the API and more elegantly handles the connections to the CVP nodes....
Continue reading →

CVP APIs: A Non-Programmer’s Guide

1. What are CVP APIs? Most CloudVision Portal (CVP) users are familiar with the web user interface (UI) that facilitates network provisioning, inventory management, tasks management, change control and so on.  CVP application programming interfaces (APIs) offer an alternative means of realizing the same functionality.  The key difference is that, with the CVP APIs, the functionality is realized over a programmatic interface (i.e typically by a piece of software communicating with another piece of software) rather than by a user navigating over a web page and clicking and/or typing.  Figure 1 shows a simplified example of these two methods of...
Continue reading →

extending eos cli with python

Has anyone had success implementing a cli extension with vEOS rev 4.18? I’m following this guide and got some guidance from our sales team on what changes were needing to be made but not getting very far with making this work on the eos central post https://eos.arista.com/extending-eos-cli/#Cli_Registration.   -a

Agent unable to connect to Sysdb

I’m relatively new to EOS, so I feel like I’m probably missing a basic step. I’ve setup a vEOS testlab, running under KVM.  Most things have been going well, the virtual switches can see each other, i’ve been able to test some ZTP scripts. I’m getting stuck however when it comes to running an agent using the python sdk.  I’m attempting to start the HelloWorld.py from this example (https://github.com/aristanetworks/EosSdk/wiki/Quickstart:-Hello-World) However, all I get when looking at the agent logs is “waiting for connection to Sysdb …..” and it never connects. veos-vdf-core1#configure veos-vdf-core1(config)#daemon HelloWorldAgent veos-vdf-core1(config-daemon-HelloWorldAgent)#show active daemon HelloWorldAgent exec /mnt/flash/HelloWorld.py no...
Continue reading →

Export CVP Functionality to Ansible

In some network environments there is a separation of responsibility for the network infrastructure and the server side equipment. In these environments, different groups responsible for managing different equipment could use different tools for the job. This guide will discuss one of the several options for integrating Arista’s network management tool, CloudVision Portal (CVP), into an Ansible environment. Summary In this example, the environment uses Ansible as the configuration management tool for server provisioning but uses CVP for network management. The environment is set up to allow the server team to provision top of rack switch ports for servers using...
Continue reading →

Leveraging CVP Telemetry and ZTP in an Ansible Environment

This guide will discuss one of several options for integrating Arista’s network management tool, CloudVision Portal (CVP), into an Ansible environment. Summary In data center environments where Ansible is used for configuration management of all devices including networking equipment, the network operations team may want to leverage the telemetry and Zero Touch Provisioning (ZTP) functionality provided by the CloudVision Portal product. In this example, CVP will be used for ZTP, image upgrades, and telemetry while Ansible will be used to manage the switch configuration directly. Documentation for setting up ZTP can be found in the CloudVision configuration guide. Implementation This...
Continue reading →

FastCli – Calling Python Script

Hi, I added a new event-handler called TEST, what it does is when int49 operational status goes to “notconnect”, I want to disable the port. normal bash command is not working. (tested with TAC) Switch : Arista 7150 – 52 port EOS: so I wrote a python script and stored in /mnt/flash/hello1.py (when I separately run the command, it checks the status of the interface (“notconnect”) and disabling them properly. But to call the script in event-handler command? FastCli ???? Can some one please help me.. Thanks Hari  

Valid Python Scripts may fail in OS X ‘El Capitan’

Python scripts can be run on OS X using eAPI to access Arista Switches or vEOS instances. Python Scripts can also be run on OS X to automate the installation of vEOS: (https://github.com/arista-eosplus/packer-veos). After installing or upgrading to OSX ‘El Capitan’ (OS X version 10.11.5) Python Scripts that previously worked fine under earlier versions of OS X or work on other operating systems may fail. This is evident when making a Python Script executable after issuing the chmod +x command.  This is due to operating system changes Apple has introduced in ‘El Capitan’. Although, this problem may affect eAPI and...
Continue reading →

Script to update EOS in sw’s in a bulk

Hi We want to upgrade EOS in sw’s. We want to automate this process. We can use solarwinds to execute a script or a phython script to do it. If someone can provide with template for it so we can test it in a lab sw and use it in production.   Thanks Raj  

Interface MTU with JSON and Python

Hi, I am trying to do something which I thought would be fairly simple using the EOS API, alas it is causing me some issues. I want to run the command “show interfaces” via the JSON API and then extract and print various bits of information. I have started off simple by (trying) to extract the MTU. This is my Python code: import json import jsonrpclib from jsonrpclib import Server switches = [""] username = "admin" password = "admin" # Going through all the switch IP addresses listed above for switch in switches: urlString = "https://{0}:{1}@{2}/command-api".format(username, password, switch) switchReq =...
Continue reading →

Script example – Automating VXLAN deployments with EAPI

  1) Introduction This article describes briefly what is required to deploy overlay networks with VXLAN, but we assume a good understanding of the VXLAN fundamentals. To achieve such VXLAN deployments, multiple options exist, from simple but manual, to fully automated service chaining (orchestration) at the cost of having to also set a Cloud Management Platform or a network virtualization controler This article focuses on an easy option that is a good balance between simplicity of operation (automation), and simplicity of  setting up (script ready to go)   2) Working towards automation: it is an evolution This article is not providing...
Continue reading →


Get every new post on this blog delivered to your Inbox.

Join other followers: