napalm-huawei-vrp
napalm-huawei-vrp copied to clipboard
Error Fetching Device Environment Data
Hi,
In the Netbox web-interface when going to the Status window of my device, I get the following error:
Error Fetching Device Environment Data
Method get_environment failed: 'NoneType' object has no attribute 'group'
The Status window has partially filled in information. Below "Device Facts", everything is filled except for: FQDN, Model and OS Version. These 3 fields have as value "unknown". Below "Environment" no information is filled.
Running Netbox locally I get the following result:
python3 manage.py runserver 0.0.0.0:8000 --insecure
[12/Apr/2024 08:39:32] "GET /dcim/devices/2/status/ HTTP/1.1" 200 105075
Connected (version 2.0, client -)
Authentication (password) successful!
[12/Apr/2024 08:39:39] "GET /api/plugins/netbox_napalm_plugin/napalmplatformconfig/2/napalm/?method=get_facts&method=get_environment HTTP/1.1" 200 1014
Running the following, I get a stack-trace:
>>> device.get_environment()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/netbox-3.7.4/venv/lib/python3.11/site-packages/napalm_huawei_vrp/huawei_vrp.py", line 397, in get_environment
environment["cpu"] = {"0": {"usage": cpu_use.group(1)}}
^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'
File /opt/netbox-3.7.4/venv/lib/python3.11/site-packages/napalm_huawei_vrp/huawei_vrp.py contains the following code:
fan_output = self.device.send_command(fan_cmd)
power_cmd = self.device.send_command(power_cmd)
temp_cmd = self.device.send_command(temp_cmd)
cpu_cmd = self.device.send_command(cpu_cmd)
mem_cmd = self.device.send_command(mem_cmd)
fan_cmd = "display fan"
power_cmd = "display power"
temp_cmd = "display temperature all"
cpu_cmd = "display cpu-usage"
mem_cmd = "display memory-usage"
None of the display commands listed above, exist on my Huawei Cloudengine. However, I do have the "display health" command, that displays the same information but sorted differently.
<MYDEVICE>display health
Power:
----------------------------------------------------------------------------------
Slot PowerNo Present Mode State Current Voltage ActualPower RatedPower
(Ampere) (Volt) (Watts) (Watts)
----------------------------------------------------------------------------------
1 PWR1 YES AC Supply 7.6 12.1 92 600
PWR2 YES N/A NotSupply 0.0 0.0 0 600
----------------------------------------------------------------------------------
N/A:Power not available
internal fan info:
----------------------------------------------
Slot PowerNo FanExist Airflow Direction
----------------------------------------------
1 PWR1 YES Front-to-Back
PWR2 YES Front-to-Back
----------------------------------------------
N/A:Fan not available
Fan:
fan module:
---------------------------------------------------------------------------------
Slot FanID FanNum Status Speed Mode Airflow Direction
---------------------------------------------------------------------------------
1 FAN1 [1-4] Normal 40%(7075) Auto Front-to-Back
1 6800
2 7300
3 6800
4 7400
FAN2 [1-4] Normal 40%(7075) Auto Front-to-Back
1 6900
2 7300
3 6800
4 7300
---------------------------------------------------------------------------------
N/A:Fan not available
Temperature:
---------------------------------------------------------------------------------
Slot Card SensorName Status Major Fatal Current
(Celsius) (Celsius) (Celsius)
---------------------------------------------------------------------------------
1 -- Outlet-1(LSW) NORMAL 69 -- 29
-- Intake-1(LSW) NORMAL 75 -- 26
-- CPU NORMAL 95 100 32
-- LSW NORMAL 110 110 33
---------------------------------------------------------------------------------
System Memory Usage Information:
System Memory Usage at 2024-04-12 08:52:30
----------------------------------------------------------------------------
Slot Total Memory(MB) Used Memory(MB) Used Percentage Upper Limit
----------------------------------------------------------------------------
1 1913 1054 55% 95%
----------------------------------------------------------------------------
System CPU Usage Information:
System CPU Usage at 2024-04-12 08:52:30
--------------------------------------
Slot CPU Usage Upper Limit
--------------------------------------
1 18% 90%
--------------------------------------
System Disk Usage Information:
System Disk Usage at 2024-04-12 08:52:30
------------------------------------------------------------------------
Slot Device Total Memory(MB) Used Memory(MB) Used Percentage
------------------------------------------------------------------------
1 flash: 615 455 73%
------------------------------------------------------------------------
I have tried the 5 display commands on 2 Cloudengines running VRP "Version 8.180" (2018) and "Version 8.191" (2020) respectively.
In short, I think the ""def get_environment(self)" function should be modified to use the results of "display health" instead.
Thank you for your continued development.