Some Nexus models or NXOS versions have a different key for the power load. The function is expecting 'watts' but some switches return the key 'actual_out' instead.
I propose the following update to the _process_pdus() function in nxos.py
# Some models or versions return 'watts' as the key and others 'actual_out'
if psinfo.get("watts") != None:
normalized[psinfo["psnum"]]["output"] = float(psinfo.get("watts", -1.0))
else:
normalized[psinfo["psnum"]]["output"] = float(psinfo.get("actual_out", -1.0).split()[0])
(Place an x between the square brackets where applicable)
[x] Yes
[] No
Setup
napalm version
(Paste verbatim output from pip freeze | grep napalm between quotes below)
napalm==3.2.0
napalm-panos==0.5.2
Network operating system version
(Paste verbatim output from show version - or equivalent - between quotes below)
Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac
Documents: http://www.cisco.com/en/US/products/ps9372/tsd_products_support_series_home.html
Copyright (c) 2002-2019, Cisco Systems, Inc. All rights reserved.
The copyrights to certain works contained in this software are
owned by other third parties and used and distributed under
license. Certain components of this software are licensed under
the GNU General Public License (GPL) version 2.0 or the GNU
Lesser General Public License (LGPL) Version 2.1. A copy of each
such license is available at
http://www.opensource.org/licenses/gpl-2.0.php and
http://www.opensource.org/licenses/lgpl-2.1.php
Software
BIOS: version 2.12.0
kickstart: version 7.3(5)D1(1)
system: version 7.3(5)D1(1)
BIOS compile time: 05/29/2013
kickstart image file is: bootflash:///n7000-s2-kickstart.7.3.5.D1.1.bin
kickstart compile time: 9/30/2019 21:00:00 [11/09/2019 05:55:30]
system image file is: bootflash:///n7000-s2-dk9.7.3.5.D1.1.bin
system compile time: 9/30/2019 21:00:00 [11/09/2019 08:12:42]
Hardware
cisco Nexus7000 C7004 (4 Slot) Chassis ("Supervisor Module-2")
Intel(R) Xeon(R) CPU with 32940104 kB of memory.
Processor Board ID Jxxx
Device name: my_router
bootflash: 1966080 kB
slot0: 0 kB (expansion flash)
Kernel uptime is 352 day(s), 7 hour(s), 13 minute(s), 16 second(s)
Last reset at 966994 usecs after Tue Feb 25 09:19:35 2020
Reason: Reset due to upgrade
System version: 7.3(3)D1(1)
Service:
plugin
Core Plugin, Ethernet Plugin
Active Package(s)
Steps to Reproduce the Issue
The output is shown as -1 from the following command
'''
salt my_router napalm.call get_environment
my_router:
Description of Issue/Question
Some Nexus models or NXOS versions have a different key for the power load. The function is expecting 'watts' but some switches return the key 'actual_out' instead.
I propose the following update to the _process_pdus() function in nxos.py
''' < normalized[psinfo["psnum"]]["output"] = float(psinfo.get("watts", -1.0))
Did you follow the steps from https://github.com/napalm-automation/napalm#faq
(Place an
x
between the square brackets where applicable)Setup
napalm version
(Paste verbatim output from
pip freeze | grep napalm
between quotes below)Network operating system version
(Paste verbatim output from
show version
- or equivalent - between quotes below)Steps to Reproduce the Issue
The output is shown as -1 from the following command
''' salt my_router napalm.call get_environment my_router:
'''
Here is what you get from the rpc call:
''' salt sb1agrt732 napalm.nxos_apirpc 'show environment' sb1agrt732: |