My goal was to update the controller on my APs from http://weburl:8080 to http://weburl2:8080. I have over 200 Unifi Wireless Access Points that need the update. After I wrote this python script I learned I could use ansible to do this, but as it stands I know python and not Ansible.

First: Get the IP addresses from Unifi. They do not have an export option. So the easiest way I found was to copy and past all the text on the page and use a script to pull the IP addresses from it.

cat IPs.txt | python3

import fileinput
import re

for line in fileinput.input():
    ip = re.findall( r'[0-9]+(?:\.[0-9]+){3}', line )
    if ip:
        for i in ip:

Now I saved the results as APs.txt

Second: use this python script to SSH into each AP and update the inform command. This script is threaded so if the IP address is not accessible it just keeps going to the next AP.

import sys, os, string, threading
import paramiko
import numpy as np

cmd = "/usr/bin/mca-cli-op set-inform"


outlock = threading.Lock()

def workon(host):

    ssh = paramiko.SSHClient()
    ssh.connect(host, username='admin', password='your-password')
    stdin, stdout, stderr = ssh.exec_command(cmd)

    with outlock:
        print (f'STDOUT: {"utf8")}')

def main():
    hosts = datafromfile # etc
    threads = []
    for h in hosts:
        t = threading.Thread(target=workon, args=(h,))
    for t in threads:


There maybe another better way to get all this done. Feel free to let me know. In the meantime I will be learning ansible. Hopefully this helps someone else who is trying to do this.