From b0f9cc9ead4e2fec119199ec942165f2cefbe060 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Thu, 30 Jun 2011 16:37:57 -0400 Subject: [PATCH] Fix regex to match DRACs with username in ssh prompt. Pass IP addr to racadm rather than hostname. --- pcucontrol/models/DRAC.py | 2 +- pcucontrol/models/exp/DRAC.exp | 8 ++++---- pcucontrol/reboot.py | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) mode change 100755 => 100644 pcucontrol/models/exp/DRAC.exp diff --git a/pcucontrol/models/DRAC.py b/pcucontrol/models/DRAC.py index d9e4fe6..24ef3ad 100644 --- a/pcucontrol/models/DRAC.py +++ b/pcucontrol/models/DRAC.py @@ -4,7 +4,7 @@ import time class DRAC(BasicPCUControl): supported_ports = [22,443,5869] def run_drac(self, node_port, dryrun): - return self.run_expect_script("DRAC.exp racadm", dryrun=dryrun, model="None") + return self.run_expect_script("DRAC.exp racadm", dryrun=dryrun, model="None", ip=True) def run_ssh(self, node_port, dryrun): return self.run_expect_script("DRAC.exp ssh", dryrun=dryrun, model="None") diff --git a/pcucontrol/models/exp/DRAC.exp b/pcucontrol/models/exp/DRAC.exp old mode 100755 new mode 100644 index 35e9184..b3b1990 --- a/pcucontrol/models/exp/DRAC.exp +++ b/pcucontrol/models/exp/DRAC.exp @@ -36,7 +36,7 @@ if { "$method" == "ssh" } { "Could not resolve hostname" { send_user "DRAC ssh: $expect_out(0,string)"; exit } "Connection timed out" { send_user "DRAC ssh: $expect_out(0,string)"; exit } -re "Received disconnect.*" { send_user "DRAC ssh: $expect_out(0,string)"; exit} - -re "\\$|/.*>|\[$user\]#" { send "\r"; } + -re "\\$|/.*>|.*$user.*#" { send "\r"; } timeout { send_user "DRAC ssh: timeout" ; exit; } eof { if { $cont == 1 } { send_user "DRAC ssh failed twice"; exit ; } ; set cont 1 } } @@ -47,15 +47,15 @@ if { "$method" == "ssh" } { if { "$dryrun" == "True" } { expect { -re "\\$|/.*>" { send "racadm getsysinfo\r"; } - -re "\[$user\]#" { send "getsysinfo\r" } + -re ".*$user.*#" { send "getsysinfo\r" } } } else { expect { -re "\\$|/.*>" { send "racadm serveraction powercycle\r"; } - -re "\[$user\]#" { send "serveraction powercycle\r" } + -re ".*$user.*#" { send "serveraction powercycle\r" } } } - expect -re "\\$|/.*>|\[$user\]#" { send "exit\r"; } + expect -re "\\$|/.*>|.*$user.*#" { send "exit\r"; } expect eof { send_user "$reset_msg\n" } diff --git a/pcucontrol/reboot.py b/pcucontrol/reboot.py index eef8d2e..c127ac0 100755 --- a/pcucontrol/reboot.py +++ b/pcucontrol/reboot.py @@ -359,9 +359,14 @@ class BasicPCUControl(PCUModel): def run_expect_script(self, scriptname, **args): locfg = command.CMD() + if 'ip' in args: + host = self.ip + else: + host = self.host + cmd_str = get_python_lib(1) + "/pcucontrol/models/exp/" cmd = cmd_str + "%s %s %s '%s' %s %s " % ( - scriptname, self.host, self.username, + scriptname, host, self.username, self.password, args['dryrun'], args['model']) print cmd cmd_out, cmd_err = locfg.run_noexcept(cmd) -- 2.43.0