Home | History | Annotate | Download | only in faft
      1 #!/usr/bin/python -u
      2 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 """Exposes the FAFTClient interface over XMLRPC.
      7 
      8 It launches a XMLRPC server and exposes the functions in RPCFunctions().
      9 """
     10 
     11 from datetime import datetime
     12 from optparse import OptionParser
     13 from SimpleXMLRPCServer import SimpleXMLRPCServer
     14 
     15 import common
     16 from autotest_lib.client.cros.faft.rpc_functions import RPCFunctions
     17 
     18 
     19 def main():
     20     """The Main program, to run the XMLRPC server."""
     21     parser = OptionParser(usage='Usage: %prog [options]')
     22     parser.add_option('--port', type='int', dest='port', default=9990,
     23                       help='port number of XMLRPC server')
     24     (options, _) = parser.parse_args()
     25 
     26     print '[%s] XMLRPC Server: Spinning up FAFT server' % str(datetime.now())
     27     # Launch the XMLRPC server to provide FAFTClient commands.
     28     server = SimpleXMLRPCServer(('localhost', options.port), allow_none=True,
     29                                 logRequests=True)
     30     server.register_introspection_functions()
     31     server.register_instance(RPCFunctions())
     32     print '[%s] XMLRPC Server: Serving FAFT functions on port %s' % (
     33         str(datetime.now()), options.port)
     34 
     35     server.serve_forever()
     36 
     37 
     38 if __name__ == '__main__':
     39     main()
     40