+ ssh = None
+
+ try:
+ ssh = pyssh.Ssh(username, ip)
+ ssh.set_debuglevel(verbose)
+ ssh.open()
+ # Login
+ print "password"
+ telnet_answer(ssh, "password:", password)
+
+ # User:vici logged-in to ILOUSE701N7N4.CS.Princeton.EDU(128.112.154.171)
+ # iLO Advanced 1.26 at 10:01:40 Nov 17 2006
+ # Server Name: USE701N7N400
+ # Server Power: On
+ #
+ # </>hpiLO->
+ print "cd system1"
+ telnet_answer(ssh, "</>hpiLO->", "cd system1")
+
+ # Reboot Outlet N (Y/N)?
+ print "reset or power"
+ if dryrun:
+ telnet_answer(ssh, "</system1>hpiLO->", "POWER")
+ else:
+ # Reset this machine
+ telnet_answer(ssh, "</system1>hpiLO->", "reset")
+
+ print "exit"
+ telnet_answer(ssh, "</system1>hpiLO->", "exit")
+
+ # Close
+ print "close"
+ output = ssh.close()
+ return 0
+
+ except socket.error, err:
+ print "exception"
+ import traceback
+ traceback.print_exc()
+ if verbose:
+ logger.debug(err)
+ if ssh:
+ output = ssh.close()
+ if verbose:
+ logger.debug(err)
+ return errno.ETIMEDOUT
+ except Exception, err:
+ print "exception"
+ import traceback
+ traceback.print_exc()
+ if verbose:
+ logger.debug(err)
+ if ssh:
+ output = ssh.close()
+ if verbose:
+ logger.debug(err)
+ return "ilo error"
+
+def baytech_reboot(ip, username, password, port, dryrun):
+ global verbose