Testing network reachability using ping and NAPALM
So far, in this chapter, we have only discussed how to connect to a device (please refer to the Connecting to devices from different vendors using NAPALM recipe) and then how to issue a command (please refer to the Issuing commands to a device using NAPALM recipe). What we have not looked at, so far, are the vendor-agnostic methods that we promised.
The device we obtain from the vendor-specific driver offers a variety of functions; so, in this example, we are going to use the ping()
function to test that our network device can reach a list of hosts.
Getting ready
Open your code editor and create a file called ping.py
. Next, in your Terminal, navigate to the same directory that you just created the ping.py
file in.
How to do it…
We will use the following steps to establish a connection with our network device. Then, we will use the ping()
method to test connectivity:
- Import the
napalm
module:import napalm...