blob: 230e3dd6547b23ea5d9b37d2a794211ebbb79d07 [file] [log] [blame]
import sys
from autotest_lib.server import utils
from autotest_lib.server.cros import provision
from autotest_lib.utils.frozen_chromite.lib import metrics
except ImportError:
metrics = utils.metrics_mock
DURATION_METRIC = 'chromeos/autotest/autoserv/reset_duration'
# A string of the form 'label1,label2:value,label3'.
job_labels = locals().get('job_labels') or ','.join(args)
labels_list = [l.strip() for l in job_labels.split(',') if l]
def reset(machine):
print('Starting to reset host %s' % machine)
job.record('START', None, 'reset')
target = hosts.create_target_machine(machine)
hostname = utils.get_hostname_from_machine(machine)
with metrics.SecondsTimer(DURATION_METRIC,
fields={'dut_host_name': hostname}):
# Assume cleanup always runs first.
provision.Cleanup.run_task_actions(job, target, labels_list)
provision.Verify.run_task_actions(job, target, labels_list)
except Exception:
logging.exception('Reset failed due to Exception.')
job.record('END FAIL', None, 'reset')
# See the provision control segment for the explanation of why we're
# doing this.
raise Exception('')
hostname = utils.get_hostname_from_machine(machine)
job.record('END GOOD', None, 'reset',
'%s reset successfully' % hostname)
job.parallel_simple(reset, machines)
# vim: set syntax=python :