napalm-automation / napalm

Network Automation and Programmability Abstraction Layer with Multivendor support
Apache License 2.0
2.23k stars 549 forks source link

Inconsistent ping behavior across platforms #946

Open madhurabhogate opened 5 years ago

madhurabhogate commented 5 years ago

I was trying to use the ping function. Incase of Juniper, I do get the error output as -


{'error': 'cannot resolve foo: Host name lookup failure'}
>>> junos.ping('1.1.1.1')
{'error': 'Packet loss 100'}```

I tried this on Arista -
```>>> eos.ping('1.1.1.1', count = 1)
{'success': {'probes_sent': 1, 'packet_loss': 1, 'rtt_min': 0.0, 'rtt_max': 0.0, 'rtt_avg': 0.0, 'rtt_stddev': 0.0, 'results': []}}
>>> eos.ping('1.1.1.9', count = 1)
{'success': {'probes_sent': 1, 'packet_loss': 1, 'rtt_min': 0.0, 'rtt_max': 0.0, 'rtt_avg': 0.0, 'rtt_stddev': 0.0, 'results': []}}
>>> eos.ping('www.sdfsf', count = 1)
{}
>>> eos.ping('google', count = 1)
{}
>>> eos.ping('www.google.com', count = 1)
{}
>>> eos.ping('foo', count = 1)
{}```

The output seems inconsistent between different platforms.
madhurabhogate commented 5 years ago

I digged in a little bit more.

In case of Juniper- (scenario -----> output)

  1. When the Host is unreachable ---> {'error': 'Packet loss 100'}
  2. When the host is unknown ---> {'error': 'cannot resolve foo: Host name lookup failure'}

In case of Arista: Host unreachable : it gives success and says packet loss == probes sent. We could have it throw an error as Juniper does.

Unknown host : the cli output on arista box is arista#ping foo ping: unknown host foo

The eos.py checky for "connect: " string https://github.com/napalm-automation/napalm/blob/develop/napalm/eos/eos.py#L1862

but there is no such string + nor there is "PING" in the string and hence returns an {}.

So two fixes for Arista --

  1. For 100% packet loss it should return {'error': 'Packet loss 100'}
  2. For host unreachable or other output: {'error': 'ping: unknown host foo'}