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 """Internal bot API handlers.""" | 5 """Internal bot API handlers.""" |
| 6 | 6 |
| 7 import base64 | 7 import base64 |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import re | 10 import re |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 def _cmd_run(self, request, run_result_key, bot_id): | 376 def _cmd_run(self, request, run_result_key, bot_id): |
| 377 cmd = None | 377 cmd = None |
| 378 if request.properties.commands: | 378 if request.properties.commands: |
| 379 cmd = request.properties.commands[0] | 379 cmd = request.properties.commands[0] |
| 380 elif request.properties.command: | 380 elif request.properties.command: |
| 381 cmd = request.properties.command | 381 cmd = request.properties.command |
| 382 out = { | 382 out = { |
| 383 'cmd': 'run', | 383 'cmd': 'run', |
| 384 'manifest': { | 384 'manifest': { |
| 385 'bot_id': bot_id, | 385 'bot_id': bot_id, |
| 386 'cipd_input': { | |
| 387 'client_package': ( | |
|
M-A Ruel
2016/05/12 13:49:45
() not needed
| |
| 388 request.properties.cipd_input.client_package.to_dict()), | |
| 389 'packages': [ | |
| 390 p.to_dict() for p in request.properties.cipd_input.packages | |
| 391 ], | |
| 392 'server': request.properties.cipd_input.server, | |
| 393 } if request.properties.cipd_input else None, | |
| 386 'command': cmd, | 394 'command': cmd, |
| 387 'dimensions': request.properties.dimensions, | 395 'dimensions': request.properties.dimensions, |
| 388 'env': request.properties.env, | 396 'env': request.properties.env, |
| 389 'extra_args': request.properties.extra_args, | 397 'extra_args': request.properties.extra_args, |
| 390 'grace_period': request.properties.grace_period_secs, | 398 'grace_period': request.properties.grace_period_secs, |
| 391 'hard_timeout': request.properties.execution_timeout_secs, | 399 'hard_timeout': request.properties.execution_timeout_secs, |
| 392 'host': utils.get_versioned_hosturl(), | 400 'host': utils.get_versioned_hosturl(), |
| 393 'io_timeout': request.properties.io_timeout_secs, | 401 'io_timeout': request.properties.io_timeout_secs, |
| 394 'isolated': { | 402 'isolated': { |
| 395 'input': request.properties.inputs_ref.isolated, | 403 'input': request.properties.inputs_ref.isolated, |
| 404 'namespace': request.properties.inputs_ref.namespace, | |
| 396 'server': request.properties.inputs_ref.isolatedserver, | 405 'server': request.properties.inputs_ref.isolatedserver, |
| 397 'namespace': request.properties.inputs_ref.namespace, | |
| 398 } if request.properties.inputs_ref else None, | 406 } if request.properties.inputs_ref else None, |
| 399 'packages': [ | |
| 400 { | |
| 401 'package_name': p.package_name, | |
| 402 'version': p.version, | |
| 403 } | |
| 404 for p in request.properties.packages | |
| 405 ], | |
| 406 'task_id': task_pack.pack_run_result_key(run_result_key), | 407 'task_id': task_pack.pack_run_result_key(run_result_key), |
| 407 }, | 408 }, |
| 408 } | 409 } |
| 409 self.send_response(utils.to_json_encodable(out)) | 410 self.send_response(utils.to_json_encodable(out)) |
| 410 | 411 |
| 411 def _cmd_sleep(self, sleep_streak, quarantined): | 412 def _cmd_sleep(self, sleep_streak, quarantined): |
| 412 out = { | 413 out = { |
| 413 'cmd': 'sleep', | 414 'cmd': 'sleep', |
| 414 'duration': task_scheduler.exponential_backoff(sleep_streak), | 415 'duration': task_scheduler.exponential_backoff(sleep_streak), |
| 415 'quarantined': quarantined, | 416 'quarantined': quarantined, |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 ('/swarming/api/v1/bot/poll', BotPollHandler), | 676 ('/swarming/api/v1/bot/poll', BotPollHandler), |
| 676 ('/swarming/api/v1/bot/server_ping', ServerPingHandler), | 677 ('/swarming/api/v1/bot/server_ping', ServerPingHandler), |
| 677 ('/swarming/api/v1/bot/task_update', BotTaskUpdateHandler), | 678 ('/swarming/api/v1/bot/task_update', BotTaskUpdateHandler), |
| 678 ('/swarming/api/v1/bot/task_update/<task_id:[a-f0-9]+>', | 679 ('/swarming/api/v1/bot/task_update/<task_id:[a-f0-9]+>', |
| 679 BotTaskUpdateHandler), | 680 BotTaskUpdateHandler), |
| 680 ('/swarming/api/v1/bot/task_error', BotTaskErrorHandler), | 681 ('/swarming/api/v1/bot/task_error', BotTaskErrorHandler), |
| 681 ('/swarming/api/v1/bot/task_error/<task_id:[a-f0-9]+>', | 682 ('/swarming/api/v1/bot/task_error/<task_id:[a-f0-9]+>', |
| 682 BotTaskErrorHandler), | 683 BotTaskErrorHandler), |
| 683 ] | 684 ] |
| 684 return [webapp2.Route(*i) for i in routes] | 685 return [webapp2.Route(*i) for i in routes] |
| OLD | NEW |