I'm looking for a Pythonscript that will copy Network switch config scripts to and from a TFTP server using HP switches. What I want to do is basically run the script from a TFTP server that will automatically ssh to an HP procurve switch and copy its startup-config back to my tftp server and load a new one from files I have specified. When it does this, it usually does it from one computer which is connected to a switch and when a certain switch goes down it reboots the network and a network respan occurs. When a network respan occurs I can not goto the next switch to copy switch configs until that switch comes back up. Do i need a delay command to wait before it goes to the next switch config or can i use a while loop that will basically copy switch configs from each switch let them reboot and take it out of a group of "to be configured switches" until all of them are done. What I have is a environment that has configs that constantly change and I need a way to basically run one script that will load a set of 8 switch configs fast instead of me taking cable to each serial port on the individual switches, which is really slow. Ill show you what I currently have but it is not as consistent and usually hangs due to a network respan. I'm a little new to Python so excuse my basic code. Is there anything I can do to make my code more reliable and my program closer to the one button configure and copy/load configs in a few seconds scirpt I want?
#Bindividual expect scripts that communicate with each switch
SW1 = "/tftpboot/ssh_toSW1.exp testing 192.168.1.101"
SW2 = "/tftpboot/ssh_toSW2.exp testing 192.168.1.1"
SW3 = "/tftpboot/ssh_toSW3.exp testing 192.168.1.212"
SW4 = "/tftpboot/ssh_toSW4.exp testing 192.168.1.101"
SW5 = "/tftpboot/ssh_toSW5.exp testing 192.168.1.2"
SW6 = "/tftpboot/ssh_toSW6.exp testing 192.168.1.104"
SW7 = "/tftpboot/ssh_toSW7.exp testing 192.168.1.110"
SW8 = "/tftpboot/ssh_toSW8.exp testing 192.168.1.103"
#Places variables into a list/array and executes them in order from left to right
cmds = [SW1, SW2, SW3, SW4, SW5, SW6, SW7, SW8,]
#Iterates over list, running statements for each item in the list
#Note, that whitespace is absolutely critical and that a consistent indent must be maintained for the code to work properly
for cmd in cmds:
print "Running Command Number %s" % count