Prashanth B | 79441d9 | 2014-04-29 08:38:15 -0700 | [diff] [blame] | 1 | #! /usr/bin/python |
| 2 | |
| 3 | import os |
| 4 | import argparse |
| 5 | import datetime as datetime_base |
| 6 | from datetime import datetime |
| 7 | import logging |
| 8 | import sys |
| 9 | |
| 10 | import common |
| 11 | from autotest_lib.frontend import setup_django_environment |
| 12 | from autotest_lib.frontend.afe import models |
| 13 | from autotest_lib.server.cros.dynamic_suite import job_status |
| 14 | |
| 15 | |
| 16 | def find_hostnames(pool='bvt', board='x86-mario'): |
| 17 | return os.popen("/usr/local/autotest/cli/atest host list | " |
| 18 | "grep pool:%s | grep %s | " |
| 19 | "awk '{ print $1}'" % (pool, board)).read().split('\n') |
| 20 | |
| 21 | |
| 22 | def _parse_args(args): |
| 23 | if not args: |
| 24 | print ('Try ./contrib/poolhistory.py pool -name bvt -board x86-mario -start ' |
| 25 | '"2014-04-25 02:57:16" -end "2014-04-25 04:32:06"') |
| 26 | sys.exit(0) |
| 27 | parser = argparse.ArgumentParser( |
| 28 | description='A script to get the special tasks on a host or job.') |
| 29 | subparsers = parser.add_subparsers(help='Get tasks based on a job or host.') |
| 30 | parser_host = subparsers.add_parser('pool', help='Per host analysis mode.') |
| 31 | parser_host.add_argument('-name', |
| 32 | help='Hostname for which you would like tasks.') |
| 33 | parser_host.add_argument('-board', |
| 34 | help='Hostname for which you would like tasks.') |
| 35 | parser_host.add_argument( |
| 36 | '-start', help='Start time. Eg: 2014-03-25 16:26:31') |
| 37 | parser_host.add_argument( |
| 38 | '-end', help='End time Eg: 2014-03-25 18:26:31.') |
| 39 | return parser.parse_args(args) |
| 40 | |
| 41 | |
| 42 | if __name__ == '__main__': |
| 43 | args = _parse_args(sys.argv[1:]) |
| 44 | print 'Pool %s, board %s' % (args.name, args.board) |
| 45 | for name in find_hostnames(args.name, args.board): |
| 46 | print 'Host: %s' % name |
| 47 | print os.popen('/usr/local/autotest/contrib/onerous_tasks.py host -name %s ' |
| 48 | '-start "%s" -end "%s"' % (name, args.start, args.end)).read() |