blob: 7db915e9e5221513d668715387a9f137525844bd [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):
Simran Basi1bf60eb2015-12-01 16:39:29 -080013 print 'Starting to reset host %s' % machine
Dan Shi07e09af2013-04-12 09:31:29 -070014 timer = None
15 try:
Alex Miller667b5f22014-02-28 15:33:39 -080016 job.record('START', None, 'reset')
Dan Shid7f12422016-01-04 11:51:32 -080017 target = hosts.create_target_machine(machine, initialize=False,
18 auto_monitor=False)
Gabe Black1e1c41b2015-02-04 23:55:15 -080019 timer = autotest_stats.Timer('reset_time')
Dan Shi07e09af2013-04-12 09:31:29 -070020 timer.start()
Alex Miller667b5f22014-02-28 15:33:39 -080021
Dan Shi07e09af2013-04-12 09:31:29 -070022 # Assume cleanup always runs first.
Dan Shid7f12422016-01-04 11:51:32 -080023 target.cleanup()
24 provision.run_special_task_actions(job, target, labels_list,
Alex Miller667b5f22014-02-28 15:33:39 -080025 provision.Cleanup)
26
Dan Shid7f12422016-01-04 11:51:32 -080027 target.verify()
28 provision.run_special_task_actions(job, target, labels_list,
Alex Miller667b5f22014-02-28 15:33:39 -080029 provision.Verify)
Dan Shi07e09af2013-04-12 09:31:29 -070030 except Exception as e:
Alex Miller789d6f12014-05-02 13:11:15 -070031 logging.exception(e)
Alex Miller667b5f22014-02-28 15:33:39 -080032 job.record('END FAIL', None, 'reset')
33 # See the provision control segment for the explanation of why we're
34 # doing this.
35 raise Exception('')
36 else:
37 job.record('END GOOD', None, 'reset',
38 '%s reset successfully' % machine)
Dan Shi07e09af2013-04-12 09:31:29 -070039 finally:
40 if timer:
41 timer.stop()
42
43
44job.parallel_simple(reset, machines)
Alex Miller667b5f22014-02-28 15:33:39 -080045
46# vim: set syntax=python :