Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: testing/legion/client_controller.py

Issue 890773003: Adding the initial code for Omnibot multi-machine support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium 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 """The main client_controller code.
Marc-Antoine Ruel (Google) 2015/01/30 18:00:21 FYI, we generally keep an empty line in between th
Mike Meade 2015/01/30 21:04:04 Done.
6
7 This code is the main entry point for the client machines and handles
8 registering with the host server and running the local RPC server.
9 """
10 import argparse
11 import logging
12 import socket
13 import sys
14 import time
15
16 #pylint: disable=relative-import
17 import client_rpc_server
18 import common_lib
19 import discovery_server
20
21
22 def RegisterClient(host, otp):
23 """Register this client with the host's discovery server."""
24 server = discovery_server.DiscoveryServer.Connect(host)
25 logging.info(
26 'Registering with discovery server using OTP %s', otp)
27 server.RegisterClient(otp, common_lib.MY_IP)
28
29
30 def GetArgs():
Marc-Antoine Ruel (Google) 2015/01/30 18:00:21 Is there value in making it a function vs embeddin
Mike Meade 2015/01/30 21:04:04 Not explicitly. I was just trying to group by oper
31 """Parse the command line arguments."""
32 parser = argparse.ArgumentParser()
33 parser.add_argument('--otp')
34 parser.add_argument('--host')
35 parser.add_argument('--idle-timeout', type=int)
36 args, _ = parser.parse_known_args()
37 return args
38
39
40 def CreateRPCServer(host, idle_timeout=None):
41 """Create the client RPC server.
42
43 Args:
44 host: The address of the host machine.
45 idle_timeout: The timeout in seconds to set.
46
47 Returns:
48 An instance of client_rpc_server.RPCServer.
49 """
50 server = client_rpc_server.RPCServer()
Marc-Antoine Ruel (Google) 2015/01/30 18:00:21 same
Mike Meade 2015/01/30 21:04:04 Done.
51 server.AddAuthorizedAddress(host)
52 if idle_timeout:
53 server.SetIdleTimeout(idle_timeout)
54 return server
55
56
57 def main():
58 common_lib.InitLogging()
59 common_lib.LogCommandLine()
60 logging.info('Client controller starting')
61 args = GetArgs()
62 RegisterClient(args.host, args.otp)
63 server = CreateRPCServer(args.host, args.idle_timeout)
64 server.serve_forever()
65
66
67 if __name__ == '__main__':
68 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698