| 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 # TODO(maruel): Note the task if possible and hand it out on next poll. | 372 # TODO(maruel): Note the task if possible and hand it out on next poll. |
| 373 # https://code.google.com/p/swarming/issues/detail?id=130 | 373 # https://code.google.com/p/swarming/issues/detail?id=130 |
| 374 self.abort(500, 'Deadline') | 374 self.abort(500, 'Deadline') |
| 375 | 375 |
| 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 |
| 383 isolated = None |
| 384 if request.properties.inputs_ref: |
| 385 isolated = { |
| 386 'input': request.properties.inputs_ref.isolated, |
| 387 'server': request.properties.inputs_ref.isolatedserver, |
| 388 'namespace': request.properties.inputs_ref.namespace, |
| 389 } |
| 390 elif request.properties.outputs_target: |
| 391 isolated = { |
| 392 'input': None, |
| 393 'server': request.properties.inputs_ref.isolatedserver, |
| 394 'namespace': request.properties.inputs_ref.namespace, |
| 395 } |
| 396 |
| 382 out = { | 397 out = { |
| 383 'cmd': 'run', | 398 'cmd': 'run', |
| 384 'manifest': { | 399 'manifest': { |
| 385 'bot_id': bot_id, | 400 'bot_id': bot_id, |
| 386 'command': cmd, | 401 'command': cmd, |
| 387 'dimensions': request.properties.dimensions, | 402 'dimensions': request.properties.dimensions, |
| 388 'env': request.properties.env, | 403 'env': request.properties.env, |
| 389 'extra_args': request.properties.extra_args, | 404 'extra_args': request.properties.extra_args, |
| 390 'grace_period': request.properties.grace_period_secs, | 405 'grace_period': request.properties.grace_period_secs, |
| 391 'hard_timeout': request.properties.execution_timeout_secs, | 406 'hard_timeout': request.properties.execution_timeout_secs, |
| 392 'host': utils.get_versioned_hosturl(), | 407 'host': utils.get_versioned_hosturl(), |
| 393 'io_timeout': request.properties.io_timeout_secs, | 408 'io_timeout': request.properties.io_timeout_secs, |
| 394 'inputs_ref': request.properties.inputs_ref, | 409 'isolated': isolated, |
| 395 'packages': [ | 410 'packages': [ |
| 396 { | 411 { |
| 397 'package_name': p.package_name, | 412 'package_name': p.package_name, |
| 398 'version': p.version, | 413 'version': p.version, |
| 399 } | 414 } |
| 400 for p in request.properties.packages | 415 for p in request.properties.packages |
| 401 ], | 416 ], |
| 402 'task_id': task_pack.pack_run_result_key(run_result_key), | 417 'task_id': task_pack.pack_run_result_key(run_result_key), |
| 403 }, | 418 }, |
| 404 } | 419 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 ('/swarming/api/v1/bot/poll', BotPollHandler), | 682 ('/swarming/api/v1/bot/poll', BotPollHandler), |
| 668 ('/swarming/api/v1/bot/server_ping', ServerPingHandler), | 683 ('/swarming/api/v1/bot/server_ping', ServerPingHandler), |
| 669 ('/swarming/api/v1/bot/task_update', BotTaskUpdateHandler), | 684 ('/swarming/api/v1/bot/task_update', BotTaskUpdateHandler), |
| 670 ('/swarming/api/v1/bot/task_update/<task_id:[a-f0-9]+>', | 685 ('/swarming/api/v1/bot/task_update/<task_id:[a-f0-9]+>', |
| 671 BotTaskUpdateHandler), | 686 BotTaskUpdateHandler), |
| 672 ('/swarming/api/v1/bot/task_error', BotTaskErrorHandler), | 687 ('/swarming/api/v1/bot/task_error', BotTaskErrorHandler), |
| 673 ('/swarming/api/v1/bot/task_error/<task_id:[a-f0-9]+>', | 688 ('/swarming/api/v1/bot/task_error/<task_id:[a-f0-9]+>', |
| 674 BotTaskErrorHandler), | 689 BotTaskErrorHandler), |
| 675 ] | 690 ] |
| 676 return [webapp2.Route(*i) for i in routes] | 691 return [webapp2.Route(*i) for i in routes] |
| OLD | NEW |