blob: ebe01d14226aab47b6bf557348e8013b01f09de4 [file] [log] [blame]
Dan Shi07e09af2013-04-12 09:31:29 -07001import sys
2
Gabe Black1e1c41b2015-02-04 23:55:15 -08003from autotest_lib.client.common_lib.cros.graphite import autotest_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)
Gabe Black1e1c41b2015-02-04 23:55:15 -080018 timer = autotest_stats.Timer('reset_time')
Dan Shi07e09af2013-04-12 09:31:29 -070019 timer.start()
Alex Miller667b5f22014-02-28 15:33:39 -080020
Dan Shi07e09af2013-04-12 09:31:29 -070021 # Assume cleanup always runs first.
22 host.cleanup()
Alex Miller667b5f22014-02-28 15:33:39 -080023 provision.run_special_task_actions(job, host, labels_list,
24 provision.Cleanup)
25
Dan Shi07e09af2013-04-12 09:31:29 -070026 host.verify()
Alex Miller667b5f22014-02-28 15:33:39 -080027 provision.run_special_task_actions(job, host, labels_list,
28 provision.Verify)
Dan Shi07e09af2013-04-12 09:31:29 -070029 except Exception as e:
Alex Miller789d6f12014-05-02 13:11:15 -070030 logging.exception(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 :