cancel
Showing results for 
Search instead for 
Did you mean: 

Assistance with automating cli commands on AP using Python/Paramiko

Assistance with automating cli commands on AP using Python/Paramiko

chris_krieter
New Contributor

I am trying to build a python script to connect to the APs cli via SSH using Paramiko, issue commands and collect the output. Ultimately, I want to develop a more automated and reliable method to upgrading the APs software in the field.

 

I am able to connect to the AP using paramiko.SSHClient() and .connect() and this appears to be successful. When I issue .exec_command("show version") for example, I get nothing back in the stdout buffer. Code example below:

 

ssh = paramiko.SSHClient()

   ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

   print("Connecting to AP")

   ssh.connect(hostname=ap_ip, username="admin", password="1234")

   print("Connected -sending command to AP")

   stdin, stdout, stderr = ssh.exec_command("show version")

   print("command issued")

   data_out = stdout.readlines()

   print(data_out)

   stdin.flush()

   ssh.close()

 

Has anyone successfully been able to script against the Aerohive APs? Any direction would be appreciated as I am not making progress with this effort. Thanks!

13 REPLIES 13

andy_truett
New Contributor

Why don't you show us what you've got and we can walk through it with you.

bobby_clowers
New Contributor

I'm a noob on python and I can't seem to make any of those work. Any more help or explanation?

andy_truett
New Contributor

It's been used internally for a while, but decided to get it out into the world, due in part to seeing this question.

chris_krieter
New Contributor

Andy - this is awesome! Did you just create this? Nice work!!

 

Good call on the Nornir, we had discussed using for this reason!

andy_truett
New Contributor

See also: https://github.com/andytruett/aeromiko

 

We pair it with Nornir to get information from many APs and make batch changes with concurrency.

GTM-P2G8KFN