[autotest] Refactor SiteHost, AbstractSSHHost, SSHHost hierarchy

This CL refactors the host classes inheriting hierarchy.
Previously, we have SiteHost as a parent class of AbstractSSHost.
This makes AbstractSSHHost/SSHHost chromeos-specific.
In the new hierarchy, SiteHost is made as a subclass of AbstractSSHHost.
This allows other types of host, such as ServoHost,
easily inherits from AbstractSSHHost/SSHHost, without unnecessarily
inheriting chromeos specific methods from SiteHost.

make_ssh_command is put inside host classes, which allows
each subclass of AbstractSSHHost to easily
override it with its own settings.

SiteHost are mixed with SSHHost or ParamikoHost in create_host.

For a thorough discussion about the refactoring design,
take a look at the design doc mentioned in crbug.com/265998.

CQ-DEPEND=CL:66136
BUG=chromium:265998
TEST=dummy and bvt suite pass locally; repair/verify jobs pass; vmtest
in a tryjob pass.
DEPLOY=scheduler

Change-Id: I03a63a3db2f3cb0eaa50884c53fe3d3f8bb779ed
Reviewed-on: https://gerrit.chromium.org/gerrit/64331
Reviewed-by: Fang Deng <[email protected]>
Tested-by: Fang Deng <[email protected]>
Commit-Queue: Fang Deng <[email protected]>
diff --git a/server/hosts/abstract_ssh.py b/server/hosts/abstract_ssh.py
index 0df6b41..3c45a6b 100644
--- a/server/hosts/abstract_ssh.py
+++ b/server/hosts/abstract_ssh.py
@@ -10,30 +10,7 @@
                               default=False)
 
 
-def _make_ssh_cmd_default(user="root", port=22, opts='', hosts_file='/dev/null',
-                          connect_timeout=30, alive_interval=300):
-    base_command = ("/usr/bin/ssh -a -x %s -o StrictHostKeyChecking=no "
-                    "-o UserKnownHostsFile=%s -o BatchMode=yes "
-                    "-o ConnectTimeout=%d -o ServerAliveInterval=%d "
-                    "-l %s -p %d")
-    assert isinstance(connect_timeout, (int, long))
-    assert connect_timeout > 0 # can't disable the timeout
-    return base_command % (opts, hosts_file, connect_timeout,
-                           alive_interval, user, port)
-
-
-make_ssh_command = utils.import_site_function(
-    __file__, "autotest_lib.server.hosts.site_host", "make_ssh_command",
-    _make_ssh_cmd_default)
-
-
-# import site specific Host class
-SiteHost = utils.import_site_class(
-    __file__, "autotest_lib.server.hosts.site_host", "SiteHost",
-    remote.RemoteHost)
-
-
-class AbstractSSHHost(SiteHost):
+class AbstractSSHHost(remote.RemoteHost):
     """
     This class represents a generic implementation of most of the
     framework necessary for controlling a host via ssh. It implements
@@ -62,6 +39,19 @@
         self.master_ssh_option = ''
 
 
+    def make_ssh_command(self, user="root", port=22, opts='',
+                         hosts_file='/dev/null',
+                         connect_timeout=30, alive_interval=300):
+        base_command = ("/usr/bin/ssh -a -x %s -o StrictHostKeyChecking=no "
+                        "-o UserKnownHostsFile=%s -o BatchMode=yes "
+                        "-o ConnectTimeout=%d -o ServerAliveInterval=%d "
+                        "-l %s -p %d")
+        assert isinstance(connect_timeout, (int, long))
+        assert connect_timeout > 0 # can't disable the timeout
+        return base_command % (opts, hosts_file, connect_timeout,
+                               alive_interval, user, port)
+
+
     def use_rsync(self):
         if self._use_rsync is not None:
             return self._use_rsync
@@ -102,9 +92,9 @@
         appropriate rsync command for copying them. Remote paths must be
         pre-encoded.
         """
-        ssh_cmd = make_ssh_command(user=self.user, port=self.port,
-                                   opts=self.master_ssh_option,
-                                   hosts_file=self.known_hosts_file)
+        ssh_cmd = self.make_ssh_command(user=self.user, port=self.port,
+                                        opts=self.master_ssh_option,
+                                        hosts_file=self.known_hosts_file)
         if delete_dest:
             delete_flag = "--delete"
         else:
@@ -123,9 +113,9 @@
         Create a base ssh command string for the host which can be used
         to run commands directly on the machine
         """
-        base_cmd = make_ssh_command(user=self.user, port=self.port,
-                                    opts=self.master_ssh_option,
-                                    hosts_file=self.known_hosts_file)
+        base_cmd = self.make_ssh_command(user=self.user, port=self.port,
+                                         opts=self.master_ssh_option,
+                                         hosts_file=self.known_hosts_file)
 
         return '%s %s "%s"' % (base_cmd, self.hostname, utils.sh_escape(cmd))