OLD | NEW |
1 # coding: utf-8 | 1 # coding: utf-8 |
2 # Copyright 2013 The LUCI Authors. All rights reserved. | 2 # Copyright 2013 The LUCI Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
5 | 5 |
6 """This file is meant to be overriden by the server's specific copy. | 6 """This file is meant to be overriden by the server's specific copy. |
7 | 7 |
8 You can upload a new version via /restricted/upload/bot_config. | 8 You can upload a new version via /restricted/upload/bot_config. |
9 | 9 |
10 There's 3 types of functions in this file: | 10 There's 3 types of functions in this file: |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 The dimensions are what are used to select the bot that can run each task. | 34 The dimensions are what are used to select the bot that can run each task. |
35 | 35 |
36 The bot id will be automatically selected based on the hostname with | 36 The bot id will be automatically selected based on the hostname with |
37 os_utilities.get_dimensions(). If you want something more special, specify it | 37 os_utilities.get_dimensions(). If you want something more special, specify it |
38 in your bot_config.py and override the item 'id'. | 38 in your bot_config.py and override the item 'id'. |
39 | 39 |
40 See https://code.google.com/p/swarming/wiki/SwarmingMagicValues. | 40 See https://code.google.com/p/swarming/wiki/SwarmingMagicValues. |
41 | 41 |
42 Arguments: | 42 Arguments: |
43 - botobj: bot.Bot instance or None. | 43 - bot: bot.Bot instance or None. |
44 """ | 44 """ |
45 return os_utilities.get_dimensions() | 45 return os_utilities.get_dimensions() |
46 | 46 |
47 | 47 |
48 def get_state(bot): | 48 def get_state(bot): |
49 """Returns dict with a state of the bot reported to the server with each poll. | 49 """Returns dict with a state of the bot reported to the server with each poll. |
50 | 50 |
51 It is only for dynamic state that changes while bot is running for information | 51 It is only for dynamic state that changes while bot is running for information |
52 for the sysadmins. | 52 for the sysadmins. |
53 | 53 |
54 The server can not use this state for immediate scheduling purposes (use | 54 The server can not use this state for immediate scheduling purposes (use |
55 'dimensions' for that), but it can use it for maintenance and bookkeeping | 55 'dimensions' for that), but it can use it for maintenance and bookkeeping |
56 tasks. | 56 tasks. |
57 | 57 |
58 See https://code.google.com/p/swarming/wiki/SwarmingMagicValues. | 58 See https://code.google.com/p/swarming/wiki/SwarmingMagicValues. |
59 | 59 |
60 Arguments: | 60 Arguments: |
61 - botobj: bot.Bot instance or None. | 61 - bot: bot.Bot instance or None. |
62 """ | 62 """ |
63 return os_utilities.get_state() | 63 return os_utilities.get_state() |
64 | 64 |
65 | 65 |
| 66 def get_authentication_headers(bot): |
| 67 """Returns authentication headers and their expiration time. |
| 68 |
| 69 The returned headers will be passed with each HTTP request to the Swarming |
| 70 server (and only Swarming server). The bot will use the returned headers until |
| 71 they are close to expiration (usually 6 min, see AUTH_HEADERS_EXPIRATION_SEC |
| 72 in remote_client.py), and then it'll attempt to refresh them by calling |
| 73 get_authentication_headers again. |
| 74 |
| 75 Can be used to implement per-bot authentication. If no headers are returned, |
| 76 the server will use only IP whitelist for bot authentication. |
| 77 |
| 78 May be called by different threads, but never concurrently. |
| 79 |
| 80 Arguments: |
| 81 - bot: bot.Bot instance. |
| 82 |
| 83 Returns: |
| 84 Tuple (dict with headers or None, unix timestamp of when they expire). |
| 85 """ |
| 86 return (None, None) |
| 87 |
| 88 |
66 ### Hooks | 89 ### Hooks |
67 | 90 |
68 | 91 |
69 def on_bot_shutdown(bot): | 92 def on_bot_shutdown(bot): |
70 """Hook function called when the bot shuts down, usually rebooting. | 93 """Hook function called when the bot shuts down, usually rebooting. |
71 | 94 |
72 It's a good time to do other kinds of cleanup. | 95 It's a good time to do other kinds of cleanup. |
73 | 96 |
74 Arguments: | 97 Arguments: |
75 - bot: bot.Bot instance. | 98 - bot: bot.Bot instance. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 def setup_bot(bot): | 151 def setup_bot(bot): |
129 """Does one time initialization for this bot. | 152 """Does one time initialization for this bot. |
130 | 153 |
131 Returns True if it's fine to start the bot right away. Otherwise, the calling | 154 Returns True if it's fine to start the bot right away. Otherwise, the calling |
132 script should exit. | 155 script should exit. |
133 | 156 |
134 Example: making this script starts automatically on user login via | 157 Example: making this script starts automatically on user login via |
135 os_utilities.set_auto_startup_win() or os_utilities.set_auto_startup_osx(). | 158 os_utilities.set_auto_startup_win() or os_utilities.set_auto_startup_osx(). |
136 """ | 159 """ |
137 return True | 160 return True |
OLD | NEW |