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.

Loading a configuration from txt file takes a lot of time

See original GitHub issue

Hi,

I am practicing network automation using netmiko library and have been able to do so only because of the great content provided by Kirk Byers. Thank you so much sir!

I created a code which loads the configuration from a text file in a certain directory on to the cisco device. I have created the whole lab on GNS3. The code is running perfectly fine it’s just that it takes a lot of time to push the configuration on the device. Using the datetime library, I came to know that the code is taking 1 minute and 30 seconds to push the configuration. I am just curious to know if there is any faster way of doing it or does netmiko takes this much amount of time.

Here is the part of the code:

`AUTOLAB = { ‘device_type’: ‘cisco_ios’, ‘ip’: IP_ADD, #these variables have been taken as raw_input ‘username’: USER_NAME, ‘password’: PASSWORD, ‘secret’ : SECRET_PASS, }

net_connect = ConnectHandler(**AUTOLAB) net_connect.enable() net_connect.config_mode()

with open(user_path, ‘r’) as f: #user_path is the variable i defined which takes the path of file(configuration file) as raw input from the user. config_commands = f.readlines()

Tstart = datetime.now() net_connect.send_config_set(config_commands) Tend = datetime.now() Tdiff = Tend - Tstart print (“\n Configuration loaded”) print (“Time taken to push the configuration = " + str(Tdiff)) print (”\n\n Aborting Connection with " + IP_ADD) net_connect.disconnect()`

image

As you can in above screen shot, it took 1:30 secs to push the configuration. Can you please let me know if this is normal?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ktbyerscommented, Oct 29, 2018

@mabslkoirala Make sure you are using Netmiko 2.3.0 then try setting fast_cli=True

net_connect = netmiko.ConnectHandler(device_type='cisco_xr', ip=Ip , username=Username, password=Password, fast_cli=True)

Also, you shouldn’t be doing a for loop in that way for Netmiko and send_config_set (you will be making things a lot slower that way).

Netmiko send_config_set() takes a list of commands, so you should just do:

net_connect.send_config_set(list_of_commands)

i.e. no separate for-loop. If you need to create a list of commands from some other data-structure, then you should do that as a preprocessing step before calling send_config_set.

0reactions
skoirala01commented, Oct 30, 2018

@mabslkoirala Make sure you are using Netmiko 2.3.0 then try setting fast_cli=True

net_connect = netmiko.ConnectHandler(device_type='cisco_xr', ip=Ip , username=Username, password=Password, fast_cli=True)

Also, you shouldn’t be doing a for loop in that way for Netmiko and send_config_set (you will be making things a lot slower that way).

Netmiko send_config_set() takes a list of commands, so you should just do:

net_connect.send_config_set(list_of_commands)

i.e. no separate for-loop. If you need to create a list of commands from some other data-structure, then you should do that as a preprocessing step before calling send_config_set.

Thank you very much Krik, your comment is highly appreciated. I created text file and load config removed for loop so less than a minute of job completed. (however I tried but could not able to install netmiko version 2.3.0, but not a big deal for me now) Now time to go through your lecture videos and to learn more 😃.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading Configuration wasting time - Alteryx Community
I have a question: when I was developing the workflow, after I add a big dataset, let's say the file size is 5Gs,...
Read more >
Process very large (>20GB) text file line by line - Stack Overflow
shows that a 10 gb read should take in the neighborhood of 3 minutes. Sequential write is the same speed. So you're missing...
Read more >
Why does it take a long time to open certain small text files in ...
It takes 10 seconds on an idle computer for this tiny text file to open up in Vim. The time taken is the...
Read more >
Loading Configuration Files | Junos OS - Juniper Networks
You can create a file containing configuration data for a Juniper Networks device, copy the file to the local device, and then load...
Read more >
Working with the Configuration Files - Cisco
Creating a Configuration File Using a Text Editor, page 2-2 ... The copy {ftp: | rcp: | tftp:} system:running-config privileged EXEC command loads...
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