NXOS support for getter commands

Hi all,

I’m new to automation and trying to start doing some scripts to get network stats using nornir/napalm. I’m trying to get ntp stats on my devices using real hardwares and gns3. I’m able to get ntp_stats on regular IOS box but was having issues with NXOS. I found that “get_ntp_stats” is not supported on NXOS_SSH getters support matrix. (https://napalm.readthedocs.io/en/latest/support/)

  1. Does any know if " get_ntp_stats" command and the rest below will be supported for NXOS_SSH anytime soon? If yes, any timeline when they will be supported? I was hoping i could use these for my requirements.
  • get_ntp_stats
  • get_bgp_config
  • get_bgp_neighbors_detail
  • get_interfaces_counters
  1. “get_bgp_neighbors” are supported for NXOS_SSH but the result is empty for both real hardware and gns3 nxosv. Any idea why? I’m not getting any error messages though.
  • NXOSV-GNS3 ** changed : False *****************************************************
    vvvv napalm_get ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
    {‘get_bgp_neighbors’: {}}
    ^^^^ END napalm_get ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • Nexus 9000** changed : False ***************************************
    vvvv napalm_get ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
    {‘get_bgp_neighbors’: {}}

Thanks in advance.

Can you share your code that fetches get_bgp_neighbors?

Here’s my code, after a few testings somehow it worked a bit for Nexus 9K but it seems a hit or miss. Sometimes i get a result sometimes get a traceback error. For Nexus 6K it just wont work in my environment and just gets an empty list. See below for the traceback error on the N9K:

from nornir import InitNornir
from nornir.plugins.functions.text import print_result
from nornir.plugins.tasks.networking import napalm_get

nr = InitNornir(
config_file=“configs.yaml”, dry_run=True
)

results = nr.run(
task=napalm_get, getters=[“bgp_neighbors”]
)

print_result(results)

Here’s my host file:

LAB-NXOS:
hostname: 10.x.x.x
port: 10022
username: xxxx
password: xxxxx
platform: ‘nxos_ssh’
groups:
- nxos_group

N9K:
hostname: 10.x.x.x
port: 22
username: xxxx
password: xxxxx
platform: ‘nxos_ssh’
groups:
- nxos_group

N6K:
hostname: 10.x.x.x
port: 22
username: xxxx
password: xxxxx
platform: ‘nxos_ssh’
groups:
- nxos_group

Traceback error for N9K

Traceback (most recent call last):
File “C:\Users\user1\AppData\Local\Programs\Python\Python37-32\lib\site-packages\nornir\core\task.py”, line 85, in start
r = self.task(self, **self.params)
File “C:\Users\user1\AppData\Local\Programs\Python\Python37-32\lib\site-packages\nornir\plugins\tasks\networking\napalm_get.py”, line 61, in napalm_get
result[g] = method(**options)
File “C:\Users\user1\AppData\Local\Programs\Python\Python37-32\lib\site-packages\napalm\ios\ios.py”, line 1787, in get_bgp_neighbors
afi = entry[“afi”].lower()
KeyError: ‘afi’

The code looks good to me. Can you test with the nxos platform instead of nxos_ssh? Here’s the NAPALM code that is executed, might help you track this down.