cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
391
Views
0
Helpful
2
Replies

AP inventory AIREOS

ariask93
Level 1
Level 1

Hi guys!

I knew in this world of automation, I trying to get an inventory of all AP's that are register in a WLC 5520 - AIREOS

This is part of my code.

 

df = pd.DataFrame()
data = {}


# obtiene la lista de ips a conectarse
with open("ipdiscoc.txt", "r") as f:
    ips = f.read().splitlines()

# recorre la lista de ips
for ip in ips:
    try:
        # establece la conexión al dispositivo
        device = ConnectHandler(
            device_type='cisco_wlc_ssh',
            ip=ip,
            port=22,
            username= username,
            password= password
        )

        # ejecuta el comando para obtener la configuracion
        hostname = device.find_prompt()
        cdp = device.send_command('grep include NAME:|DESCR:|PID:|VID:|SN: "show ap inventory all"', use_textfsm=True, read_timeout=300, delay_factor=2)
        data[hostname] = cdp
        # crea un archivo con el nombre del host y la fecha actual
        print(f"La configuracion del dispositivo con IP {ip} ha sido guardada")
    except Exception as e:
        print(f"Error al conectarse al dispositivo con IP {ip}: {e}")
    finally:
        # cierra la conexion
        device.disconnect()
print(data)
for entry in data.keys():
    datadf = pd.DataFrame(data[entry])
    datadf["hostname"] = entry
    df = pd.concat([df,datadf])

df.to_excel("apsummary02.xlsx", sheet_name=hostname, index=False)
 
The problems is: When the command "grep include NAME:|DESCR:|PID:|VID:|SN: "show ap inventory all" is execute, the prompt is waiting to press a key to continue, so, I don't know how to send that key,bottom to continue with the straction of data.
 
 
(Cisco Controller) >grep include NAME:|DESCR:|PID:|VID:|SN: "show ap inventory all"
Press any key to continue..
 
 
1 Accepted Solution

Accepted Solutions

Leo Laohoo
Hall of Fame
Hall of Fame

Before entering the grep command, use the command "config paging disable".  

View solution in original post

2 Replies 2

Leo Laohoo
Hall of Fame
Hall of Fame

Before entering the grep command, use the command "config paging disable".  

It's not that. I tried before and I didn't work.

I found this solution:

When you send the command "conf terminal' prompt changes to reflect configuration mode, and it starts to look like Switch(config)# while netmiko still waits for Switch#

So alternatively, if you want to send commands one by one, you can set the expected prompt or use "send_command_timing"