question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with expect_string on new Cisco 9100 series APs

See original GitHub issue

Hi, I’ve reviewed #941 and a couple other issues, and this doesn’t appear to be related, so I’m opening a new issue. I have also reviewed the example uses of expect_string, send_command_timing, and troubleshot this quite a bit on my own but I can’t figure out what is going wrong.

I am using Netmiko version 3.3.0.

Problem Summary

I’m trying to change the hostname on a Cisco 9130AX AP, and part of the process involves restarting the CAPWAP connection to the WLC. The AP asks to [confirm] the CAPWAP restart, so I have Python send a \n. The AP seems to completely ignore the \n that Netmiko is sending, and the CAPWAP connection never restarts.

The latest Cisco 9100 series APs run a slightly different software than the previous 3700/3800/4800 gen hardware. I feel like this is the core of the issue, but I don’t want to jump to any conclusions yet.

Test Code

Here’s the relevant pieces of my test script. I have excluded the username, password, and IP on purpose.

from netmiko import Netmiko

ap_shell = Netmiko(host=ip, username=AP_USER, password=AP_PASS, device_type='cisco_ios', secret=AP_PASS)
ap_shell.enable()
new_name = 'TEST'
output = ap_shell.send_command(command_string=f"capwap ap hostname {new_name}", strip_prompt=False, strip_command=False)
time.sleep(1)
output += ap_shell.find_prompt()
output += ap_shell.send_command(command_string=f"capwap ap restart", expect_string=r"confirm", strip_prompt=False, strip_command=False)
output += ap_shell.send_command(command_string="\n", strip_prompt=False, strip_command=False)
print(output)

Here is the output from the above code:

capwap ap hostname TEST
Please note that if AP is already associated to WLC,
the new hostname will only reflect on WLC after AP
 dis-associates and rejoins.

AP1416.9D2A.1A80#AP1416.9D2A.1A80#capwap ap restart
Warning: This CLI resets connection with WLC.
Do you want to continue? [confirm]

TEST#

I know that the the CAPWAP restart is not being triggered because I am watching the live logs of the AP, and also checking the CAPWAP uptime on the WLC. I would see the CAPWAP timer restart on the WLC, and the logs would display messages of a DTLS teardown.

Executing the commands manually by a regular SSH connection show the same output in the terminal… but the CAPWAP connection gets reset.

I’ve also tried to use Netmiko to reload the AP, which asks for a confirmation, just like the capwap restart command. Netmiko is failing to issue the confirmation in that case as well. Here’s what the attempt at reloading using Netmiko looks like in my Python interpreter:

>>> ap_shell = Netmiko(host=ip, username=AP_USER, password=AP_PASS, device_type='cisco_ios', secret=AP_PASS)
>>> ap_shell.enable()
'enable\r\nPassword: \r\n\rTEST#'
>>> 
>>> ap_shell.send_command("reload", expect_string=r'confirm')
'Proceed with reload? [confirm]'
>>> ap_shell.send_command('\n')
''
>>> 

I’ve also tried using write_channel('\n') instead of send_command('\n'). Neither method seems to work.

I read here in this blog post that:

Netmiko determines the current prompt by sending an ‘enter’ right before the command is sent.

… so I’ve also tried with auto_find_prompt=False. No different.

Any ideas how I can troubleshoot this further to figure out what’s going on? Or, do you see an obvious mistake that I overlooked?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ktbyerscommented, Feb 4, 2021

Does it work if for the last <enter> you do the following:

output = ap_shell.send_command(command_string=f"capwap ap restart", expect_string=r"confirm", strip_prompt=False, strip_command=False)
ap_shell.write_channel("\r\n")
time.sleep(1)
output += ap_shell.read_channel()

Also, you might want to add the session_log so we can see if we can figure out what is going on (of course, maybe you are already doing this):

ap_shell = Netmiko(host=ip, username=AP_USER, password=AP_PASS, device_type='cisco_ios', secret=AP_PASS, session_log="output.txt")

This will create a file named “output.txt” in your current directory.

Regards,

Kirk

0reactions
David00commented, Feb 4, 2021

Kirk,

That worked - thanks so much! Here’s the contents of output:

>>> print(output)
capwap ap restart
Warning: This CLI resets connection with WLC.
TEST#u want to continue? [confirm]
TEST#

Thanks for letting me know about session_log. I’ve been using Netmiko for awhile now (you had previously helped me with issue #1184), and I’ve never noticed the session_log. That will be helpful moving forward.

Do you know why that specific combination of \r\n with write_channel does the trick? I just tested with send_command('\r\n') and it does not work. I understand that write_channel is much lower level, but I don’t know what send_command is doing differently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Security Advisories, Responses and Notices - Cisco
Cisco Catalyst 9100 Series Access Points Association Request Denial of Service Vulnerability 28/Sep/2022New; Vulnerabilities in Layer 2 Network Security ...
Read more >
Cisco Catalyst 9100 Access Points - Troubleshooting TechNotes
Cisco Catalyst 9100AX Access Points - Some links below may open a new browser window to display the document you selected.
Read more >
Cisco Catalyst 9100 and Wi-Fi 6 (802.11ax) Customer FAQ
Yes, the Cisco Catalyst 9800 Series Wireless Controllers will be fully supported by both the Cisco Catalyst 9100 and existing 802.11ac access points....
Read more >
Cisco Catalyst 9100 Access Points
Cisco Catalyst 9100AX Access Points - Technical support documentation, downloads, tools and resources.
Read more >
Cisco Catalyst 9120 Access Point Deployment Guide
The Catalyst 9100 Series access points come with built-in security in the form of secure boot, runtime defenses, image signing, integrity verification, and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found