Posts

Configure and Verify Cisco ACI Using Acitoolkit

Image
Some instructions and code on how to use the Acitoolkit objects to perform configuration checks against the APIC running state and then create a new Tenant configuration from scratch. Instructions for setting up acitoolkit for the first time are given here: https://acitoolkit.readthedocs.io/en/latest/tutorialsetup.html When trying to use acitoolkit in python for the first time, I got quite a few 'ModuleNotFoundError' messages before succeeding. After overcoming this rabbit-hole after much StackOverflow-ing, I managed to get the acitoolkit working. Definitely ensure the Microsoft Visual C++ components have been installed: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019 You may also get the same problems as I did in needing to do pip installs for acitoolkit, six, websocket, websocket-client and pyrsistent before being able to proceed. What this script does is to import the import the necessary modules for session, tenant, con...

Using Cobra SDK and Arya to create a Tenant

Image
Getting the python and virtual environment set up These instructions are for a Windows set up. Use these instructions for setting up your Python virtual environment and for obtaining and installing the Cobra SDK and model. https://cobra.readthedocs.io/en/latest/install.html But essentially, if you're doing this for the first time, then do the following: Download and install python 2.7 from here (yes, version 2.7) https://www.python.org/downloads/ Download this python script to a chosen location, and run it using python. This will install pip. https://bootstrap.pypa.io/get-pip.py Run these pip commands. I found that I needed to run the pip2 executable as opposed to version 3 pip that was already installed, in order to successfuly install the requirements and run using python2 etc. [code language="txt"] pip install virtualenv pip install virtualenv-clone pip install virtualenvwrapper-win [/code] Run this command to create your virtual environment (See how i...

Creating Python scripts from NX-API

Image
Cisco Nexus devices, the most popular configuration method uses command-line interfaces (CLI) that run only on the device. This method has limitations and does not scale well. To improve the CLI shortcomings, Cisco introduced NX-API REST by providing HTTP/HTTPS APIs that: Provide specific CLIs available outside the switch. Combine configuration actions into relatively few HTTP/HTTPS operations. NX-API REST uses HTTP/HTTPS as its transport. Configuration commands are encoded into the HTTP/HTTPS body and use POST as the delivery method. In the backend, NX-API REST uses the Nginx HTTP server. You can instruct the Nginx server to return requested data either in XML or JSON format The "official" lesson on creating python scripts from NX-API can be found at the Cisco developer site here: https://developer.cisco.com/learning/lab/nxos-intro-03_nxapi-rest/step/1 The site for the NX developer sandbox I have been using is here: https://sandbox-nxos-1.cisco.com/ The ...

Using Ansible to automate Cisco ACI in Windows

Image
Some instructions on how to get started with using the ansible to automate Cisco ACI specifically by using ansible playbooks to accomplish basic tasks. Using the Cisco ACI GUI can be time-consuming and error prone, a more efficient could be to automate the process using ansible playbooks. Ansible is essentially an automation tool that uses playbooks consisting of Yaml files to automate the process of network configuration via connection to the APIC REST interface and push the config API commands. Really useful link for how to get your Windows environment set up for using ansible, including Cygwin and Linux virtual machines: https://phoenixnap.com/kb/install-ansible-on-windows#htoc-method-1-using-cygwin I have found the Cygwin approach to work perfectly fine for running ansible. In fact, I recommend Cygwin as the way to go in running ansible in your Windows environment, given that all my attempts to install via 'pip install' commands failed. The number of Stack...

Using Python with Cisco APIC REST API

Image
Some instructions on how to get started with interfacing Python with Cisco APIC REST API. I found this blog post by Wim Wauters particularly useful, and I have used much of his material in this post: https://blog.wimwauters.com/networkprogrammability/2020-03-19-aci_python_requests/ Initial setup If you have not yet done so, download and install Python. https://www.python.org/downloads/ Example 1: login to the APIC Sandbox controller Details of how to set up the REST API required to log in to the APIC controller can be found on this blog post , including how to obtain the login username/password credentials required (described in the Initial Setup section). For convenience, I reproduce the REST API here (the password is subject to change, so login to the sandbox URL to get the most up-to-date credentials) POST https://sandboxapicdc.cisco.com/api/aaaLogin.json [code language="xml"] {     "aaaUser":{         "attributes":{            ...