You could use this as a first step in developing more advanced Python scripts to monitor or configure your Cisco Wireless Lan Controllers.
I am still learning Python so this might not be the only and easiest way to do it!
Note: starting with version 8.8, you could interact with your Cisco WLC in a easier way using YANG models. See this presentation from Cisco Live: https://www.ciscolive.com/c/dam/r/ciscolive/us/docs/2018/pdf/BRKEWN-2050.pdf
Prerequisites
Here is the tutorial I have followed in order to setup my laptop (macOS) for Python programming: https://developer.cisco.com/learning/lab/dev-mac/step/1
Here are the program and libraries we will be using here:
- Python 3.7
- netmiko
Here is how I setup a virtual environment for Python 3.7 on my laptop:
Code - How To
- IP address of the WLC
- Username allowed to SSH into the WLC
- Password associated with that user
Once connected, we are sending the command "show ap summary" and we are displaying the output of this command.
Go a Step Further
- Created a configuration file where I keep my WLC details (IP address, username and passwords)
- Created a script that I called ssh_wlc.py that defines function that will establish the connection based on the WLC configuration file
I then re-use my script as a "library" whenever I work on a script and I need to connect to a Cisco WLC.
Note: Python 3.5+ is required here since we are using PEP 484 type hints.
Here is what my configuration file looks like (I used xml so it is easier to parse):
If you know other alternatives to do the same thing, please feel free to add a comment.
Thank you!
written by François Vergès