• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
8It launches a XMLRPC server and exposes the functions in RPCFunctions().
9"""
10
11from datetime import datetime
12from optparse import OptionParser
13from SimpleXMLRPCServer import SimpleXMLRPCServer
14
15import common
16from autotest_lib.client.cros.faft.rpc_functions import RPCFunctions
17
18
19def 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
38if __name__ == '__main__':
39    main()
40