get_boot_id to return None when not supported by the kernel.

Signed-off-by: Josh Gilkerson <[email protected]>

--- autotest/client/common_lib/hosts/base_classes.py    2010-05-19 
10:27:57.000000000 -0700
+++ autotest/client/common_lib/hosts/base_classes.py    2010-05-19 
10:27:57.000000000 -0700
@@ -165,9 +165,15 @@
 
         @param timeout The number of seconds to wait before timing out.
 
-        @return A string unique to this boot."""
-        return self.run('cat /proc/sys/kernel/random/boot_id',
-                        timeout=timeout).stdout.strip()
+        @return A string unique to this boot or None if not available."""
+        BOOT_ID_FILE = '/proc/sys/kernel/random/boot_id'
+        NO_ID_MSG = 'no boot_id available'
+        cmd = 'if [ -f %r ]; then cat %r; else echo %r; fi' % (
+                BOOT_ID_FILE, BOOT_ID_FILE, NO_ID_MSG)
+        boot_id = self.run(cmd, timeout=timeout).stdout.strip()
+        if boot_id == NO_ID_MSG:
+            return None
+        return boot_id
 
 
     def wait_up(self, timeout=None):
--- autotest/server/hosts/abstract_ssh.py       2010-05-19 10:27:57.000000000 
-0700
+++ autotest/server/hosts/abstract_ssh.py       2010-05-19 10:27:57.000000000 
-0700
@@ -444,6 +444,8 @@
 
         @returns True if the host was found to be down, False otherwise
         """
+        #TODO: there is currently no way to distinguish between knowing
+        #TODO: boot_id was unsupported and not knowing the boot_id.
         current_time = time.time()
         if timeout:
             end_time = current_time + timeout
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to