Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import paramiko
- import datetime
- import time
- hostnames_list = {
- "XXXXX" : "10.0.0.2",
- "XXXXX" : "10.0.0.3",
- "XXXXX" : "10.0.0.4",
- "XXXXX" : "10.0.0.5",
- "XXXXX" : "10.0.0.6",
- "XXXXX" : "10.0.0.7",
- }
- port = 22
- username = "admin"
- password = "XXXXXXXX"
- def RebootAccessPoints():
- if __name__ == "__main__":
- ssh = paramiko.SSHClient() #Importing SSH client
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # add finger print to the known hosts
- for key,value in hostnames_list.iteritems():
- try:
- ssh.connect(value,port,username,password)
- stdin,stdout,stderr = ssh.exec_command("reboot") # which command do you want execute
- print str(datetime.datetime.now()) + " %s rebooted successfully!" % key
- except paramiko.ssh_exception.NoValidConnectionsError: # executed if there is any problem with connection
- print str(datetime.datetime.now()) + " There is connection error with %s" % key
- ssh.close()
- RebootAccessPoints()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement