F5 root password change via python script issues
i am changing root password for mutiple f5's in my environment with a python script , somehow the script is not working as expected , i believe connection.recv is not able to get enough buffer here
script
import paramiko import threading import time import re import sys
def Cisco_smart_install(ip): username = 'admin' password = 'XXXXXXX' session = paramiko.SSHClient() session.set_missing_host_key_policy(paramiko.AutoAddPolicy()) session.connect(ip,username = username, password = password) connection = session.invoke_shell() time.sleep(3) connection.send('tmsh\n') time.sleep(2) connection.send('modify auth password root\n') time.sleep(20) connection.send('XXXXXXX\n') time.sleep(20) connection.send('XXXXXXX\n') time.sleep(3) connection.send('\n') time.sleep(4) connection.send('save sys config\n') time.sleep(4) router_output = connection.recv(65535) time.sleep(5) print router_output print " " print " " print " End of output " print " " print " " connection.send('quit\n') time.sleep(2) connection.send('exit\n')
this is the file from where i am reading ip address
thread1 = [] filename = 'ip_file.txt' file = open(filename,'r') x = file.read().splitlines() for host_name in x: th1 = threading.Thread(target = Cisco_smart_install,args = (host_name,)) th1.start() time.sleep(3) thread1.append(th1)
for th1 in thread1: th1.join()
file.close()
out put i am getting after script run
[admin@XXXXXXXX1:/S1-green-P:Active:Standalone] ~ tmsh admin@(XXXXXXXXX)(cfg-sync Standalone)(/S1-green-P:Active)(/Common)(tmos) modify auth password root changing password for root new password:
End of output