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

Side by Side Diff: appengine/swarming/handlers_endpoints.py

Issue 1942143002: swarming: isolate defaults (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@swarming-ns-re
Patch Set: nit Created 4 years, 7 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
« no previous file with comments | « no previous file | appengine/swarming/handlers_endpoints_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if request.properties is None:
M-A Ruel 2016/05/12 13:48:25 in general we use the short form: if not request.
nodir 2016/05/12 22:00:09 Done.
272 raise endpoints.BadRequestException('properties are required')
273
274 # Apply isolate defaults.
275 cfg = config.settings()
276 if cfg.isolate.default_server and cfg.isolate.default_namespace:
277 request.properties.inputs_ref = (
278 request.properties.inputs_ref or swarming_rpcs.FilesRef())
279 request.properties.inputs_ref.isolatedserver = (
280 request.properties.inputs_ref.isolatedserver or
281 cfg.isolate.default_server)
282 request.properties.inputs_ref.namespace = (
283 request.properties.inputs_ref.namespace or
284 cfg.isolate.default_namespace)
285
270 try: 286 try:
271 request = message_conversion.new_task_request_from_rpc( 287 request = message_conversion.new_task_request_from_rpc(
272 request, utils.utcnow()) 288 request, utils.utcnow())
273 posted_request = task_request.make_request(request, acl.is_bot_or_admin()) 289 posted_request = task_request.make_request(request, acl.is_bot_or_admin())
274 except (datastore_errors.BadValueError, TypeError, ValueError) as e: 290 except (datastore_errors.BadValueError, TypeError, ValueError) as e:
275 raise endpoints.BadRequestException(e.message) 291 raise endpoints.BadRequestException(e.message)
276 292
277 result_summary = task_scheduler.schedule_request(posted_request) 293 result_summary = task_scheduler.schedule_request(posted_request)
278 294
279 previous_result = None 295 previous_result = None
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 parts = d.split(':', 1) 614 parts = d.split(':', 1)
599 if len(parts) != 2 or any(i.strip() != i or not i for i in parts): 615 if len(parts) != 2 or any(i.strip() != i or not i for i in parts):
600 raise endpoints.BadRequestException('Invalid dimensions') 616 raise endpoints.BadRequestException('Invalid dimensions')
601 q = q.filter(bot_management.BotInfo.dimensions_flat == d) 617 q = q.filter(bot_management.BotInfo.dimensions_flat == d)
602 bots, cursor = datastore_utils.fetch_page(q, request.limit, request.cursor) 618 bots, cursor = datastore_utils.fetch_page(q, request.limit, request.cursor)
603 return swarming_rpcs.BotList( 619 return swarming_rpcs.BotList(
604 cursor=cursor, 620 cursor=cursor,
605 death_timeout=config.settings().bot_death_timeout_secs, 621 death_timeout=config.settings().bot_death_timeout_secs,
606 items=[message_conversion.bot_info_to_rpc(bot, now) for bot in bots], 622 items=[message_conversion.bot_info_to_rpc(bot, now) for bot in bots],
607 now=now) 623 now=now)
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/handlers_endpoints_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698