Python – How to Connect to a Cisco WLC (Aireos)

This is a very simple article just explaining how you can connect to a Cisco WLC (aireos) using a python script.

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: ​


We will assume that you have already Python installed on your computer. I would also advise you to use virtual environment when developing Python scripts on your computer.

Here is the tutorial I have followed in order to setup my laptop (macOS) for Python programming: ​

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:
Here is how I installed the netmiko library within this new virtual environment:


Here is the Python code you will need to in order to connect via SSH to a Cisco WLC. Obviously you need to gather this information first:

  • IP address of the WLC
  • Username allowed to SSH into the WLC
  • Password associated with that user
#!/usr/bin/env python
from netmiko import ConnectHandler
with ConnectHandler(ip = '',
                        port = 22,
                        username = 'admin',
                        password = 'Cisco123!',
                        device_type = 'cisco_wlc_ssh') as ch:
    print(ch.send_command("show ap summary"))

In this example, we are using the object called ConnectHandler from the netmiko library to establish an SSH connection to the WLC (

​Once connected, we are sending the command “show ap summary” and we are displaying the output of this command.


onnecting to the Cisco WLC could be the first step in a more complex script. Therefore, I have done the following in order to ease the process:

  1. Created a configuration file where I keep my WLC details (IP address, username and passwords)
  2. Created a script that I called 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):
<!--?xml version ="1.0" encoding="UTF-8"?-->
    SemFio Networks
Here is what my script looks like:
#!/usr/bin/env python
# This script SSH into a network device defined in a configuration filename
# Configuration file: wlc.configuration
# This script can also be used as a library
# Written by @VergesFrancois
import xmltodict
from netmiko import ConnectHandler
''' Retreive the network device details from an XML config filename
    - Config file:  'wlc.config'
    - Returns:      A dict containing the device details
def retrv_device_info(config_file: str) -&gt; dict:
    with open(config_file, 'r') as file_object:
        xmlString =
        dom = xmltodict.parse(xmlString)
        device = {'name':dom['wlc']['name'],
    return device
''' SSH into a WLC and send the 'show ap summary' command
    * Paramters
        - Device: Dict containing the device details
    * Returns
        - A str containing the output of the command
def retrv_ap_summary(device: dict):
    print('** Connecting to {} ({})...'.format(device['name'],device['address']))
    with ConnectHandler(ip = device['address'],
                        port = device['ssh_port'],
                        username = device['username'],
                        password = device['password'],
                        device_type = device['device_type']) as ch:
        print('** The connection is open')
        command = "show ap summary"
        output =  ch.send_command(command)
    return output
def main():
    device = retrv_device_info('wlc.config')
if __name__ == "__main__":

If you know other alternatives to do the same thing, please feel free to add a comment.

As I continue to learn more about Python, I will continue to share it with you guys on the blog.

Thank you!

Notify of
Inline Feedbacks
View all comments