You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling get_environment() on our Juniper MX10003 throws a KeyError.
The error has been traced back to pem_name = pem[0].replace("PEM", "Power Supply"). I assume this was done because Junos returned "Power Suppply" in junos_environment_table and "PEM" in junos_pem_table. However, my box returns "PEM" in both, so replacing it causes the lookup error later.
Suggested fix is to also replace "PEM" with "Power Supply" on the name from the environment. This makes the lookup work and keeps the output consistent by always using the "Power Supply" naming:
for sensor_object, object_data in environment.items():
...
if structured_object_data["class"] == "Power":
sensor_object = sensor_object.replace("PEM", "Power Supply")
....
(Place an x between the square brackets where applicable)
Yes
No
Setup
napalm version
(Paste verbatim output from pip freeze | grep napalm between quotes below)
napalm==3.0.1
Network operating system version
(Paste verbatim output from show version - or equivalent - between quotes below)
Model: mx10003
Junos: 19.2R1.8
Steps to Reproduce the Issue
In [1]: import napalm
In [2]: driver = napalm.get_network_driver('junos')
In [3]: rtr = driver('10.x.y.z', 'sander', 'wouldntyouliketoknow')
In [4]: rtr.open()
In [5]: rtr.get_environment()
Error Traceback
(Paste the complete traceback of the exception between quotes below)
/opt/netbox-dev/venv/lib/python3.6/site-packages/napalm/junos/junos.py in get_environment(self)
527 environment_data["power"][pem_name]["capacity"] = pem_table[
528 pem_name
--> 529 ]["capacity"]
530 if pem_table[pem_name]["output"] is not None:
531 environment_data["power"][pem_name]["output"] = pem_table[pem_name][
KeyError: 'Power Supply 0'
The text was updated successfully, but these errors were encountered:
Description of Issue/Question
Calling
get_environment()
on our Juniper MX10003 throws aKeyError
.The error has been traced back to
pem_name = pem[0].replace("PEM", "Power Supply")
. I assume this was done because Junos returned "Power Suppply" injunos_environment_table
and "PEM" injunos_pem_table
. However, my box returns "PEM" in both, so replacing it causes the lookup error later.Suggested fix is to also replace "PEM" with "Power Supply" on the name from the environment. This makes the lookup work and keeps the output consistent by always using the "Power Supply" naming:
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
Error Traceback
(Paste the complete traceback of the exception between quotes below)
The text was updated successfully, but these errors were encountered: