blob: b6fe1131194be00ec75fce551b49f0ba32d690b2 [file] [log] [blame]
from autotest_lib.client.common_lib import host_protections
from autotest_lib.server.cros import repair_utils
from autotest_lib.server.cros import provision
# 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 _call_repair(machine):
protection = host_protections.Protection
try:
level = protection.get_value(protection_level)
except ValueError:
raise NotImplementedError("Unknown host protection level %s" %
protection_level)
host = hosts.create_host(machine, initialize=False, auto_monitor=False)
host.repair_with_protection(level)
def repair(machine):
try:
job.record('START', None, 'repair')
_call_repair(machine)
provision.run_special_task_actions(job, host, labels_list,
provision.Repair)
except Exception as e:
repair_utils.flag_problem_test(machine)
job.record('END FAIL', None, 'repair')
# See the provision control segment for the explanation of why we're
# doing this.
raise Exception('')
else:
job.record('END GOOD', None, 'repair',
'%s repaired successfully' % machine)
job.parallel_simple(repair, machines)
# vim: set syntax=python :