Dan Shi | 07e09af | 2013-04-12 09:31:29 -0700 | [diff] [blame] | 1 | import sys |
| 2 | |
| 3 | from autotest_lib.site_utils.graphite import stats |
Alex Miller | 667b5f2 | 2014-02-28 15:33:39 -0800 | [diff] [blame^] | 4 | from autotest_lib.server.cros import provision |
| 5 | |
| 6 | |
| 7 | # A string of the form 'label1,label2:value,label3'. |
| 8 | job_labels = locals().get('job_labels') or ','.join(args) |
| 9 | labels_list = [l.strip() for l in job_labels.split(',') if l] |
| 10 | |
Dan Shi | 07e09af | 2013-04-12 09:31:29 -0700 | [diff] [blame] | 11 | |
| 12 | def reset(machine): |
| 13 | print 'Starting to reset host ' + machine |
| 14 | timer = None |
| 15 | try: |
Alex Miller | 667b5f2 | 2014-02-28 15:33:39 -0800 | [diff] [blame^] | 16 | job.record('START', None, 'reset') |
Dan Shi | 07e09af | 2013-04-12 09:31:29 -0700 | [diff] [blame] | 17 | host = hosts.create_host(machine, initialize=False, auto_monitor=False) |
| 18 | timer = stats.Timer('reset_time.%s' % |
| 19 | host._get_board_from_afe()) |
| 20 | timer.start() |
Alex Miller | 667b5f2 | 2014-02-28 15:33:39 -0800 | [diff] [blame^] | 21 | |
Dan Shi | 07e09af | 2013-04-12 09:31:29 -0700 | [diff] [blame] | 22 | # Assume cleanup always runs first. |
| 23 | host.cleanup() |
Alex Miller | 667b5f2 | 2014-02-28 15:33:39 -0800 | [diff] [blame^] | 24 | provision.run_special_task_actions(job, host, labels_list, |
| 25 | provision.Cleanup) |
| 26 | |
Dan Shi | 07e09af | 2013-04-12 09:31:29 -0700 | [diff] [blame] | 27 | host.verify() |
Alex Miller | 667b5f2 | 2014-02-28 15:33:39 -0800 | [diff] [blame^] | 28 | provision.run_special_task_actions(job, host, labels_list, |
| 29 | provision.Verify) |
Dan Shi | 07e09af | 2013-04-12 09:31:29 -0700 | [diff] [blame] | 30 | except Exception as e: |
Alex Miller | 667b5f2 | 2014-02-28 15:33:39 -0800 | [diff] [blame^] | 31 | job.record('END FAIL', None, 'reset') |
| 32 | # See the provision control segment for the explanation of why we're |
| 33 | # doing this. |
| 34 | raise Exception('') |
| 35 | else: |
| 36 | job.record('END GOOD', None, 'reset', |
| 37 | '%s reset successfully' % machine) |
Dan Shi | 07e09af | 2013-04-12 09:31:29 -0700 | [diff] [blame] | 38 | finally: |
| 39 | if timer: |
| 40 | timer.stop() |
| 41 | |
| 42 | |
| 43 | job.parallel_simple(reset, machines) |
Alex Miller | 667b5f2 | 2014-02-28 15:33:39 -0800 | [diff] [blame^] | 44 | |
| 45 | # vim: set syntax=python : |