HomeGuidesAPI Reference
GuidesAPI ReferenceGitHubAirheads Developer CommunityLog In

Example Workflows

Short examples of creating workflows

❗️

This page is currently using pyaoscx v1

These documented pages will be updated for pyaoscx v2 in the near future

Now that we've broken down the details of creating a workflow, here are a couple succinct examples of how to do so:

  1. Getting LLDP Neighbors
  2. Configuring simple BGP

"Read the Docs"

Again, the pyaoscx modules are documented on the our "Read the Docs" page here. This resource helps us figure out what functions within what modules we need to use in our workflows to configure features.

1. Creating a workflow to get a list of LLDP Neighbors

In the same manner that we created the VLAN scripts, we'll create a script to retrieve a list of the LLDP Neighbors. Again, we can borrow elements that are common to all the scripts--the setup, the login, and the logout. The first change we have to make is that when we're importing our aos_cx modules, we have to import the lldp module:
from pyaoscx import lldp

As for the core steps portion of the workflow, we have to add our call to retrieve the list of LLDP Neighbors:
lldp_neighbors_list = lldp.get_all_lldp_neighbors(**session_dict)

2. Creating a workflow to configure simple BGP

Now let's perform a basic BGP configuration. In this example workflow, we will set up the BGP instance, create an ASN, and set the router ID. Then we'll add a BGP peer with whom we want our device to exchange IPv4 address routes. We will use an example configuration shown by the following CLI commands:

router bgp 65001
    bgp router-id 10.2.0.101
    neighbor 10.2.0.1 remote-as 65002
    address-family ipv4 unicast
        neighbor 10.2.0.1 activate
    exit-address-family

Again, near the top where we have our pyaoscx module imports, we must first import the appropriate module(s), in this case bgp:
from pyaoscx import bgp

Next, in our core steps, we'll add our necessary function calls. The first thing we have to do is set up the BGP instance, and create the ASN, and set the router ID. We do that with this function call:
bgp.create_bgp_asn("default", 65001, "10.2.0.101", **session_dict)

Then, we add our BGP peer:
bgp.create_bgp_neighbors("default", 65002, "10.2.0.1", "ipv4-unicast", **session_dict)