- # Reboot Outlet N (Y/N)?
- if dryrun:
- self.ifThenSend("(Y/N)?", "N")
- else:
- self.ifThenSend("(Y/N)?", "Y")
- self.ifThenSend("DS-RPC>", "")
+ return 0
+
+class BayTechCtrlC(PCUControl):
+ """
+ For some reason, these units let you log in fine, but they hang
+ indefinitely, unless you send a Ctrl-C after the password. No idea
+ why.
+ """
+ def run(self, node_port, dryrun):
+ print "BayTechCtrlC %s" % self.host
+
+ ssh_options="-o StrictHostKeyChecking=no -o PasswordAuthentication=yes -o PubkeyAuthentication=no"
+ s = pxssh.pxssh()
+ if not s.login(self.host, self.username, self.password, ssh_options):
+ raise ExceptionPassword("Invalid Password")
+ # Otherwise, the login succeeded.
+
+ # Send a ctrl-c to the remote process.
+ print "sending ctrl-c"
+ s.send(chr(3))
+
+ # Control Outlets (5 ,1).........5
+ try:
+ index = s.expect(["Enter Request :"])
+
+ if index == 0:
+ print "5"
+ s.send("5\r\n")
+ index = s.expect(["DS-RPC>", "Enter user name:"])
+ if index == 1:
+ print "sending username"
+ s.send(self.username + "\r\n")
+ index = s.expect(["DS-RPC>"])
+
+ if index == 0:
+ print "Reboot %d" % node_port
+ s.send("Reboot %d\r\n" % node_port)
+
+ index = s.expect(["(Y/N)?"])
+ if index == 0:
+ if dryrun:
+ print "sending N"
+ s.send("N\r\n")
+ else:
+ print "sending Y"
+ s.send("Y\r\n")
+
+ #index = s.expect(["DS-RPC>"])
+ #print "got prompt back"
+
+ s.close()
+
+ except pexpect.EOF:
+ raise ExceptionPrompt("EOF before 'Enter Request' Prompt")
+ except pexpect.TIMEOUT:
+ raise ExceptionPrompt("Timeout before 'Enter Request' Prompt")