From: Stephen Soltesz Date: Thu, 15 Jan 2009 19:45:41 +0000 (+0000) Subject: allow the ssh-version of the drac command to function correctly with drac5 and X-Git-Tag: Monitor-2.0-1~22 X-Git-Url: http://git.onelab.eu/?p=monitor.git;a=commitdiff_plain;h=b6200bf65d14d9de28c42f446d5d413f1954a240 allow the ssh-version of the drac command to function correctly with drac5 and the included pexpect scripts. --- diff --git a/pcucontrol/models/DRAC.py b/pcucontrol/models/DRAC.py index a2731cd..e7c030a 100644 --- a/pcucontrol/models/DRAC.py +++ b/pcucontrol/models/DRAC.py @@ -1,4 +1,5 @@ from pcucontrol.reboot import * +import time class DRAC(PCUControl): supported_ports = [22,443,5869] @@ -23,18 +24,29 @@ class DRAC(PCUControl): # NOTE: be careful to escape any characters used by 're.compile' index = s.expect(["\$", "\[%s\]#" % self.username ]) print "INDEX:", index + print s if dryrun: if index == 0: - s.send("racadm getsysinfo") + s.sendline("racadm getsysinfo") elif index == 1: - s.send("getsysinfo") + s.sendline("getsysinfo") else: + print "serveraction powercycle" if index == 0: - s.send("racadm serveraction powercycle") + s.sendline("racadm serveraction powercycle") elif index == 1: - s.send("serveraction powercycle") + s.sendline("serveraction powercycle") - s.send("exit") + # TODO: this is really lousy. Without the sleep, the sendlines + # don't completely get through. Even the added, expect line + # returns right away without waiting for the commands above to + # complete... Therefore, this delay is guaranteed to fail in some + # other context... + time.sleep(5) + index = s.expect(["\$", "\[%s\]#" % self.username ]) + print s + print "INDEX 2:", index + s.sendline("exit") except pexpect.EOF: raise ExceptionPrompt("EOF before expected Prompt") @@ -46,26 +58,6 @@ class DRAC(PCUControl): return 0 -class DRACDefault(PCUControl): - supported_ports = [22,443,5869] - def run_ssh(self, node_port, dryrun): - self.transport.open(self.host, self.username) - self.transport.sendPassword(self.password) - - print "logging in..." - self.transport.write("\r\n") - # Testing Reboot ? - if dryrun: - self.transport.ifThenSend("[%s]#" % self.username, "getsysinfo") - else: - # Reset this machine - self.transport.ifThenSend("[%s]#" % self.username, "serveraction powercycle") - - self.transport.ifThenSend("[%s]#" % self.username, "exit") - - self.transport.close() - return 0 - ### rebooting Dell systems via RAC card # Marc E. Fiuczynski - June 01 2005 # tested with David Lowenthal's itchy/scratchy nodes at UGA