send_command expect string and delay_factor
See original GitHub issueHi,
Context I’m having a hard time figuring out how expect_string and delay_factor work together. I need to script a cisco 2960X stack upgrade which include the painful step of sending “archive download-sw flash:tarfile”. This step is high CPU consuming on the switch part and it takes forever (more than an hour and a half). Using ANSIBLE, i’haven’t found a effective way of checking when this step is ending, that is why i’m turning to Nornir + Netmiko. However I’ve been POCing this with a “write mem” command which can take a while as well depending on the load size of the stack.
Setup I’m running the following against a single switch for test purposes:
start_time = time.time()
nr = InitNornir()
result = nr.run(
task=netmiko_send_command,
command_string="write mem",
expect_string="OK",
delay_factor=50,
)
print_result(result)
print(f"{time.time() - start_time} seconds")
Ouput PS C:\Users\WWW\production\nornir> python .\nornir_writemem.py netmiko_send_command************************************************************
- labnxp ** changed : False ****************************************************vvvv netmiko_send_command ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO Building configuration… [OK] ^^^^ END netmiko_send_command ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24.849318027496338 seconds
Expected output I’m expecting the run to stop as soon as OK appears in the output. I’ve set delay to 50 just to adjust timeout to 50 seconds in case it doesn’t find it.
I expected it to finish in 5 seconds.
Is my understanding of the send_command options wrong ? When does it check the output content ? Can we control it ?
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
@MichalObs97 You have a couple of options:
develop
branch (which is Netmiko 4.X code). This entire delay_factor/fast_cli/max_loops has been reworked and largely replaced with a much simpler timeout.send_command()
timing mode. Given that you are doing a long running operation (several minutes), you will want to have fast_cli=False if you are using the Netmiko 3.4.0 code.@ktbyers Hi. I’ve looked into what was detailed here and also other posts. My problem is that I used fast_cli=true, and that seems to have completely changed the timing of 100 seconds. I am uploading new image to a WLC which is a process that takes around 5-7 minutes and according to the 100 seconds calculations delay around 5 should be plenty. Currently with fast_cli on true I have to have delay_factor on 99999 for it to surely work. Do you know how does timing change with fast_cli? Or you recommend to just turn it off? (I would profit from it being on). Thank you for your time and help.