Netbox / Napalm Status tab not working

1,114 views
Skip to first unread message

Wes Hegge

unread,
May 22, 2018, 4:17:31 PM5/22/18
to NetBox
Hello,

Running Netbox 2.3.2 with Napalm 2.3.0.  I have the Napalm driver set to nxos_ssh for the Cisco Nexus switch.  When I click on the different tabs to get information on the Cisco device this is what happens.

Status - Does NOT Work, fails with the following error: {"detail":"Error connecting to the device at 10.220.164.31: "}
LLDP Neighbors - Works
Configuration - Works

I have raised the timeouts both in Gunicorn and Apache to 60 seconds and restarted Apache and Netbox, but that did not help.  If I use Napalm via Python cli and do get_facts I get information back.  I am assuming the Status tab is trying to execute get_facts.   Is that true?

Any ideas?

Thanks,

Wes Hegge

Jeremy Stretch

unread,
May 22, 2018, 4:27:35 PM5/22/18
to Wes Hegge, NetBox
The status tab calls both get_facts() and get_environment(), the later of which can be hit-or-miss on different platforms. What happens when you call get_environment() on the device via CLI?

Jeremy

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to netbox-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/ad08e1a5-7a38-4c86-8c97-e04c16709557%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wes Hegge

unread,
May 22, 2018, 5:29:22 PM5/22/18
to NetBox
Looks like get_environment() is not there.

>>> driver = napalm.get_network_driver('nxos_ssh')
>>> device = driver(hostname='10.220.164.31', username='......', password='......')
>>> device.open()
>>> device.get_environment()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/napalm/base/base.py", line 405, in get_environment
    raise NotImplementedError
NotImplementedError
>>> device.get_facts()
{'uptime': 21004921, 'vendor': 'Cisco', 'os_version': '6.0(2)A7(2)', 'serial_number': 'FOC204303LG', 'model': 'Nexus', 'hostname': 'CHCGIL3K1-IPTV', 'fqdn': '', 'interface_list': ['Eth1/1', 'Eth1/2', 'Eth1/3', 'Eth1/4', 'Eth1/5', 'Eth1/6', 'Eth1/7', 'Eth1/8', 'Eth1/9', 'Eth1/10', 'Eth1/11', 'Eth1/12', 'Eth1/13', 'Eth1/14', 'Eth1/15', 'Eth1/16', 'Eth1/17', 'Eth1/18', 'Eth1/19', 'Eth1/20', 'Eth1/21', 'Eth1/22', 'Eth1/23', 'Eth1/24', 'Eth1/25', 'Eth1/26', 'Eth1/27', 'Eth1/28', 'Eth1/29', 'Eth1/30', 'Eth1/31', 'Eth1/32', 'Eth1/33', 'Eth1/34', 'Eth1/35', 'Eth1/36', 'Eth1/37', 'Eth1/38', 'Eth1/39', 'Eth1/40', 'Eth1/41', 'Eth1/42', 'Eth1/43', 'Eth1/44', 'Eth1/45', 'Eth1/46', 'Eth1/47', 'Eth1/48', 'mgmt0', 'Lo0']}

There is no get_environment in /usr/lib/python3.6/site-packages/napalm/nxos_ssh/nxos_ssh.py file.

Suggestion: Have Netbox check if the get_environment function returns anything, if not don't error out just display the get_facts info.

Thanks,

Wes




On Tuesday, May 22, 2018 at 3:27:35 PM UTC-5, Jeremy Stretch wrote:
The status tab calls both get_facts() and get_environment(), the later of which can be hit-or-miss on different platforms. What happens when you call get_environment() on the device via CLI?

Jeremy
On Tue, May 22, 2018 at 4:17 PM, Wes Hegge <whe...@gmail.com> wrote:
Hello,

Running Netbox 2.3.2 with Napalm 2.3.0.  I have the Napalm driver set to nxos_ssh for the Cisco Nexus switch.  When I click on the different tabs to get information on the Cisco device this is what happens.

Status - Does NOT Work, fails with the following error: {"detail":"Error connecting to the device at 10.220.164.31: "}
LLDP Neighbors - Works
Configuration - Works

I have raised the timeouts both in Gunicorn and Apache to 60 seconds and restarted Apache and Netbox, but that did not help.  If I use Napalm via Python cli and do get_facts I get information back.  I am assuming the Status tab is trying to execute get_facts.   Is that true?

Any ideas?

Thanks,

Wes Hegge

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To post to this group, send email to netbox-...@googlegroups.com.

Wes Hegge

unread,
May 31, 2018, 8:50:19 PM5/31/18
to NetBox
Here is what I did to "Fix" this issue.   I plan on implementing the function fully but for now this at least stops the error from appearing.

I created a dummy "get_environment" function based off the IOS driver.  I placed this function just before the "get_facts" definition.

This is on a CentOS 7 server with Python 3.6 and using the nxos_ssh driver.  This should also work for nxos in /usr/lib/python3.6/site-packages/napalm/nxos/nxos.py

vi /usr/lib/python3.6/site-packages/napalm/nxos_ssh/nxos_ssh.py

    def get_environment(self):
        """
        Get environment facts.

        Place holder for this function so netbox will not return an error
        when selecting Status tab on devices
        """
        environment = {}

        environment.setdefault('cpu', {})
        environment.setdefault('memory', {})
        environment.setdefault('temperature', {})
        environment.setdefault('power', {})
        environment['power']['invalid'] = {'status': True, 'output': -1.0, 'capacity': -1.0}
        environment.setdefault('fans', {})
        environment['fans']['invalid'] = {'status': True}

        return environment

Wes
Reply all
Reply to author
Forward
0 new messages