Home | History | Annotate | Download | only in control_segments
      1 from autotest_lib.server import utils
      2 from autotest_lib.server.cros import provision
      3 
      4 try:
      5     from chromite.lib import metrics
      6 except ImportError:
      7     metrics = utils.metrics_mock
      8 
      9 
     10 DURATION_METRIC = 'chromeos/autotest/autoserv/verify_duration'
     11 
     12 
     13 # A string of the form 'label1,label2:value,label3'.
     14 job_labels = locals().get('job_labels') or ','.join(args)
     15 labels_list = [l.strip() for l in job_labels.split(',') if l]
     16 
     17 
     18 def 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.run_special_task_actions(job, target, labels_list,
     29                                                provision.Verify)
     30     except Exception:
     31         logging.exception('Verify failed due to Exception.')
     32         job.record('END FAIL', None, 'verify')
     33         # See the provision control segment for the explanation of why we're
     34         # doing this.
     35         raise Exception('')
     36     else:
     37         hostname = utils.get_hostname_from_machine(machine)
     38         job.record('END GOOD', None, 'verify',
     39                    '%s verified successfully' % hostname)
     40 
     41 
     42 job.parallel_simple(verify, machines)
     43 
     44 # vim: set syntax=python :
     45