blob: fab380f2804fc83c8b27f0b32fb6ca9f3ac82baf [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
Richard Barnette28aa6892016-06-10 13:00:58 -07004from autotest_lib.server import utils
Alex Miller667b5f22014-02-28 15:33:39 -08005from autotest_lib.server.cros import provision
6
7
8# A string of the form 'label1,label2:value,label3'.
9job_labels = locals().get('job_labels') or ','.join(args)
10labels_list = [l.strip() for l in job_labels.split(',') if l]
11
Dan Shi07e09af2013-04-12 09:31:29 -070012
13def reset(machine):
Simran Basi1bf60eb2015-12-01 16:39:29 -080014 print 'Starting to reset host %s' % machine
Dan Shi07e09af2013-04-12 09:31:29 -070015 timer = None
16 try:
Alex Miller667b5f22014-02-28 15:33:39 -080017 job.record('START', None, 'reset')
Dan Shid7f12422016-01-04 11:51:32 -080018 target = hosts.create_target_machine(machine, initialize=False,
19 auto_monitor=False)
Gabe Black1e1c41b2015-02-04 23:55:15 -080020 timer = autotest_stats.Timer('reset_time')
Dan Shi07e09af2013-04-12 09:31:29 -070021 timer.start()
Alex Miller667b5f22014-02-28 15:33:39 -080022
Dan Shi07e09af2013-04-12 09:31:29 -070023 # Assume cleanup always runs first.
Dan Shid7f12422016-01-04 11:51:32 -080024 target.cleanup()
25 provision.run_special_task_actions(job, target, labels_list,
Alex Miller667b5f22014-02-28 15:33:39 -080026 provision.Cleanup)
27
Dan Shid7f12422016-01-04 11:51:32 -080028 target.verify()
29 provision.run_special_task_actions(job, target, labels_list,
Alex Miller667b5f22014-02-28 15:33:39 -080030 provision.Verify)
Dan Shi07e09af2013-04-12 09:31:29 -070031 except Exception as e:
Alex Miller789d6f12014-05-02 13:11:15 -070032 logging.exception(e)
Alex Miller667b5f22014-02-28 15:33:39 -080033 job.record('END FAIL', None, 'reset')
34 # See the provision control segment for the explanation of why we're
35 # doing this.
36 raise Exception('')
37 else:
Richard Barnette28aa6892016-06-10 13:00:58 -070038 hostname = utils.get_hostname_from_machine(machine)
Alex Miller667b5f22014-02-28 15:33:39 -080039 job.record('END GOOD', None, 'reset',
Richard Barnette28aa6892016-06-10 13:00:58 -070040 '%s reset successfully' % hostname)
Dan Shi07e09af2013-04-12 09:31:29 -070041 finally:
42 if timer:
43 timer.stop()
44
45
46job.parallel_simple(reset, machines)
Alex Miller667b5f22014-02-28 15:33:39 -080047
48# vim: set syntax=python :