Fix regex to match DRACs with username in ssh prompt.
authorStephen Soltesz <soltesz@cs.princeton.edu>
Thu, 30 Jun 2011 20:37:57 +0000 (16:37 -0400)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Thu, 30 Jun 2011 20:37:57 +0000 (16:37 -0400)
Pass IP addr to racadm rather than hostname.

pcucontrol/models/DRAC.py
pcucontrol/models/exp/DRAC.exp [changed mode: 0755->0644]
pcucontrol/reboot.py

index d9e4fe6..24ef3ad 100644 (file)
@@ -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")
old mode 100755 (executable)
new mode 100644 (file)
index 35e9184..b3b1990
@@ -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" }
 
index eef8d2e..c127ac0 100755 (executable)
@@ -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)