ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.49k stars 1.26k forks source link

Improvement for Huawei SmartAX #3401

Open evilmonkey19 opened 3 months ago

evilmonkey19 commented 3 months ago

Description of Issue/Question

At least, in most of the current huawei smartax versions there is the possibility of using the command mmi-mode enable for doing machine-to-machine communications (what netmiko does). I suggest to enable the possibility to use this command to improve the performance and the robustness of the Huawei smartax driver. I will dig and come up with factual data of how does it improves the current implementation.

As well, the robustness is something which the current implementation lacks of in certain cases. For instance, if there is a command for which you don't have enough permissions, it gives an error. To further clarify, if you try to use for example display ont info 0/0/0 and you don't have the enough permissions to use this command, the current implementation doesn't work.

However, there is a downside (as always) to use this command. It can only be used when config can be used by the user in the OLT. This means that it will not be a one-ring fits everything mode. I will explore how much it improves when enabled.

Setup

Python 3.11

Netmiko version

Netmiko 4.3.0

Netmiko device_type (if relevant to the issue)

huawei_smartax

This issue is related to #1929 & #1628

evilmonkey19 commented 3 months ago

May I ask for suggestion on how to do the testing as well? I think it is a good time as well to add some good testing in this case and maybe you already have experience on how you did the cisco ones.😄

evilmonkey19 commented 3 months ago

I've just started doing some improvements (really small ones) and those are some starting improvements

imagen

I have check and both works for a directly connected Huawei SmartAX. I'm still pending on checking on many, which perhaps there are some differences...

In this case i've just changed from CiscoBaseConnection to BaseConnection.

The file i'm talking about: https://github.com/ktbyers/netmiko/blob/develop/netmiko/huawei/huawei_smartax.py

This drastic change in performance seems to be due to clean_up. Specifically, when using the following code it takes 3 seconds.

with ConnectHandler(**credentials) as net_connect:
    net_connect.enable()
    output = net_connect.send_command('display board 0')

However, when using this other one it takes roughly the same time in both cases with CiscoBaseConnection and BaseConnection:

net_connect = ConnectHandler(**credentials)
net_connect.enable()
output = net_connect.send_command('display board 0')
# We are not closing here as we should.