Loading a configuration from txt file takes a lot of time
See original GitHub issueHi,
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()`
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:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
@mabslkoirala Make sure you are using Netmiko 2.3.0 then try setting 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:
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 😃.