Coder Social home page Coder Social logo

napalm-automation-community / napalm-huawei-vrp Goto Github PK

View Code? Open in Web Editor NEW
74.0 7.0 25.0 149 KB

NAPALM Driver for Huawei VRP5/VRP8 Routers and Switches

License: Apache License 2.0

Python 100.00%
napalm huawei automation netmiko vrp network-automation ansible python

napalm-huawei-vrp's People

Contributors

angely-dev avatar codingnetworksb avatar dependabot[bot] avatar prin-meng avatar tkspuk avatar zhuyuehui1993 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

napalm-huawei-vrp's Issues

Error running device.get_mac_address_table()

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.

raise ConnectionException("Cannot connect to {}".format(self.hostname))

交换机管理口已经配置了管理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

请问大佬是什么问题

Problem with S2700 models

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?

Unexpected output data

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

get_lldp_neighbors_detail

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 :)

get_lldp_neighbor

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" :)

I'm Interested on becoming a Maintainer of napalm-huawei-vrp

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

Huawei S7706 get_config() failed

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:

  1. Explicitly set your pattern using the expect_string argument.
  2. Increase the read_timeout to a larger value.
    You can also look at the Netmiko session_log or debug log for more information._"

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?

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.

A misprint in open method

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

Does you guys have huawei device in the internet?

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.

This code has a problem with routers that have tow cfcards while saving file in commit object

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.