Reboot status is (again) logged, this time more cleanly through the use
of job.record.

From: John Admanski <jadmanski@google.com>
Signed-off-by: Martin Bligh <mbligh@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@901 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index 7cbb1f9..e4a5a8e 100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -21,8 +21,6 @@
 import types, os, sys, signal, subprocess, time, re, socket
 import base_classes, utils, errors, bootloader
 
-DEFAULT_REBOOT_TIMEOUT = 1800
-
 
 class SSHHost(base_classes.RemoteHost):
 	"""
@@ -47,6 +45,8 @@
 	"""
 
 	SSH_BASE_COMMAND = '/usr/bin/ssh -a -o BatchMode=yes'
+	DEFAULT_REBOOT_TIMEOUT = 1800
+	job = None
 
 	def __init__(self, hostname, user="root", port=22, initialize=True,
 		     conmux_log="console.log", conmux_warnings="status.log",
@@ -189,12 +189,12 @@
 
 	def _wait_for_restart(self, timeout):
 		if not self.wait_down(300):	# Make sure he's dead, Jim
-			sys.stderr.write("REBOOT ERROR\n")
+			self.__record("FAIL", None, "reboot")
 			raise errors.AutoservRebootError("Host would not shut down")
 		self.wait_up(timeout)
 		time.sleep(2) # this is needed for complete reliability
 		if not self.wait_up(timeout):
-			sys.stderr.write("REBOOT ERROR\n")
+			self.__record("FAIL", None, "reboot")
 		print "Reboot complete"
 
 
@@ -289,6 +289,16 @@
 		return result == 0
 
 
+	def __record(self, status_code, subdir, operation, status = ''):
+		if self.job:
+			self.job.record(status_code, subdir, operation, status)
+		else:
+			if not subdir:
+				subdir = "----"
+			msg = "%s\t%s\t%s\t%s" % (status_code, subdir, operation, status)
+			sys.stderr.write(msg + "\n")
+
+
 	def ssh_command(self):
 		"""Construct an ssh command with proper args for this host."""
 		return r'%s -l %s -p %d %s' % (self.SSH_BASE_COMMAND,
@@ -350,7 +360,7 @@
 				label = self.bootloader.get_titles()[default]
 			self.bootloader.add_args(label, kernel_args)
 		print "Reboot: initiating reboot"
-		sys.stderr.write("REBOOT\n")
+		self.__record("GOOD", None, "reboot")
 		self.run('(sleep 5; reboot) >/dev/null 2>&1 &')
 		if wait:
 			self._wait_for_restart(timeout)