Chromium Code Reviews| Index: appengine/swarming/handlers_endpoints.py |
| diff --git a/appengine/swarming/handlers_endpoints.py b/appengine/swarming/handlers_endpoints.py |
| index 5ced064a782d16430703831503df9e22a64268ce..c77823e6e8f73994c440cdc8d7577bf0ecdb5757 100644 |
| --- a/appengine/swarming/handlers_endpoints.py |
| +++ b/appengine/swarming/handlers_endpoints.py |
| @@ -620,14 +620,28 @@ class SwarmingBotsService(remote.Service): |
| """ |
| logging.info('%s', request) |
| now = utils.utcnow() |
| - q = bot_management.BotInfo.query().order(bot_management.BotInfo.key) |
| + q = bot_management.BotInfo.query() |
| for d in request.dimensions: |
| if not ':' in d: |
| raise endpoints.BadRequestException('Invalid dimensions') |
| parts = d.split(':', 1) |
| if len(parts) != 2 or any(i.strip() != i or not i for i in parts): |
| raise endpoints.BadRequestException('Invalid dimensions') |
| - q = q.filter(bot_management.BotInfo.dimensions_flat == d) |
| + if parts[0] == 'quarantined': |
|
M-A Ruel
2016/08/08 19:29:51
Please change BotsRequest with formal arguments in
kjlubick
2016/08/08 20:12:05
Done. Should I update BotsCount (line 657ish) to
M-A Ruel
2016/08/08 20:28:00
Yes it should match.
|
| + if parts[1] == 'true': |
| + q = q.filter(bot_management.BotInfo.quarantined == True) |
| + elif parts[1] == 'false': |
| + q = q.filter(bot_management.BotInfo.quarantined == False) |
| + elif parts[0] == 'is_dead': |
| + dt = datetime.timedelta( |
| + seconds=config.settings().bot_death_timeout_secs) |
| + timeout = now - dt |
| + if parts[1] == 'true': |
| + q = q.filter(bot_management.BotInfo.last_seen_ts < timeout) |
| + elif parts[1] == 'false': |
| + q = q.filter(bot_management.BotInfo.last_seen_ts > timeout) |
| + else: |
| + q = q.filter(bot_management.BotInfo.dimensions_flat == d) |
| bots, cursor = datastore_utils.fetch_page(q, request.limit, request.cursor) |
| return swarming_rpcs.BotList( |
| cursor=cursor, |