scrapli / scrapli_community

scrapli community platforms
https://scrapli.github.io/scrapli_community/
MIT License
86 stars 26 forks source link

Mikrotik Identity can contains spaces #20

Closed ravenich closed 4 years ago

ravenich commented 4 years ago

If Identity (router name) on mikrotik contain space scrapli raise TimeOut exception SSH on the router: [ravenich@ravenich] > /sys identity set name="Test Router" [ravenich@Test Router] > Scrapli exception: scrapli.exceptions.ScrapliTimeout: Timed out determining if session is authenticated I'm not a regexp expert, but i think a simple space in "comms_prompt_pattern" fix the situation. I'm just begin my work with python and simply don't know how to add a PR.

Also mikrotik have a safe mode, it enabled by Ctrl-X, but that string matches with regexp: [ravenich@Test Router] > [Safe Mode taken] [ravenich@Test Router] <SAFE>

carlmontanari commented 4 years ago

Hey @ravenich thanks for opening this!

Sounds like you're probably bang on with the space. I can probably get that fixed up this weekend and/or tagging @AlexLardschneider here too if he is interested/has time to take a peak.

What is this safe mode thing all about? I have effectively zero mikrotik experience so if you could ELI5 that'd be dope :)

Thanks! Carl

carlmontanari commented 4 years ago

@ravenich sorry for delay. added a space to the mikrotik prompt pattern and added a test to make sure we dont regress on that. Given that I dont have a mikrotik router to test im just going to assume it is good to go :) If you could test the develop branch and let us know if its working that would be great.

Regarding the safe mode -- should this be matched or are you saying we would not want to match it? If we dont want to we can just add a negative lookahead like we do for the Arista prompt: pattern=r"^((?!config)[a-z0-9.\-@()/: ]){1,63}#\s?$"

Let us know what ya think!

Carl

ravenich commented 4 years ago

@carlmontanari Thanks, now it works. `with Scrapli(**my_device) as conn: print(conn.get_prompt())

[ravenich@ravenich router] >`

*If you want you can try mikrotik CHR. It is a virtual image for hypervisors, have speed limitations on free version but no feature limits.

About safe mode - i think this pattern is fine. User can use some kind of expression to verify safe mode by the get_prompt function.

carlmontanari commented 4 years ago

@ravenich sounds good! I'll go ahead and close this then. Will hopefully merge to master and make a new release soonish as I know there were a few minor mixups that @AlexLardschneider just got pushed in recently as well. Thanks for opening this!

Carl