blob: 80382e0ab7f844c7bec4d42e085b48ed82c11b30 [file] [log] [blame]
import logging
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(host):
protection = host_protections.Protection
try:
level = protection.get_value(protection_level)
except ValueError:
raise NotImplementedError("Unknown host protection level %s" %
protection_level)
logging.debug('Protection level of host %s is %s: %s',
host.hostname, protection_level, level)
host.repair_with_protection(level)
def repair(machine):
try:
job.record('START', None, 'repair')
host = hosts.create_host(machine, initialize=False, auto_monitor=False)
_call_repair(host)
logging.debug('Repair with labels list %s', labels_list)
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 :