question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Huawei special_login_handler is not logging in successfully

See original GitHub issue

The system information is as follows:

  1. netmiko version: 4.0
  2. python 3.10
  3. window 11

error_print:

Traceback (most recent call last):
  File "E:\web_API\test.py", line 11, in <module>
    app.net_ssh_proxy(switch_json = switch_json, commands=commands)
  File "E:\web_API\app.py", line 25, in net_ssh_proxy
    with ConnectHandler(**device_info, sock=sock) as net_connect:
  File "E:\venv_02\lib\site-packages\netmiko\ssh_dispatcher.py", line 344, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "E:\venv_02\lib\site-packages\netmiko\base_connection.py", line 434, in __init__
    self._open()
  File "E:\venv_02\lib\site-packages\netmiko\base_connection.py", line 439, in _open
    self.establish_connection()
  File "E:\venv_02\lib\site-packages\netmiko\base_connection.py", line 1092, in establish_connection
    self.special_login_handler()
  File "E:\venv_02\lib\site-packages\netmiko\huawei\huawei.py", line 105, in special_login_handler
    output = self.read_until_pattern(password_change_prompt)
  File "E:\venv_02\lib\site-packages\netmiko\base_connection.py", line 631, in read_until_pattern
    raise ReadException(msg)
netmiko.exceptions.ReadException: Unable to successfully split output based on pattern:
pattern=((Change now|Please choose))|([\]>]\s*$)
output='\nInfo: The max number of VTY users is 21, the number of current VTY users online is 2, and total number of terminal users online is 2.\n      The current login time is 2022-03-28 15:55:30+08:00.\n<xxxx_hostname>'
results=['\nInfo: The max number of VTY users is 21, the number of current VTY users online is 2, and total number of terminal users online is 2.\n      The current login time is 2022-03-28 15:55:30+08:00.\n<xxxx_hostname', None, None, '>', '']

test instanse 2. python 3.10 3. window 11 Netmiko 3.4.0 Release

out_print

no problem

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:52 (26 by maintainers)

github_iconTop GitHub Comments

2reactions
TimGacommented, Sep 7, 2022

The reason for Huawei telnet trouble netmiko.exceptions.ReadException: Unable to successfully split output based on pattern is that pattern (]\s*$|>\s*$|(Change now|Please choose 'YES' or 'NO').+) contains nested group (nested parentheses). To fix this issue, changes of source code needed.

Details:

  1. In this string: https://github.com/ktbyers/netmiko/blob/f3b5da244e6ce1e5fd7bd89fd36b090e854828b4/netmiko/huawei/huawei.py#L132 combined_pattern created - i mean this pattern (]\s*$|>\s*$|(Change now|Please choose 'YES' or 'NO').+)
  2. Then created combined_pattern passes to read_until_pattern method here https://github.com/ktbyers/netmiko/blob/f3b5da244e6ce1e5fd7bd89fd36b090e854828b4/netmiko/huawei/huawei.py#L155
  3. Bad thing happend here: https://github.com/ktbyers/netmiko/blob/f3b5da244e6ce1e5fd7bd89fd36b090e854828b4/netmiko/base_connection.py#L636 After splitting, we got result list of length = 4, and this is the reason for ReadException here: https://github.com/ktbyers/netmiko/blob/f3b5da244e6ce1e5fd7bd89fd36b090e854828b4/netmiko/base_connection.py#L645
  4. And the reason of len(result) = 4 is that combined_pattern has nested parentheses here:
(]\s*$|>\s*$|(Change now|Please choose 'YES' or 'NO').+)
             ^                                      ^

@Toxic-Waste- you can try to edit file /home/<snip>/.local/lib/python3.10/site-packages/netmiko/huawei/huawei.py on line 131 change this:

password_change_prompt = r"(Change now|Please choose 'YES' or 'NO').+"

to this:

password_change_prompt = r"Change now|Please choose 'YES' or 'NO'"

But you must understand that:

  • it is not good to change package’s code directly like that
  • it can cause unexpected error in another place
  • this is just a dirty quick fix that worked for my case

@ktbyers I can try to analize side effects of proposed changes and craft Pull Request if you like. But if you think that PR is redundant, please let me know. Thanks!

1reaction
aztec102commented, May 14, 2022

@ktbyers Yes, i see.

import re
from netmiko import ConnectHandler
host = input('Input Dest host: ')

device = {
    'device_type': 'huawei_telnet',
    'ip':   host,
    'username': 'login',
    'password': 'pass',
    'port' : 23,
    'verbose': True,
    'session_log': f'{host}.log'
}

net_connect = ConnectHandler(**device)
pip3 list | grep netmiko
netmiko                      4.1.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

An issue occurs when logging in to my HUAWEI ID
When logging in to their HUAWEI ID, the user is prompted with "Unable to obtain data. Please try again later.", a message indicating...
Read more >
What should I do if I am having trouble logging in to ...
Cause and solution: · The network environment may be abnormal. · Clear the data and cache of HUAWEIAppGallery and open the app again....
Read more >
Troubleshooting Failures to Log In to the Web System of AR ...
Run the display this command in the interface view to check whether the router's IP address is correctly configured. If not, run the...
Read more >
Troubleshooting S5700 Switch Login Failures - Huawei Support
This document describes how to troubleshoot common login faults of Huawei S series switches, including: Failure to log in to a Huawei S...
Read more >
Failed to Log in to the FusionAccess VM- Huawei
A user fails to log in to the FusionAccess VM. After the user enters the account and password, the VM is stuck in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found