Refactor client side xmlrpc server code.

Break out code for xmlrpc server from the code that exposes the faft functions
into two files (rpc_server.py and rpc_functions.py).

Also break out config values used for the rpc server into anther module which
can be seen by server side FAFT code which tells autotest to spin up the
rpc server.

BUG=None
TEST=Manually ran tests at desk against link device.

Change-Id: I9d8b2c3946c34fac247e8c4263f9620cba1fcd28
Reviewed-on: https://gerrit.chromium.org/gerrit/65873
Reviewed-by: Dennis Jeffrey <dennisjeffrey@chromium.org>
Commit-Queue: Yusuf Mohsinally <mohsinally@chromium.org>
Tested-by: Yusuf Mohsinally <mohsinally@chromium.org>
diff --git a/client/cros/faft/config.py b/client/cros/faft/config.py
new file mode 100644
index 0000000..1ae3f90
--- /dev/null
+++ b/client/cros/faft/config.py
@@ -0,0 +1,15 @@
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+class Config(object):
+    """Client side services config. Accessible by server side code as well."""
+
+    # RPC server that runs on the DUT.
+    rpc_port = 9990
+    rpc_command = '/usr/local/autotest/cros/faft/rpc_server.py'
+    rpc_command_short = 'rpc_server'
+    rpc_logfile = '/tmp/faft_rpc.log'
+    rpc_ssh_options = ('-o StrictHostKeyChecking=no '
+                       '-o UserKnownHostsFile=/dev/null ')
diff --git a/client/cros/faft/faft_client.py b/client/cros/faft/rpc_functions.py
similarity index 95%
rename from client/cros/faft/faft_client.py
rename to client/cros/faft/rpc_functions.py
index e43bbb4..ebf6f6f 100755
--- a/client/cros/faft/faft_client.py
+++ b/client/cros/faft/rpc_functions.py
@@ -1,18 +1,13 @@
-#!/usr/bin/python -u
-# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-"""Exposes the FAFTClient interface over XMLRPC.
+"""Code to provide functions for FAFT tests.
 
-It launches a XMLRPC server and exposes the interface of FAFTClient object.
-The FAFTClient object aggreates some useful functions of exisintg SAFT
-libraries.
+These can be exposed via a xmlrpci server running on the DUT.
 """
 
 import functools, os, shutil, tempfile
-from optparse import OptionParser
-from SimpleXMLRPCServer import SimpleXMLRPCServer
 
 import common
 from autotest_lib.client.cros.faft.utils import (cgpt_state,
@@ -69,8 +64,8 @@
         self._loaded = False
 
 
-class FAFTClient(object):
-    """A class of FAFT client which aggregates some useful functions of SAFT.
+class RPCFunctions(object):
+    """A class which aggregates some useful functions for firmware testing.
 
     This class can be exposed via a XMLRPC server such that its functions can
     be accessed remotely. Method naming should fit the naming rule
@@ -722,25 +717,3 @@
     def cleanup(self):
         """Cleanup for the RPC server. Currently nothing."""
         pass
-
-
-def main():
-    """The Main program, to run the XMLRPC server."""
-    parser = OptionParser(usage='Usage: %prog [options]')
-    parser.add_option('--port', type='int', dest='port', default=9990,
-                      help='port number of XMLRPC server')
-    (options, _) = parser.parse_args()
-
-    faft_client = FAFTClient()
-
-    # Launch the XMLRPC server to provide FAFTClient commands.
-    server = SimpleXMLRPCServer(('localhost', options.port), allow_none=True,
-                                logRequests=True)
-    server.register_introspection_functions()
-    server.register_instance(faft_client)
-    print 'XMLRPC Server: Serving FAFTClient on port %s' % options.port
-    server.serve_forever()
-
-
-if __name__ == '__main__':
-    main()
diff --git a/client/cros/faft/rpc_server.py b/client/cros/faft/rpc_server.py
new file mode 100755
index 0000000..7977a75
--- /dev/null
+++ b/client/cros/faft/rpc_server.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python -u
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Exposes the FAFTClient interface over XMLRPC.
+
+It launches a XMLRPC server and exposes the functions in RPCFunctions().
+"""
+
+from optparse import OptionParser
+from SimpleXMLRPCServer import SimpleXMLRPCServer
+
+import common
+from autotest_lib.client.cros.faft.rpc_functions import RPCFunctions
+
+
+def main():
+    """The Main program, to run the XMLRPC server."""
+    parser = OptionParser(usage='Usage: %prog [options]')
+    parser.add_option('--port', type='int', dest='port', default=9990,
+                      help='port number of XMLRPC server')
+    (options, _) = parser.parse_args()
+
+    # Launch the XMLRPC server to provide FAFTClient commands.
+    server = SimpleXMLRPCServer(('localhost', options.port), allow_none=True,
+                                logRequests=True)
+    server.register_introspection_functions()
+    server.register_instance(RPCFunctions())
+    print 'XMLRPC Server: Serving FAFT functions on port %s' % options.port
+    server.serve_forever()
+
+
+if __name__ == '__main__':
+    main()