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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 - botobj: 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 - botobj: 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 |