Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """This module defines Swarming Server endpoints handlers.""" | 5 """This module defines Swarming Server endpoints handlers.""" |
| 6 | 6 |
| 7 import datetime | 7 import datetime |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 | 10 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 swarming_rpcs.NewTaskRequest, swarming_rpcs.TaskRequestMetadata) | 260 swarming_rpcs.NewTaskRequest, swarming_rpcs.TaskRequestMetadata) |
| 261 @auth.require(acl.is_bot_or_user) | 261 @auth.require(acl.is_bot_or_user) |
| 262 def new(self, request): | 262 def new(self, request): |
| 263 """Creates a new task. | 263 """Creates a new task. |
| 264 | 264 |
| 265 The task will be enqueued in the tasks list and will be executed at the | 265 The task will be enqueued in the tasks list and will be executed at the |
| 266 earliest opportunity by a bot that has at least the dimensions as described | 266 earliest opportunity by a bot that has at least the dimensions as described |
| 267 in the task request. | 267 in the task request. |
| 268 """ | 268 """ |
| 269 logging.info('%s', request) | 269 logging.info('%s', request) |
| 270 | |
| 271 # Apply isolate defaults. | |
| 272 cfg = config.settings() | |
| 273 if cfg.isolate.default_server_host and cfg.isolate.default_namespace: | |
| 274 request.properties = request.properties or swarming_rpcs.TaskProperties() | |
|
M-A Ruel
2016/05/10 15:27:40
request.properties cannot be None so this is not n
nodir
2016/05/10 18:49:49
Done.
| |
| 275 default_server = 'https://' + cfg.isolate.default_server_host | |
|
M-A Ruel
2016/05/10 15:27:40
Do not prepend https:// here, it should be listed
nodir
2016/05/10 18:49:49
Done.
| |
| 276 inputs_ref = request.properties.inputs_ref | |
| 277 if inputs_ref: | |
| 278 inputs_ref.isolatedserver = inputs_ref.isolatedserver or default_server | |
| 279 inputs_ref.namespace = ( | |
| 280 inputs_ref.namespace or cfg.isolate.default_namespace) | |
| 281 elif not request.properties.outputs_target: | |
|
M-A Ruel
2016/05/10 15:27:40
Please remove.
nodir
2016/05/10 18:49:49
Done in patchset 'rebased'
| |
| 282 request.properties.outputs_target = ( | |
| 283 swarming_rpcs.IsolatedOutputsTarget( | |
| 284 isolatedserver=default_server, | |
| 285 namespace=cfg.isolate.default_namespace)) | |
| 286 | |
| 270 try: | 287 try: |
| 271 request = message_conversion.new_task_request_from_rpc( | 288 request = message_conversion.new_task_request_from_rpc( |
| 272 request, utils.utcnow()) | 289 request, utils.utcnow()) |
| 273 posted_request = task_request.make_request(request, acl.is_bot_or_admin()) | 290 posted_request = task_request.make_request(request, acl.is_bot_or_admin()) |
| 274 except (datastore_errors.BadValueError, TypeError, ValueError) as e: | 291 except (datastore_errors.BadValueError, TypeError, ValueError) as e: |
| 275 raise endpoints.BadRequestException(e.message) | 292 raise endpoints.BadRequestException(e.message) |
| 276 | 293 |
| 277 result_summary = task_scheduler.schedule_request(posted_request) | 294 result_summary = task_scheduler.schedule_request(posted_request) |
| 278 | 295 |
| 279 previous_result = None | 296 previous_result = None |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 parts = d.split(':', 1) | 615 parts = d.split(':', 1) |
| 599 if len(parts) != 2 or any(i.strip() != i or not i for i in parts): | 616 if len(parts) != 2 or any(i.strip() != i or not i for i in parts): |
| 600 raise endpoints.BadRequestException('Invalid dimensions') | 617 raise endpoints.BadRequestException('Invalid dimensions') |
| 601 q = q.filter(bot_management.BotInfo.dimensions_flat == d) | 618 q = q.filter(bot_management.BotInfo.dimensions_flat == d) |
| 602 bots, cursor = datastore_utils.fetch_page(q, request.limit, request.cursor) | 619 bots, cursor = datastore_utils.fetch_page(q, request.limit, request.cursor) |
| 603 return swarming_rpcs.BotList( | 620 return swarming_rpcs.BotList( |
| 604 cursor=cursor, | 621 cursor=cursor, |
| 605 death_timeout=config.settings().bot_death_timeout_secs, | 622 death_timeout=config.settings().bot_death_timeout_secs, |
| 606 items=[message_conversion.bot_info_to_rpc(bot, now) for bot in bots], | 623 items=[message_conversion.bot_info_to_rpc(bot, now) for bot in bots], |
| 607 now=now) | 624 now=now) |
| OLD | NEW |