Replies: 5 comments 18 replies
-
Kirk,
I really like the idea. It’s more user-friendly as it translates to a concept one would think of when the desire is “keep trying until _____”.
…________________________________
From: Kirk Byers ***@***.***>
Sent: Tuesday, June 8, 2021 12:42
To: ktbyers/netmiko
Cc: Subscribed
Subject: [ktbyers/netmiko] Convert delay_factor/global_delay_factor to a simple read_timeout for the send_command method (#2302)
I have been thinking quite a bit about how global_delay_factor and delay_factor should be fixed. For send_command , I was planning on doing the following:
1. Completely kill both delay_factor and global_delay_factor here i.e. as of netmiko4, these would do nothing on the send_command() method (probably just raise a warning if you try to use them).
2. Add a read_timeout that would be an argument to send_command. For example, send_command("show ip int brief", read_timeout=30). read_timeout will be the time Netmiko spends looking for the terminating pattern either self.base_prompt or expect_string if it is specified. read_timeout will default to 10 seconds.
3. If pattern (i.e. self.base_prompt or expect_string) is not detected in read_timeout seconds, then ReadTimeout exception will be raised.
Because of platforms like Ansible, Salt, Nornir and also libraries like NAPALM which might potentially make argument passing to a method difficult, there will be a ConnectHandler argument that will override the default read_timeout (probably read_timeout_override=x).
tldr = I am planning on killing delay_factor/global_delay_factor to send_command and replacing it with a simple read_timeout=x
Thoughts/issues/problems?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#2302>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMUHHMWJXNUULJVE6ILAV6TTRZB6LANCNFSM46KKLUBA>.
|
Beta Was this translation helpful? Give feedback.
-
But what if device continue sending the output and read time out expire, think we should have two timeouts, one is absolute, which works as you describing read timeout now and second timeout that should expire if no output from device was received for certain amount of time. All in all, that was implemented with promptless mode PR I raised a while ago. |
Beta Was this translation helpful? Give feedback.
-
yes I installed 4.0 literally a few days back
I'll give a try in a bit - thank you
What I am talking about is a somewhat different concept of starting the
timer when there is no longer data coming from the device and the prompt is
still not matched).
I understand there could be a few cases:
- data arrived and then the prompt -> all is good here
- prompt has arrived but some junk/background data is still arriving ->
then the prompt should be matched anyway
- data stopped but no prompt -> then timer kicks in when the last bit of
data arrived and expires
- no prompt / no data -> the timer kicks in when the command was sent and
expires
…On Wed, Mar 30, 2022 at 4:56 PM Kirk Byers ***@***.***> wrote:
Are you using Netmiko 4.0.0?
If so, then you should be able to just use send_command(command,
read_timeout=x) where x is a time in seconds sufficiently large that your
output will complete. read_timeout is an absolute timer (that is very
unlikely to change).
—
Reply to this email directly, view it on GitHub
<#2302 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATJNEU6UCWL5RKGSA5HPKYLVCTSZ3ANCNFSM46KKLUBA>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Thanks,
Igor Skobkarev,
***@***.***
|
Beta Was this translation helpful? Give feedback.
-
After digging into send_command to deal with a corner case recently, I came across this thread and figured I'd throw my opinion into the mix. I like the idea of having two timeouts. Something short to account for the the device that's gone quiet and something longer to account for the output that will never stop. Here's an idea to throw out there
Two additional variables are set to
This while loop condition will fail if no data has been received before the read_timeout, or if data is still being received and 10x the read_timeout has passed. Test code:
In all examples, the Example command exceeding read_timeout:
Another example exceeding read_timeout:
Example of expected prompt that won't be found:
Example output exceeding absolute timer:
|
Beta Was this translation helpful? Give feedback.
-
@ktbyers all in all think it would be for the best of everybody to consider implementing plugins system for Netmiko 5 where certain functionality, including read from prompt mechanism, could be implemented as plugins similar to how Nornir does it using entry points. That would allow to lift the burden off the Netmiko maintainers to test and support corner case scenarios and will allow people to use their own plugins. |
Beta Was this translation helpful? Give feedback.
-
I have been thinking quite a bit about how global_delay_factor and delay_factor should be fixed. For send_command , I was planning on doing the following:
delay_factor
andglobal_delay_factor
here i.e. as of netmiko4, these would do nothing on the send_command() method (probably just raise a warning if you try to use them).read_timeout
that would be an argument to send_command. For example, send_command("show ip int brief", read_timeout=30). read_timeout will be the time Netmiko spends looking for the terminating pattern either based on the prompt or expect_string if it is specified. read_timeout will default to 10 seconds.ReadTimeout
exception will be raised.Because of platforms like Ansible, Salt, Nornir and also libraries like NAPALM which might potentially make argument passing to a method difficult, there will be a ConnectHandler argument that will override the default read_timeout (probably
read_timeout_override=x
).tldr = I am planning on killing delay_factor/global_delay_factor to send_command and replacing it with a simple read_timeout=x
Thoughts/issues/problems?
Beta Was this translation helpful? Give feedback.
All reactions