Fix up the reboot logging so that the starts of hardresets are logged
properly, failed soft reboots are logged properly, and a little extra
detail is attached to failure messages to make it easier to determine
exactly what failed.

This also fixes up "reboot over ssh" commands to make sure that all
the associated file descriptors are closed.

Signed-off-by: John Admanski <jadmanski@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@930 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index d7cdb7a..de7dd4a 100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -192,14 +192,14 @@
 
 	def _wait_for_restart(self, timeout):
 		if not self.wait_down(300):	# Make sure he's dead, Jim
-			self.__record("ABORT", None, "reboot.verify")
+			self.__record("ABORT", None, "reboot.verify", "shutdown failed")
 			raise errors.AutoservRebootError("Host did not shut down")
 		self.wait_up(timeout)
 		time.sleep(2) # this is needed for complete reliability
 		if self.wait_up(timeout):
 			self.__record("GOOD", None, "reboot.verify")
 		else:
-			self.__record("ABORT", None, "reboot.verify")
+			self.__record("ABORT", None, "reboot.verify", "bringup failed")
 			raise errors.AutoservRebootError("Host did not return from reboot")
 		print "Reboot complete"
 
@@ -208,8 +208,9 @@
 		"""
 		Reach out and slap the box in the power switch
 		"""
-		command_ran = self.__console_run(r"'~$hardreset'")
-                if not command_ran:
+		self.__record("GOOD", None, "reboot.start", "hard reset")
+		if not self.__console_run(r"'~$hardreset'"):
+			self.__record("ABORT", None, "reboot.start", "hard reset unavailable")
                         raise errors.AutoservUnsupportedError
                 if wait:
                         self._wait_for_restart(timeout)
@@ -368,9 +369,10 @@
 		print "Reboot: initiating reboot"
 		self.__record("GOOD", None, "reboot.start")
 		try:
-			self.run('(sleep 5; reboot) >/dev/null 2>&1 &')
-		except AutoservRunError:
-			self.__record("ABORT", None, "reboot.start")
+			self.run('(sleep 5; reboot) </dev/null >/dev/null 2>&1 &')
+		except errors.AutoservRunError:
+			self.__record("ABORT", None, "reboot.start",
+				      "reboot command failed")
 			raise
 		if wait:
 			self._wait_for_restart(timeout)