Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Prompt pattern matches where it should NOT #54

Open
gbieli opened this issue Dec 10, 2020 · 1 comment
Open

Prompt pattern matches where it should NOT #54

gbieli opened this issue Dec 10, 2020 · 1 comment

Comments

@gbieli
Copy link

gbieli commented Dec 10, 2020

Describe the bug

Prompt pattern brn\-boll111\-.*?(\(.*?\))?[\>|\#] matches in show interfaces description on an interface that has brn-boll111-ap-02 Gi0 <LS:LIR> in its description.

General Information

OS:
RHEL7, python3.6

Netdev version:
asyncssh==1.18.0
netdev==0.9.3

Device OS:
Cisco IOS XE Software, Version 16.12.03s
C9300

Debug information

[2020-12-10 10:30:09,152 DEBUG base.py:388 - _read_until_prompt_or_pattern() pn:MainProcess pid:31799 t:MainThread ] Host <SNIP>: Reading pattern 'brn\-boll111\-.*?(\(.*?\))?[\>|\#]' or 'brn\-boll111\-.*?(\(.*?\))?[\>|\#]' was found: 'show interfaces description\r\nInterface Status Protocol Description\r\nVl1 up up not used <LS:C>\r\n<SNIP> <LS:CV>\r\nTe3/0/20 down down Access-Port with 802.1x - lan <LS:CV>\r\nTe3/0/21 down down Access-Port with 802.1x - lan <LS:CV>\r\nTe3/0/22 down down Access-Port with 802.1x - lan <LS:CV>\r\nTe3/0/23 up up Fabric Physical Link - brn-boll111-ap-02 Gi0 <LS:LIR>\r\nTe3/0/24 up up Fabric Physical Link - brn-boll111-ap-02 Gi0 <LS:LIR>\r\nGi3/1/1 admin down down not used <LS:C>\r\nGi3/1/2 admin down down not used <LS:C>\r\nGi3/1/3 admin down down not used <LS:C>\r\nGi3/1/4 admin down down not used <LS:C>\r\nTe3'

Additional context

Any ideas for a quick fix until the problem can be solved permanently?

@gbieli
Copy link
Author

gbieli commented Dec 10, 2020

I think I found the issue. In the code only the first 12 characters from the base prompt are being used for the pattern. Our hostname has 18 characters. I fixed the issue as follows.

netdev/vendors/base.py - line 172:
_pattern = r"{prompt}.*?(\(.*?\))?[{delimiters}]"

changed to

_pattern = r"{prompt}(\(.*?\))?[{delimiters}]"

AND

netdev/vendors/base.py - line 252:
base_prompt = re.escape(self._base_prompt[:12])

changed to

base_prompt = re.escape(self._base_prompt)

Now it works without problems.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant