09-03-2025 11:11 AM
Hi Guys,
I have to write a Python function to launch a file copy using ftp on IOSXE (no PyATS API available for this ... with vrf option).
So I discovered Unicon, the execute API, the reply/dialog option to validate expected questions from the CLI and the error_pattern option to detect errors returned by the IOS.
I find myself trying to guess the expected errors that could from a "copy ftp://..." command.
I simulated several errors and so far I wrote the following error_pattern:
out = device.execute(cmd,reply=dialog, timeout=timeout, error_pattern=['^%Error', '^% Unable', '% Invalid'])
Anyway I'm not sure I have listed all error patterns that could come up from such a command.
Are you aware of some "standard" error_pattern that would gather all kind of errors generated by the CLI of the IOSXE ?
BR, Damien.
09-04-2025 02:42 AM
@dbillon is this the execute command mentioned here in your other thread? https://community.cisco.com/t5/tools/pyats-api-to-scp-from-the-pyats-client-to-a-device/td-p/5325825/jump-to/first-unread-message
I see the problem you mentioned, from what i recall the reasons a single standards errors pattern does not exist is that different XE commands, and even different versions of XE, can produce a wide variety of fun (sometime confusing) error messages in your logs. Yuo have already build something great here to catch the common errors, there is few more to add, timeout, fail, refused etc.. I would use raw strings for best pratice when bulding something like this. If you wanted to get a lot more you could add %.*?%
- but, this might be an informational or warning message that doesn't indicate a problem/failure.
Logging is tricky, getting the balance of helpful and where there is a problem, versus false flags and making lots of noise with verbose logging ...
Hope this helps.
09-04-2025 05:11 AM
Yes, I'm investing the same question with a different approach:
Actually I read that several "Dialog patterns" have been collected in Unicon doc ... so I thought I would have found some generic error pattern too. But nothing so far.
One thing puzzles me : when I read for example the function "copy_file_with_scp" from Genie API (on Github), I don't see how they catch any error since they are not using error_pattern:
out = device.execute(cmd,reply=dialog, timeout=timeout)
BR, Damien.
09-04-2025 05:25 AM
Ok did not want to cross post or think your other issue you asked about, we resolved.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide