napalm-automation-community / napalm-huawei-vrp Goto Github PK
View Code? Open in Web Editor NEWNAPALM Driver for Huawei VRP5/VRP8 Routers and Switches
License: Apache License 2.0
NAPALM Driver for Huawei VRP5/VRP8 Routers and Switches
License: Apache License 2.0
Hi,
Thank you for the update last week.
When I use the following function, I receive a stack trace:
device.get_mac_address_table()
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 978, in get_mac_address_table
"mac": mac(mac_info[0]),
^^^^^^^^^^^^^^^^
File "/opt/netbox-3.7.4/venv/lib/python3.11/site-packages/napalm/base/helpers.py", line 521, in mac
return str(EUI(raw, dialect=_MACFormat))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-3.7.4/venv/lib/python3.11/site-packages/netaddr/eui/__init__.py", line 374, in __init__
self.value = addr
^^^^^^^^^^
File "/opt/netbox-3.7.4/venv/lib/python3.11/site-packages/netaddr/eui/__init__.py", line 422, in _set_value
raise AddrFormatError('failed to detect EUI version: %r' % (value,))
netaddr.core.AddrFormatError: failed to detect EUI version: 'seconds'
Device: Cloudengine 6855
OS: VRP (R) software, Version 8.180
pip list:
...
netmiko 4.3.0
napalm 4.1.0
napalm-huawei-vrp 1.2.0
netbox_napalm_plugin 0.1.7
Using a switch that has been factory reset and only the basics of SSH configured.
I can run all other 'Get info' commands succesfully.
Seems very related to: napalm-automation-community/napalm-ftos#2
Please do let me know if I can help troubleshoot further.
交换机管理口已经配置了管理ip
[HUAWEI-MEth0/0/1]di th
interface MEth0/0/1
ip address 192.168.1.248 255.255.255.0
return
终端报错
C:\Users\Administrator>ping 192.168.1.248
正在 Ping 192.168.1.248 具有 32 字节的数据:
来自 192.168.1.248 的回复: 字节=32 时间<1ms TTL=255
来自 192.168.1.248 的回复: 字节=32 时间=2ms TTL=255
来自 192.168.1.248 的回复: 字节=32 时间<1ms TTL=255
来自 192.168.1.248 的回复: 字节=32 时间<1ms TTL=255
192.168.1.248 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 2ms,平均 = 0ms
C:\Users\Administrator>python
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
from napalm import get_network_driver
driver = get_network_driver('huawei_vrp')
device = driver(hostname='192.168.1.248', username='admin', password='[email protected]')
device.open()
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\napalm_huawei_vrp\huawei_vrp.py", line 128, in open
device_type, netmiko_optional_args=self.netmiko_optional_args
File "C:\Python27\lib\site-packages\napalm\base\base.py", line 99, in _netmiko_open
raise ConnectionException("Cannot connect to {}".format(self.hostname))
napalm.base.exceptions.ConnectionException: Cannot connect to 192.168.1.248
请问大佬是什么问题
Hello,
I would like to know against what models you are testing the driver. I could help you to test it with S2700, S7700, S7703, NE40E-X8, NE40E-X3.
I did not see this driver before and I developed one that fit my needs. mainly for S2700 to get info needed in netbox.
I tried this one but I could not get the info expected in netbox (get_facts mainly, like uptime, model version or serial number)
are you planning to upgrade to the newest napalm driver model and dependencies?
Facing issue: Unexpected output data: [" ^\nError: Unrecognized command found at '^' position."] I hope issue is my device have super mode password, passed secret optional value still facing same issue
def get_lldp_neighbors_detail(self):
results = {}
command = 'display lldp neighbor brief'
output = self.device.send_command(command)
lines = output.split("\n")
for line in lines:
# translate Huawai
skip_lines = ['local', '-----']
local_iface = line[:14].strip()
remote_port = line[39:65].strip().replace(" ", "")
remote_system_name = line[14:39].strip()
local_iface = local_iface.replace("XGE", "XGigabitEthernet")
remote_port = remote_port.replace("XGE", "XGigabitEthernet")
if local_iface[:5].lower() not in skip_lines:
if local_iface not in results:
results[local_iface] = []
neighbor_dict = dict()
neighbor_dict['remote_port'] = py23_compat.text_type(remote_port)
neighbor_dict['remote_system_name'] = py23_compat.text_type(remote_system_name)
results[local_iface].append(neighbor_dict)
return results
this is working for 10gig interfaces in NetBox.. i have no gig nor 40/100 gig interfaces active to test against.. is suspect that the replace statement needs to be expanded tot get them equal to the names in the config.
I wrote this as a start for use in netbox only..so see it as a partial implementation
If you need me to test on a couple of VRP devices i am glad to help out.. i am in no way a python developer :)
I saw you marked this method as #ok but its not..
the regex is for a CE and not working correctly on VRP
you could use the fixed width method as i used for the get_lldp_neighbor_detail or with a new regex.
i didnt rewrite it because netbox is not using this mehtod.
---Actual CE output----
<cr1-somecity-randomdc7>display lldp neighbor brief
Local Interface Exptime(s) Neighbor Interface Neighbor Device
-------------------------------------------------------------------------------
10GE1/0/1 113 Gi7/1 cr1-somecity-randomdc2.domain.tld
10GE1/0/45 106 XGigabitEthernet0/0/43 cr2-somecity-randomdc2
10GE1/0/46 100 10GE1/0/47 cr1-somecity-randomdc3
10GE1/0/47 110 XGigabitEthernet0/0/4 cr2-somecity-randomdc5
10GE1/0/48 102 Gi3/15 cr1-somecity-randomdc2.domain.tld
10GE1/0/48 109 Gi3/15.2375 cr1-somecity-randomdc2.domain.tld
10GE1/0/48 119 Gi1/14.2271 cr1-somecity-randomdc5.domain.tld
10GE1/0/48 91 Gi1/14.2266 cr1-somecity-randomdc5.domain.tld
10GE1/0/48 105 Gi1/14.2270 cr1-somecity-randomdc5.domain.tld
10GE1/0/48 112 Gi1/14.2267 cr1-somecity-randomdc5.domain.tld
10GE1/0/48 108 Gi1/14.2263 cr1-somecity-randomdc5.domain.tld
---Actual vrp output------
<pek-cr2-cis-sik>display lldp neighbor brief
Local Intf Neighbor Dev Neighbor Intf Exptime(s)
XGE0/0/1 PEK-N5000 Eth1/13 118
XGE0/0/3 ASW17-sikpek Eth 0/2 117
XGE0/0/4 pek-cr1-cis-sik.as999... Te5/2 91
XGE0/0/24 pek-cr1-ren-bat.as999... Gi4/4.1170 95
XGE0/0/24 pek-cr1-ren-bat.as999... Gi4/4.1176 101
XGE0/0/34 atopsw2pek XGE0/0/2 118
XGE0/0/37 pek-sw1-cis-sik XGE0/0/1 119
XGE0/0/48 pek-cr1-cis-sik.as999... Te5/4 105
Mind, the "Eth 0/2" is screwing up my regex skills so i resorted to fixed witdh" :)
Hi @tkspuk
I'm writing because i'm very interested on becoming a maintainer of this repository. I have used this driver in a project and developed multiple methods to add support for other Huawei devices, routers specifically: NE40E-X2, NE40E-X16, NE8000 and ATN 910C.
I know i can simply make pull request and wait for your approval, but i want to be an active contributor adding codes and reviewing others people Pull requests and issues.
Regards
Hello !
I have 2 switches S7706,
and I'm attempting to perform a get_config() operation using napalm.
On one of the switches, the process is not completing and results is:
"_Pattern not detected: '<Switch\-S7706\-core>' in output.
Things you might try to fix this:
I have tried every combination of optional_args (without any success):
global_delay_factor, fast_cli, timeout, conn_timeout, session_timeout.
With cli, using SSH, I don't have any problem.
I also mention that get_facts(), works as expected.
I am using:
Python 3.11.2
Netmiko 4.2.0
Napalm 4.1.0
The following script also fails:
napalm --vendor huawei_vrp --user username --password secret --optional_args 'port=22, global_delay_factor=2, read_timeout_override=30.0' 10.10.10.10 call get_config
What do you think might be causing this, and what else can I try?
In the new Napalm version py23compat is no longer available.
Crashing the vrp driver.
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.
You have a misprint in open method. At line 126 you wrote - "huawei_telent" instead of "huawei_telnet". It entails an error when you try to use telnet connection instead ssh
I wanna contribute my effort to upgrade the Huawei driver continually.
The network devices that i can connect to are in the company's inner network.
It's will be helpful that you guys provide the Huawei device, thanks.
I have been using Napalm to develop the Network Automation Project in our company since 2018.
In routers that have 2 cfcards, saving files need to save in slave cards also. So when I want to use the device.commit_config() API, because it trying to save a file into cfcard the router ask an extra question to save the file to slave cfcard:
<BRKSAB_KS0006>save config_20221004_1026.cfg
Warning: Are you sure to save the configuration to cfcard:/config_20221004_1026.cfg? [Y/N]:
By the “y” command that will be sent to the node using “_save_config(self)” function the node goes to the next step, so the situation will be like below:
Warning: cfcard:/config_20221004_1026.cfg exists,overwrite? [Y/N]:y
Now saving the current configuration to the slot 11 .
Info: Save the configuration successfully.
Warning: Are you sure to save the configuration to slave#cfcard:/config_20221004_1026.cfg? [Y/N]:
But in the last line, the node asks to save the file into slave cfcard, but the code doesn’t have an answer for this question. So that it senses an error. In continue we can see the _save_config(self) code:
def _save_config(self, filename=''):
"""Save the current running config to the given file."""
command = 'save {}'.format(filename)
save_log = self.device.send_command(command, max_loops=10, expect_string=r'Y/N')
# Search pattern will not be detected when set a new hostname, so don't use auto_find_prompt=False
save_log += self.device.send_command('y', expect_string=r'<.+>')
search_result = re.search("successfully", save_log, re.M)
if search_result is None:
msg = "Failed to save config. Command output:{}".format(save_log)
raise CommandErrorException(msg)
I have been trying to add change the function code to like below, but it doesn’t work while it seems true:
def _save_config(self, filename=''):
"""Save the current running config to the given file."""
command = 'save {}'.format(filename)
save_log = self.device.send_command(command, max_loops=10, expect_string=r'Y/N')
# Search pattern will not be detected when set a new hostname, so don't use auto_find_prompt=False
save_log += self.device.send_command('y', expect_string=r'Info:')
savecfcard = re.search(“save the configuration to slave#cfcard” , )
if savecfcard == True:
save_log += self.device.send_command('y', expect_string=r'<.+>')
search_result = re.search("successfully", save_log, re.M)
if search_result is None:
msg = "Failed to save config. Command output:{}".format(save_log)
raise CommandErrorException(msg)
Would you help me please to solve this problem?
There is a problem with the value of description. If the description is empty, the retrieved values are all'Switch Port, Link-type: trunk(configured)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.