Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix regex in plugins/terminal/iosxr.py #54817

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
2 participants
@liviozanol
Copy link

liviozanol commented Apr 3, 2019

Fixes a bug where in some situations you can get a timeout on iosxr devices due to bad regexp.

SUMMARY

Fixes situations where iosxr terminals that do not contain new line "/r/n" at the beginning of CLI timeouts due to regex error. Just make "/r/n" optional including "*" character in the regex

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

terminal/iosxr.py

ADDITIONAL INFORMATION

The current regexp require that the router returns new line (/r/n) after authentication. Not every router returns this, which causes timeout while waiting for this regex.

You should either make newline as optional or add another regexp in the code without the newline.

Ex: re.compile(br"[\w+-.:/[]]+(?:([^)]+)){,3}(?:>|#) ?$"),

Router examples that works on current regexp:

ssh 127.0.0.1
liviozanol@127.0.0.1's password:
Last switch-over Wed Mar 28 17:49:02 2018: 1 year, 5 days, 22 hours, 48 minutes ago

RP/0/RSP0/CPU0:ROUTER#

-------

ssh 127.0.0.1
liviozanol@127.0.0.1's password:

RP/0/RSP0/CPU0:ROUTER#

Router example that DO NOT works on current regexp:

ssh 127.0.0.1
liviozanol@127.0.0.1's password:
RP/0/RSP0/CPU0:ROUTER#

Can be verified at: https://pythex.org/

[kind off-topic below]
Also, I really don't understand why the regexp's needs to be so complicated. I've read a some issues regarding regexp on ios, iosxr and nxos. Can't it be more simple? If we could know the reason why its so complicated maybe we could sugest some change.

This kind of error (regex not matched) should really raise an specific message to the user, since its VERY difficult to troubleshoot with a simple timeout error. Maybe you should raise a message in network_cli.py near if errored_response or at socket timeout on ansible_connection

fix regex in plugins/terminal/iosxr.py
Fixes situations where iosxr terminals that do not contain new line "/r/n" at the beginning of CLI timeouts due to regex error. Just make "/r/n" optional including "*" character in the regex
@ansibot

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.