Chromium Code Reviews| Index: testing/legion/client_controller.py |
| diff --git a/testing/legion/client_controller.py b/testing/legion/client_controller.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..57f2d3ffc94fdcf04a160edba427ca75d517e7c5 |
| --- /dev/null |
| +++ b/testing/legion/client_controller.py |
| @@ -0,0 +1,49 @@ |
| +#!/usr/bin/env python |
|
Marc-Antoine Ruel (Google)
2015/01/30 21:58:38
Saved 19 lines, or 28% of lines, not too bad. :)
I
Mike Meade
2015/02/03 01:18:07
Acknowledged.
|
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| +"""The main client_controller code. |
| + |
| +This code is the main entry point for the client machines and handles |
| +registering with the host server and running the local RPC server. |
| +""" |
| + |
| +import argparse |
| +import logging |
| +import socket |
| +import sys |
| +import time |
| + |
| +#pylint: disable=relative-import |
| +import client_rpc_server |
| +import common_lib |
| +import discovery_server |
| + |
| + |
| +def main(): |
| + common_lib.InitLogging() |
| + common_lib.LogCommandLine() |
| + logging.info('Client controller starting') |
| + |
| + parser = argparse.ArgumentParser() |
| + parser.add_argument('--otp') |
| + parser.add_argument('--host') |
| + parser.add_argument('--idle-timeout', type=int) |
| + args, _ = parser.parse_known_args() |
| + |
| + logging.info( |
| + 'Registering with discovery server using OTP %s', args.otp) |
| + server = discovery_server.DiscoveryServer.Connect(args.host).RegisterClient( |
| + args.otp, common_lib.MY_IP) |
| + |
| + server = client_rpc_server.RPCServer() |
| + server.AddAuthorizedAddress(args.host) |
| + if args.idle_timeout: |
| + server.SetIdleTimeout(args.idle_timeout) |
| + |
| + server.serve_forever() |
| + return 0 |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |