Created a common_lib host object hierarchy (with site specific override
support) and moved *some* non server specific code from server/hosts to
the common_lib version. Created a client.bin LocalHost host object
inheriting from the common_lib Host and implemented a run() method based
on utils.run() (ie a host object for the local machine). Modified
client/bin/autotest to receive a new --hostname argument to tell it the
hostname to use for the LocalHost.hostname instance attribute and
updated server/autotest.py to send use this argument. Modified
client.bin.job to set a self.host instance attribute with an instance of
LocalHost and updated the unittest. Added an AutotestHostRunError class
(raised on LocalHost.run() failures).

Risk: high (there are modifications in the core server side support code
and some core client code).

Tested with verify/repair and client/server sleeptest jobs.

To be able for SVN to remember code history (that most of the new 
client/common_lib/hosts/base_classes.py is based on the old 
server/hosts/base_classes.py) then the following steps are probably needed 
to apply this patch:
$ svn mkdir client/common_lib/hosts
$ svn copy server/hosts/base_classes.py client/common_lib/hosts
$ patch -p1 ...
$ svn add client/bin/local_host.py client/bin/local_host_unittest.py client/common_lib/hosts/__init__.py client/common_lib/hosts/base_classes_unittest.py

Signed-off-by: Mihai Rusu <dizzy@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3594 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/common_lib/error.py b/client/common_lib/error.py
index f2810ab..08401ce 100644
--- a/client/common_lib/error.py
+++ b/client/common_lib/error.py
@@ -159,6 +159,26 @@
     """
 
 
+class HostRunErrorMixIn(Exception):
+    """
+    Indicates a problem in the host run() function raised from client code.
+    Should always be constructed with a tuple of two args (error description
+    (str), run result object). This is a common class mixed in to create the
+    client and server side versions of it.
+    """
+    def __init__(self, description, result_obj):
+        self.description = description
+        self.result_obj = result_obj
+        Exception.__init__(self, description, result_obj)
+
+    def __str__(self):
+        return self.description + '\n' + repr(self.result_obj)
+
+
+class AutotestHostRunError(HostRunErrorMixIn, AutotestError):
+    pass
+
+
 # server-specific errors
 
 class AutoservError(Exception):
@@ -170,19 +190,8 @@
     pass
 
 
-class AutoservRunError(AutoservError):
-    """\
-    Errors raised by one of the run functions.  Should always be
-    constructed with a tuple of two args (error description (str),
-    run result object).
-    """
-    def __init__(self, description, result_obj):
-        self.description = description
-        self.result_obj = result_obj
-        AutoservError.__init__(self, description, result_obj)
-
-    def __str__(self):
-        return self.description + '\n' + repr(self.result_obj)
+class AutoservRunError(HostRunErrorMixIn, AutoservError):
+    pass
 
 
 class AutoservSshPermissionDeniedError(AutoservRunError):