Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buffer clean in Huawei session preparation #3131

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

k-ribot
Copy link
Contributor

@k-ribot k-ribot commented Mar 2, 2023

No description provided.

@ktbyers
Copy link
Owner

ktbyers commented Mar 12, 2023

@k-ribot Why is this needed? Do you have more details?

I would have thought it was unnecessary and slows things down.

@k-ribot
Copy link
Contributor Author

k-ribot commented Mar 21, 2023

@ktbyers We use Netmiko to connect to equipment from our tool. This tool can be used at the same time by several users. When we have more than 4 connections at the same time on a Huawei. the prompt of the last connection is wrong because it uses the result of the command "screen-length 0 temporary". This is why the delay is necessary.

Error received on the command "display version" executed after the connection:

ReadTimeout

Pattern not detected: 'Info:\\ The\\ configuration\\ takes\\ effect\\ on\\ the\\ current\\ user\\ terminal\\ interface\\ only\\.' 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.

@ktbyers
Copy link
Owner

ktbyers commented Mar 21, 2023

Can you show what the CLI looks like when you see this message?

Pattern not detected: 'Info:\\ The\\ configuration\\ takes\\ effect\\ on\\ the\\ current\\ user\\ terminal\\ interface\\ only\\.' in output.

i.e. the message The configuration takes effect on the current...

You can probably capture this via the Netmiko session_log and just include the session_log.

I am reluctant to add the buffer clearing in the session_preparation method as it slows things down meaningfully (which is why I removed it previously). Also your error/issue doesn't exactly match what I would expect...so that is why I want to dig into it a bit more.

Thanks, Kirk

@k-ribot k-ribot force-pushed the fix-huawei-add-buffer-clean-in-session-preparation branch from 81f93a4 to 48659fc Compare May 31, 2023 13:29
@ktbyers
Copy link
Owner

ktbyers commented May 31, 2023

@k-ribot Are you still working on this?

I still don't see why this is needed and am pretty reluctant to just add slowness without an understanding of why it is needed.

@k-ribot
Copy link
Contributor Author

k-ribot commented Jun 1, 2023

Sorry we work on many projet, I forgot to send you the log file.
netmiko_global.log

I execute this python code:

import logging

from typing import List

from netmiko import ConnectHandler
from threading import Thread

logging.basicConfig(filename='netmiko_global.log', level=logging.DEBUG)
logger = logging.getLogger("netmiko")

def test(i: int):
    netmiko_connection = ConnectHandler(
        host='...',
        port=22,
        username='...',
        password='...',
        device_type='huawei_vrp'
    )
    netmiko_connection.send_command('display version')


threads: List[Thread] = []
for i in range(0, 4):
    threads.append(Thread(target=test, args=(i,)))

for thread in threads:
    thread.start()

I create 4 connection and I try to execute one command.

Lines 466 and 670 we can read this:
DEBUG:netmiko:[find_prompt()]: prompt is Info: The configuration takes effect on the current user terminal interface only.

Without sleep before buffer clearing 2 threads find bad prompt and client raise ReadTimeout exception.

@k-ribot k-ribot force-pushed the fix-huawei-add-buffer-clean-in-session-preparation branch from 48659fc to a891ebe Compare June 14, 2023 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants