[autotest] Eureka host.

Creates a eureka host capable of verifying, cleanup, reboot
and machine_install. Also implements the following chagnes:
1. Pipes a base command through is_up, since different ssh
   hosts are bound to have different things pre-installed.
2. Changes some timeouts to integers to avoid asserts.
3. Make host factory a little more generic, and check
   for chromeos host first.
4. Adds a method to remote wget to server/site_utils.

TEST=Tried verify, cleanup, reoboot and machine_install.
BUG=chromium:292629, chromium:273843

Change-Id: I62a700614838569c6d77184b3c3339e914f4b456
Reviewed-on: https://chromium-review.googlesource.com/176303
Tested-by: Prashanth B <[email protected]>
Reviewed-by: Scott Zawalski <[email protected]>
Reviewed-by: Simran Basi <[email protected]>
Commit-Queue: Prashanth B <[email protected]>
diff --git a/server/hosts/abstract_ssh.py b/server/hosts/abstract_ssh.py
index 4120334..7af5a2e 100644
--- a/server/hosts/abstract_ssh.py
+++ b/server/hosts/abstract_ssh.py
@@ -382,19 +382,21 @@
                     raise error.AutoservRunError(e.args[0], e.args[1])
 
 
-    def ssh_ping(self, timeout=60):
+    def ssh_ping(self, timeout=60, base_cmd='true'):
         """
         Pings remote host via ssh.
 
         @param timeout: Time in seconds before giving up.
                         Defaults to 60 seconds.
+        @param base_cmd: The base command to run with the ssh ping.
+                         Defaults to true.
         @raise AutoservSSHTimeout: If the ssh ping times out.
         @raise AutoservSshPermissionDeniedError: If ssh ping fails due to
                                                  permissions.
         @raise AutoservSshPingHostError: For other AutoservRunErrors.
         """
         try:
-            self.run("true", timeout=timeout, connect_timeout=timeout)
+            self.run(base_cmd, timeout=timeout, connect_timeout=timeout)
         except error.AutoservSSHTimeout:
             msg = "Host (ssh) verify timed out (timeout = %d)" % timeout
             raise error.AutoservSSHTimeout(msg)
@@ -408,16 +410,17 @@
                                                  repr(e.result_obj))
 
 
-    def is_up(self, timeout=60):
+    def is_up(self, timeout=60, base_cmd='true'):
         """
-        Check if the remote host is up.
+        Check if the remote host is up by ssh-ing and running a base command.
 
         @param timeout: timeout in seconds.
+        @param base_cmd: a base command to run with ssh. The default is 'true'.
         @returns True if the remote host is up before the timeout expires,
                  False otherwise.
         """
         try:
-            self.ssh_ping(timeout=timeout)
+            self.ssh_ping(timeout=timeout, base_cmd=base_cmd)
         except error.AutoservError:
             return False
         else:
@@ -438,8 +441,8 @@
                  False otherwise
         """
         if timeout:
-            end_time = time.time() + timeout
-            current_time = time.time()
+            current_time = int(time.time())
+            end_time = current_time + timeout
 
         while not timeout or current_time < end_time:
             if self.is_up(timeout=end_time - current_time):
@@ -450,7 +453,7 @@
                 except error.AutoservError:
                     pass
             time.sleep(1)
-            current_time = time.time()
+            current_time = int(time.time())
 
         logging.debug('Host %s is still down after waiting %d seconds',
                       self.hostname, int(timeout + time.time() - end_time))
@@ -498,7 +501,7 @@
         """
         #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()
+        current_time = int(time.time())
         if timeout:
             end_time = current_time + timeout
 
@@ -525,7 +528,7 @@
         # the same time that allowed us into that iteration of the loop.
         while not timeout or current_time < end_time:
             try:
-                new_boot_id = self.get_boot_id(timeout=end_time - current_time)
+                new_boot_id = self.get_boot_id(timeout=end_time-current_time)
             except error.AutoservError:
                 logging.debug('Host %s is now unreachable over ssh, is down',
                               self.hostname)
@@ -549,7 +552,7 @@
                 self.run('kill -HUP 1', ignore_status=True)
 
             time.sleep(1)
-            current_time = time.time()
+            current_time = int(time.time())
 
         return False