Getting Started with pyaoscx
Overview of Python and pyaoscx
What is Python?
Python is a high-level programming language that is used widely across various disciplines. Highly regarded for its simplified syntax, beginner-friendliness, and abundance of third-party libraries, Python is among the most popular programming languages in the world. The networking community especially embraces Python due in no small part to extensive vendor support as well as a low barrier of entry for getting started with automation and scripting.
About the pyaoscx Library
The pyaoscx
package contains Python modules that can be called upon to access the REST API and configure various features on the switches. In order to use pyaoscx
, Python 3 must be installed on your system. You can download and install Python here.
The
pyaoscx
package is compatible with Python 3 only. Python 2 is not officially supported.
AOS-CX Module Support
Module⁺ | 8400 | 8325 | 8320 | 6400 | 6300 |
---|---|---|---|---|---|
access_security.py | ❌ | ❌ | ❌ | ✅ | ✅ |
acl.py | ✅ | ✅ | ✅ | ✅ | ✅ |
arp.py | ✅ | ✅ | ✅ | ✅ | ✅ |
bgp.py | ✅ | ✅ | ✅ | ✅ | ✅ |
config.py | ✅ | ✅ | ✅ | ✅ | ✅ |
dhcp.py | ✅ | ✅ | ✅ | ✅ | ✅ |
evpn.py | ✅ | ✅ | ✅ | ✅ | ✅ |
interface.py | ✅ | ✅ | ✅ | ✅ | ✅ |
lag.py | ✅ | ✅ | ✅ | ✅ | ✅ |
lldp.py | ✅ | ✅ | ✅ | ✅ | ✅ |
loop_protect.py | ✅ | ✅ | ✅ | ✅ | ✅ |
mac.py | ✅ | ✅ | ✅ | ✅ | ✅ |
ospf.py | ✅ | ✅ | ✅ | ✅ | ✅ |
port.py | ✅ | ✅ | ✅ | ✅ | ✅ |
qos.py | ✅ | ✅ | ✅ | ✅ | ✅ |
system.py | ✅ | ✅ | ✅ | ✅ | ✅ |
vlan.py | ✅ | ✅ | ✅ | ✅ | ✅ |
vrf.py | ✅ | ✅ | ✅ | ✅ | ✅ |
vsx.py | ✅ | ✅ | ✅ | ❌ | ❌ |
vxlan.py | ❌ | ✅ | ❌ | ❌ | ✅ |
The modules
common_ops.py
andsession.py
are also in the package, but they don't correspond with features and have been omitted from this table.
Package Structure
pyaoscx
│ README.md
│ Contributing.md
│ ...
│
└───pyaoscx
│ │ access_security.py
│ │ acl.py
│ │ ...
│
└───docs
│ │ ...
│
└───workflows
│ cleanup_l2_l3_vlans.py
│ configure_l2_l3_vlans.py
└───print_system_info.py
The pyaoscx
package is a directory containing files and subdirectories. Contained directly within the top level pyaoscx
directory are informative files such as the readme, licensing information, contribution guidelines, and release notes. Also contained directly within the top level directory are the relevant code-containing directories pyaoscx
and workflows
.
pyaoscx
The pyaoscx
subfolder contains the AOS-CX Python modules. Each module contains function definitions which either make a single REST API call or multiple REST API calls. Each function that makes multiple REST API calls is written as such to perform a small logical low-level process (e.g. one call creates a VLAN and the next creates a corresponding VLAN interface). The REST API calls are performed using the Python requests
library, which provides functions to make HTTP GET, PUT, POST, and DELETE requests. Information about the requests
library can be found here.
workflows
Workflows are scripts that combine calls to functions in the pyaoscx
modules to emulate large higher-level network configuration processes (e.g. create ACL and ACL entries, apply ACL on interface, and lastly enable interface). The workflows
subfolder contains three example workflows. Each contains comments that describe step-by-step the operations being performed. If you'd like to try these out, you can make copies of these workflows in your own user directory and run them directly. In addition, you may find them to be useful references when creating your own workflows.
Updated about 4 years ago