• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from autotest_lib.server import utils
2from autotest_lib.server.cros import provision
3
4try:
5    from chromite.lib import metrics
6except ImportError:
7    metrics = utils.metrics_mock
8
9
10DURATION_METRIC = 'chromeos/autotest/autoserv/verify_duration'
11
12
13# A string of the form 'label1,label2:value,label3'.
14job_labels = locals().get('job_labels') or ','.join(args)
15labels_list = [l.strip() for l in job_labels.split(',') if l]
16
17
18def verify(machine):
19    print 'Initializing host %s' % machine
20    job.record('START', None, 'verify')
21    target = hosts.create_target_machine(machine,
22                                         try_lab_servo=True)
23    hostname = utils.get_hostname_from_machine(machine)
24    try:
25        with metrics.SecondsTimer(DURATION_METRIC,
26                                  fields={'dut_host_name': hostname}):
27            target.verify()
28            provision.Verify.run_task_actions(job, target, labels_list)
29    except Exception:
30        logging.exception('Verify failed due to Exception.')
31        job.record('END FAIL', None, 'verify')
32        # See the provision control segment for the explanation of why we're
33        # doing this.
34        raise Exception('')
35    else:
36        hostname = utils.get_hostname_from_machine(machine)
37        job.record('END GOOD', None, 'verify',
38                   '%s verified successfully' % hostname)
39
40
41job.parallel_simple(verify, machines)
42
43# vim: set syntax=python :
44