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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access