Exception handling in netmiko

When we design our Python script, we assume that the device is up and running and also that the user has provided the correct credentials, which is not always the case. Sometimes there's a network connectivity issue between Python and the remote device or the user enters the wrong credentials. Usually, python will throw an exception if this happens and will exit, which is not the optimum solution.

The exception handling module in netmiko, netmiko.ssh_exception, provides some exception classes that can handle such situations. The first one is AuthenticationException, and will catch the authentication errors in the remote device. The second class is NetMikoTimeoutException, which will catch timeouts or any connectivity ...

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.