• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import sys
2
3from autotest_lib.client.common_lib.cros.graphite import autotest_stats
4from 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
11
12def reset(machine):
13    print 'Starting to reset host %s' % machine
14    timer = None
15    try:
16        job.record('START', None, 'reset')
17        target = hosts.create_target_machine(machine, initialize=False,
18                                             auto_monitor=False)
19        timer = autotest_stats.Timer('reset_time')
20        timer.start()
21
22        # Assume cleanup always runs first.
23        target.cleanup()
24        provision.run_special_task_actions(job, target, labels_list,
25                                           provision.Cleanup)
26
27        target.verify()
28        provision.run_special_task_actions(job, target, labels_list,
29                                           provision.Verify)
30    except Exception as e:
31        logging.exception(e)
32        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)
39    finally:
40        if timer:
41            timer.stop()
42
43
44job.parallel_simple(reset, machines)
45
46# vim: set syntax=python :
47