blob: e8565806393e32199f5697cbfc9961f57523ea4c [file] [log] [blame]
Dan Shi07e09af2013-04-12 09:31:29 -07001import sys
2
3from autotest_lib.site_utils.graphite import stats
Alex Miller667b5f22014-02-28 15:33:39 -08004from autotest_lib.server.cros import provision
5
6
7# A string of the form 'label1,label2:value,label3'.
8job_labels = locals().get('job_labels') or ','.join(args)
9labels_list = [l.strip() for l in job_labels.split(',') if l]
10
Dan Shi07e09af2013-04-12 09:31:29 -070011
12def reset(machine):
13 print 'Starting to reset host ' + machine
14 timer = None
15 try:
Alex Miller667b5f22014-02-28 15:33:39 -080016 job.record('START', None, 'reset')
Dan Shi07e09af2013-04-12 09:31:29 -070017 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 Miller667b5f22014-02-28 15:33:39 -080021
Dan Shi07e09af2013-04-12 09:31:29 -070022 # Assume cleanup always runs first.
23 host.cleanup()
Alex Miller667b5f22014-02-28 15:33:39 -080024 provision.run_special_task_actions(job, host, labels_list,
25 provision.Cleanup)
26
Dan Shi07e09af2013-04-12 09:31:29 -070027 host.verify()
Alex Miller667b5f22014-02-28 15:33:39 -080028 provision.run_special_task_actions(job, host, labels_list,
29 provision.Verify)
Dan Shi07e09af2013-04-12 09:31:29 -070030 except Exception as e:
Alex Miller667b5f22014-02-28 15:33:39 -080031 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 Shi07e09af2013-04-12 09:31:29 -070038 finally:
39 if timer:
40 timer.stop()
41
42
43job.parallel_simple(reset, machines)
Alex Miller667b5f22014-02-28 15:33:39 -080044
45# vim: set syntax=python :