blob: b5b215627d3192ffb7bd51110cf91562a28bd5e0 [file] [log] [blame]
mbligh313b9262009-09-03 20:49:54 +00001import logging
mblighf957fe22009-05-12 20:51:56 +00002from autotest_lib.client.common_lib import enum, global_config
showarddf062562008-07-03 19:56:37 +00003
mbligh3f033d52009-04-01 18:36:08 +00004# Changing this file has consequences that need to be understood.
5# Adding a protection level to the enum requires you to append your change to
6# the end of the enum or a database migration needs to be added to migrate
7# older protections to match the layout of the new enum.
8# Removing a protection level from the enum requires a database migration to
9# update the integer values in the DB and migrate hosts that use the removed
10# protection to a default protection level.
11# IF THIS IS NOT DONE HOSTS' PROTECTION LEVELS WILL BE CHANGED RANDOMLY.
12
mblighb024fb12008-07-11 21:24:21 +000013Protection = enum.Enum('No protection', # Repair can do anything to
14 # this host.
mbligh25c0b8c2009-01-24 01:44:17 +000015 'Repair software only', # repair should try to fix any
16 # software problem
mblighb024fb12008-07-11 21:24:21 +000017 'Repair filesystem only', # Repair should only try to
18 # recover the file system.
showardc9ae1782009-01-30 01:42:37 +000019 'Do not repair', # Repair should not touch this
mblighb024fb12008-07-11 21:24:21 +000020 # host.
showardc9ae1782009-01-30 01:42:37 +000021 'Do not verify', # Don't even try to verify
22 # this host
showarddf062562008-07-03 19:56:37 +000023 )
24
lmr6d08b3c2009-11-18 19:26:38 +000025running_client = global_config.global_config.check_stand_alone_client_run()
26
mbligh313b9262009-09-03 20:49:54 +000027try:
28 _bad_value = object()
lmr6d08b3c2009-11-18 19:26:38 +000029 default_protection = global_config.global_config.get_config_value(
30 'HOSTS', 'default_protection', default=_bad_value)
31 if default_protection == _bad_value:
lmrda8fb972009-12-01 22:49:08 +000032 if not running_client:
lmr6d08b3c2009-11-18 19:26:38 +000033 raise global_config.ConfigError(
34 'No HOSTS.default_protection defined in global_config.ini')
35 else:
36 default = Protection.get_value(default_protection)
37
lmrda8fb972009-12-01 22:49:08 +000038# It is OK to have an empty global configuration object (stand alone client)
39# so we trap this exception.
mbligh313b9262009-09-03 20:49:54 +000040except global_config.ConfigError:
lmrda8fb972009-12-01 22:49:08 +000041 pass
showarddf062562008-07-03 19:56:37 +000042
43choices = Protection.choices()