02-03-2022 12:19 AM
I have developed the following python script to help me upload NX-OS images to the Cisco Nexus switches.
The script is running just fine with small files. Tried with files under 100M and it's working fine. However I have also NX-OS images which are about 600M . At some point while script is running and the TFTP upload in in progress the upload stops when the file on the Cisco Employee Connection Insite: 205987840. The programs freezes and when I type show users in the cisco console I can see that the user used for upload is already disconnected.
I am thinking that maybe is something related to the ssh session timed out ? Or maybe something wrong in my script? I am new with python.
I am posting only relevant parts of the script:
def ssh_connect_no_shell(command): global output ssh_no_shell = paramiko.SSHClient() ssh_no_shell.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_no_shell.connect(device, port=22, username=myuser, password=mypass) ssh_no_shell.exec_command('terminal length 0\n') stdin, stdout, stder = ssh_no_shell.exec_command(command) output = stdout.readlines() ssh_no_shell.close() def upload_file(): cmd_1 = "copy tftp:" + "//" + tftp_server + "/" + image + " " + "bootflash:" + " vrf " + my_vrf ssh_connect_no_shell(cmd_1) print '\n##### Device Output Start #####' print '\n'.join(output) print '\n##### Device Output End #####' def main(): print 'Program starting...\n' time.sleep(1) variables1() check_if_file_present() check_if_enough_space() upload_file() check_file_md5sum() are_you_sure(perform_upgrade) perform_upgrade_and_reboot() if __name__ == '__main__': clear_screen() main()
02-03-2022 05:56 AM
@davelittle260 take a look at this thread https://community.cisco.com/t5/other-networking-subjects/automating-ios-upgrade-python-script-throws-error-quot-socket/td-p/4469377 and comment from @Claudia de Luna to this might help.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide