Arista Configlet Builder (in CloudVision)

Arista Configlet Builder (in CloudVision)

Nowadays, almost every networking vendor offers some form of management and orchestration platform for their devices.

Arista's platform is called CloudVision. It features a graphical user interface (GUI) for provisioning and managing Arista devices. While its interface might appear more straightforward compared to something like Cisco's DNA Center and may lack some of the more advanced features, I consider this simplicity a net positive , which is the focus of this article.

Before diving into Configlet Builder, it's important to first explain how CloudVision operates, particularly in the context of provisioning devices.

In CloudVision, you can create and manage configlets, which are essentially configuration snippets that can be assigned to devices. For example, you might create a services configlet that includes network-wide settings such as NTP and DNS servers. This type of configlet could be applied globally across all devices in your network.

Other configlets might include device-specific information, such as interface IP addresses. The combination of all assigned configlets forms the overall configuration of each device.

If a change is made to a configlet that has already been deployed to a device, CloudVision immediately generates a task to update the configuration of every device that the configlet is assigned to.

A simple configlet could look something like this:

int eth1
ip address 1.1.1.1/30        

With that context in mind, let's move on to the Configlet Builder. This tool in CloudVision allows you to create template-based configlets, which generate unique configuration snippets based on parameters you define when they are assigned to devices.

Let’s use a spine-leaf network as an example to illustrate this. In such a network, each interface on every device would need a unique IP address. You could manually create separate configlets for each of the 12 devices in your network—say, 4 spines and 8 leaf switches—or, using the Configlet Builder, you could generate all 12 configlets from a single template.

The power of the Configlet Builder lies in its flexibility: it's based on Python code, and you can access device information (via CloudVision) to dynamically generate configurations.

For instance, if you need to use a device's hostname to influence the configuration, you can write a script like this:

from cvplibrary import CVPGlobalVariables, GlobalVariableNames
hostname = CVPGlobalVariables.getValue(GlobalVariableNames.CVP_SERIAL)        

The Configlet Builder's Python integration allows you to automate configuration tasks with minimal effort. The only difference from standard Python is in the libraries used to retrieve data from Arista devices. This simplicity, in my view, is what makes the tool so powerful: you write Python code, access device information, and orchestrate configurations with ease.

Here’s an example of a complete configlet built with the Configlet Builder. This script assigns IP addresses to the interfaces of leaf and spine devices, assuming all spines have hostnames of "spineX" and all leaf switches have hostnames of "leafX". The script generates IP addresses from a provided subnet, assigning a /31 subnet mask to each interface.


# Input details
spines = 4
leafs = 4
mysubnet = "192.168.1."

# Retrieve host information
from cvplibrary import CVPGlobalVariables, GlobalVariableNames
hostname = CVPGlobalVariables.getValue(GlobalVariableNames.CVP_SERIAL)

# Uncomment the line below to run locally
# hostname = "spine2"

address_size = spines * 2

if "leaf" in hostname:
    leaf_id = int(hostname[-1])
    range_start = address_size * (leaf_id - 1)
    range_end = address_size * leaf_id

    for num in range(1, spines + 1):
        leaf_int_ip = mysubnet + str(range_start + (num - 1) * 2)
        print(f"int ethernet{num}")
        print(f"  ip address {leaf_int_ip}/31")
        print("  no switchport")

if "spine" in hostname:
    spine_id = int(hostname[-1])
    for num in range(1, leafs + 1):
        ip = ((spine_id - 1) * 2) + 1 + (address_size * (num - 1))
        spine_int_ip = mysubnet + str(ip)
        
        print(f"int ethernet{num}")
        print(f"  ip address {spine_int_ip}/31")
        print("  no switchport")
        

Other than the two lines used to retrieve the hostname, this is standard Python code.

For example, if the hostname is "spine2," the generated configlet might look like this:

int ethernet1
  ip address 192.168.1.3/31
  no switchport

int ethernet2
  ip address 192.168.1.11/31
  no switchport

int ethernet3
  ip address 192.168.1.19/31
  no switchport

int ethernet4
  ip address 192.168.1.27/31
  no switchport
        

The best part is that you can come back to this configlet builder , make changes and the changes would be automatically staged to be applied to all affected devices.

Imagine for a second that you wanted to set the mtu on the thernet interfaces. it would be as easy as adding that line in the configlet builder.

CloudVision is not without its own warts but I did feel it was important to call out the pleasantness thats configlet builder.

If you have any questions or need help with any of this stuff, please reach out.

Chidi Oparah

Transformation Specialist | Programme Director | Programme Manager | Enterprise Agility | AI Automation | Cloud | Market Ops | DataCenter | DevOps | RTE6 | SPC6

4 个月

Hi Nnanna Obuba love the article seems to me like this adds to the stack of utilities in managing the network.Does it work for the entire Arista Suite of devices?

要查看或添加评论,请登录

Nnanna Obuba的更多文章

社区洞察

其他会员也浏览了