Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #CREATED BY ELNUR
- import paramiko
- import datetime
- import time
- hostnames_list = {
- "CISCO-3B" : "10.0.0.2",
- "CISCO-1B" : "10.0.0.3",
- "FLOOR-2A" : "10.0.0.4",
- "CISCO-1A" : "10.0.0.5",
- "CISCO-1C" : "10.0.0.6",
- "FLOOR-0A" : "10.0.0.7",
- "CISCO-3A" : "10.0.0.8",
- "ASB4" : "10.0.0.9",
- "ASB-3" : "10.0.0.10",
- "CISCO-2B" : "10.0.0.11",
- "CISCO-4B" : "10.0.0.12",
- "PAVILION-5" : "10.0.0.13",
- "Asb_6" : "10.0.0.14",
- }
- port = 22
- username = "admin"
- password = "azsxdcfvgbhn*1"
- 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