blob: 99c33bb12a5a94072f1966eaa8e44dc174d090b0 [file] [log] [blame]
from autotest_lib.client.common_lib import host_protections
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)
# call the appropriate repair function based on protection level
if level == protection.DO_NOT_REPAIR:
print "Host is specified as 'Do not repair', skipping repair stage"
elif level == protection.REPAIR_FILESYSTEM_ONLY:
print "Attempting filesystem-only repair"
host = hosts.create_host(machine, initialize=False)
host.repair_filesystem_only()
elif level == protection.REPAIR_SOFTWARE_ONLY:
print "Attempting software repair only"
host = hosts.create_host(machine, initialize=False, auto_monitor=False)
host.repair_software_only()
elif level == protection.NO_PROTECTION:
print "Attempting full repair"
host = hosts.create_host(machine, initialize=False, auto_monitor=False)
host.repair_full()
def repair(machine):
try:
_call_repair(machine)
except Exception, e:
msg = 'repair failed on %s: %s\n' % (machine, str(e))
job.record('FAIL', None, 'repair', msg)
raise
job.parallel_simple(repair, machines, log=False)